File tree Expand file tree Collapse file tree 1 file changed +4
-2
lines changed
mllib/src/main/scala/org/apache/spark/mllib/feature Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Original file line number Diff line number Diff line change @@ -248,7 +248,7 @@ class Word2Vec extends Serializable with Logging {
248248 */
249249 def fit [S <: Iterable [String ]](dataset : RDD [S ]): Word2VecModel = {
250250
251- val words = dataset.flatMap(x => x)
251+ val words = dataset.flatMap(x => x).cache()
252252
253253 learnVocab(words)
254254
@@ -281,7 +281,9 @@ class Word2Vec extends Serializable with Logging {
281281 }
282282 }
283283
284- val newSentences = sentences.repartition(numPartitions).cache()
284+ val newSentences = sentences.repartition(numPartitions)
285+ words.unpersist()
286+ newSentences.cache()
285287 val initRandom = new XORShiftRandom (seed)
286288 val syn0Global =
287289 Array .fill[Float ](vocabSize * vectorSize)((initRandom.nextFloat() - 0.5f ) / vectorSize)
You can’t perform that action at this time.
0 commit comments