# Error occurs when training spark word2vec

**URL:** <https://community.konduit.ai/t/error-occurs-when-training-spark-word2vec/710>\
**Category:** DL4J\
**Created:** [July 10, 2020, 3:44am UTC](https://community.konduit.ai/t/error-occurs-when-training-spark-word2vec/710 "2020-07-10T03:44:58Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![iloveu](https://avatars.discourse-cdn.com/v4/letter/i/ecc23a/32.png) [@iloveu](https://community.konduit.ai/u/iloveu)\
**Post date:** [July 10, 2020, 3:44am UTC](https://community.konduit.ai/t/error-occurs-when-training-spark-word2vec/710/1 "2020-07-10T03:44:58Z")

</div>

Hi,

I’m using org.deeplearning4j.spark.models.embeddings.word2vec.Word2Vec to train word2vec, and the following errors occur

> Exception in thread “main” java.lang.IllegalStateException: Cannot perform in-place operation “addi”: result array shape does not match the broadcast operation output shape: [200].addi([1, 200]) != [200].  
> In-place operations like x.addi(y) can only be performed when x and y have the same shape, or x and y are broadcastable with x.shape() == broadcastShape(x,y)  
> at org.nd4j.linalg.api.shape.Shape.assertBroadcastable(Shape.java:283)  
> at org.nd4j.linalg.api.ndarray.BaseNDArray.addi(BaseNDArray.java:3251)  
> at org.nd4j.linalg.api.ndarray.BaseNDArray.addi(BaseNDArray.java:3245)  
> at org.deeplearning4j.spark.models.embeddings.word2vec.Word2Vec.train(Word2Vec.java:222)  
> at dl4jword2vec.Fun.main(Fun.java:24)

Here is my testing program [Plain Text code - 26 lines - codepad](http://codepad.org/0ZZvNFZI), and the POM.xml is here [Plain Text code - 60 lines - codepad](http://codepad.org/xDuX20l7). I’m not sure if I do anything wrong. The training file “/tmp/test” is just 100 lines of “a b c d e f g h I j k”.

Thank you all in advance.

---

<div class="post-metadata">

**Author:** ![treo](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.konduit.ai/treo/32/47_2.png) [@treo](https://community.konduit.ai/u/treo)\
**Post date:** [July 10, 2020, 6:57am UTC](https://community.konduit.ai/t/error-occurs-when-training-spark-word2vec/710/2 "2020-07-10T06:57:52Z")

</div>

That appears to be a bug. Not many people are still using Word2Vec, and fewer still are using it on Spark.

Please report this bug on github: [Issues · eclipse/deeplearning4j · GitHub](https://github.com/eclipse/deeplearning4j/issues)

---

<div class="post-metadata">

**Author:** ![iloveu](https://avatars.discourse-cdn.com/v4/letter/i/ecc23a/32.png) [@iloveu](https://community.konduit.ai/u/iloveu)\
**Post date:** [July 10, 2020, 7:29am UTC](https://community.konduit.ai/t/error-occurs-when-training-spark-word2vec/710/3 "2020-07-10T07:29:06Z")

</div>

Thank you! Will report it.
