【问题标题】:Can't build ParagraphVectors in Linux无法在 Linux 中构建 ParagraphVectors
【发布时间】:2016-12-15 20:03:28
【问题描述】:

我正在使用带有 Deeplearning4j 的 Doc2Vec 算法,当我在 Windows 10 PC 上运行它时它运行良好,但是当我尝试在 Linux 机器上运行它时,我收到以下错误:

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 并具有 sudo 权限

这是创建我的 ParagraphVectors 的代码: InputStream is = new 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>

【问题讨论】:

    标签: linux ubuntu deep-learning deeplearning4j nd4j


    【解决方案1】:

    首先始终坚持使用最新版本。你能发布完整的堆栈跟踪吗?这绝对是不是的根本原因。也许尝试使用 nd4j-native-platform 代替?通常这是缺少原生工件的问题。

    【讨论】:

    • 谢谢,我使用了 nd4j-native-platform,现在它在 Linux 上运行。奇怪的是,我将它用作 Apache Storm 集群的一部分,但仍然遇到同样的错误,但它在 LocalCluster 上适用于本机平台,所以现在是 Storm 问题。
    猜你喜欢
    • 2012-08-24
    • 1970-01-01
    • 1970-01-01
    • 2022-12-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-11-22
    • 2014-10-03
    相关资源
    最近更新 更多