You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by jkbradley <gi...@git.apache.org> on 2017/02/03 01:53:32 UTC

[GitHub] spark pull request #16607: [SPARK-19247][ML] Save large word2vec models

Github user jkbradley commented on a diff in the pull request:

    https://github.com/apache/spark/pull/16607#discussion_r99263532
  
    --- Diff: mllib/src/main/scala/org/apache/spark/ml/feature/Word2Vec.scala ---
    @@ -302,16 +302,36 @@ class Word2VecModel private[ml] (
     @Since("1.6.0")
     object Word2VecModel extends MLReadable[Word2VecModel] {
     
    +  private case class Data(word: String, vector: Array[Float])
    +
       private[Word2VecModel]
       class Word2VecModelWriter(instance: Word2VecModel) extends MLWriter {
     
    -    private case class Data(wordIndex: Map[String, Int], wordVectors: Seq[Float])
    -
         override protected def saveImpl(path: String): Unit = {
           DefaultParamsWriter.saveMetadata(instance, path, sc)
    -      val data = Data(instance.wordVectors.wordIndex, instance.wordVectors.wordVectors.toSeq)
    +
    +      val wordVectors = instance.wordVectors.getVectors
    +      val dataArray = wordVectors.toSeq.map { case (word, vector) => Data(word, vector) }.toArray
    --- End diff --
    
    No need to convert back to an Array


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org