fastText4j icon indicating copy to clipboard operation
fastText4j copied to clipboard

The problem in JAVA model

Open UB1010 opened this issue 8 years ago • 2 comments

Hi, I tested the fastText4j, and train model by: fastText = FastText.train("ag.train", ModelName.sup); fastText.saveModel(java_model);

than load model for predicting a sentence: fastText = FastText.loadModel(java_model); fastText.predict(Arrays.asList(testStr.split(" ")), 5);

get error: java.lang.ArithmeticException: / by zero at com.mayabot.mynlp.fasttext.AreaByteBufferMatrix.get(Matrix.kt:222) at com.mayabot.mynlp.fasttext.FastText.addInputVector(FastText.kt:261) at com.mayabot.mynlp.fasttext.FastText.getWordVector(FastText.kt:196) at com.mayabot.mynlp.fasttext.FastText.getWordVector(FastText.kt:207)

But, i used same data, train model by fastText-0.1.0, load model by: FastText.loadFasttextBinModel(cpp_model); predict = fastText.predict(Arrays.asList(testStr.split(" ")), 5);

That is OK:

predict result:[[__label__4,0.9996598], [__label__1,2.4863696E-4], [__label__3,1.076918E-4], [__label__2,2.3928827E-5]]

Why?

Thank you.

UB1010 avatar Aug 15 '18 09:08 UB1010

thank you report this bug! I will fixit in v1.1.2

jimichenx avatar Aug 16 '18 14:08 jimichenx

u can update to 1.1.2

jimichenx avatar Aug 16 '18 18:08 jimichenx