1
我在Deeplearning4j中使用了Doc2Vec算法,在我的Windows 10 PC上運行它時它工作正常,但是當我嘗試在Linux機器上運行它時,出現以下錯誤:無法在Linux中構建ParagraphVectors
java.lang.NoClassDefFoundError: Could not initialize class org.nd4j.linalg.factory.Nd4j
at org.deeplearning4j.models.embeddings.inmemory.InMemoryLookupTable$Builder.<init>(InMemoryLookupTable.java:581) ~[run.jar:?]
at org.deeplearning4j.models.sequencevectors.SequenceVectors$Builder.presetTables(SequenceVectors.java:801) ~[run.jar:?]
at org.deeplearning4j.models.paragraphvectors.ParagraphVectors$Builder.build(ParagraphVectors.java:663) ~[run.jar:?]
我一對夫婦的Linux機器,而這兩者都是運行Xubuntu上的嘗試這樣做,有須藤權限
這裏是我創造的ParagraphVectors代碼: InputStream的是=新ByteArrayInputStream的( baos.toByteArray());
LabelAwareSentenceIterator iter;
iter = new LabelAwareListSentenceIterator(is, DELIM);
iter.setPreProcessor(new SentencePreProcessor() {
@Override
public String preProcess(String sentence) {
return new InputHomogenization(sentence).transform();
}
});
TokenizerFactory tokenizerFactory = new DefaultTokenizerFactory();
vec = new ParagraphVectors.Builder().minWordFrequency(minWordFrequency).batchSize(batchSize)
.iterations(iterations).layerSize(layerSize).stopWords(stopWords).windowSize(windowSize)
.learningRate(learningRate).tokenizerFactory(tokenizerFactory).iterate(iter).build();
vec.fit();
這裏是我的pom.xml(版本0.7.1所有,但我一直在使用0.4 rc3.9,並得到了同樣的錯誤):
<dependency>
<groupId>org.deeplearning4j</groupId>
<artifactId>deeplearning4j-ui-model</artifactId>
<version>${dl4j.version}</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
<exclusion>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.deeplearning4j</groupId>
<artifactId>deeplearning4j-nlp</artifactId>
<version>${dl4j.version}</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
<exclusion>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.nd4j</groupId>
<artifactId>nd4j-native</artifactId>
<version>${nd4j.version}</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
<exclusion>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- https://mvnrepository.com/artifact/org.datavec/datavec-api -->
<dependency>
<groupId>org.datavec</groupId>
<artifactId>datavec-api</artifactId>
<version>${nd4j.version}</version>
</dependency>
謝謝,我使用了nd4j-native-platform,現在它運行在Linux上。奇怪的是,我將它作爲Apache Storm集羣的一部分使用,並且我仍然遇到同樣的錯誤,但它在LocalCluster上與本地平臺一起工作,所以現在是Storm問題。 –