我试图为deeplearning4j提出补丁,但首先我需要能够构建项目。我可以使用手动指令从maven构建它,但IntelliJ(2016.3.6)发现错误,当我查看源代码时,我不会责怪它。
我特意难以接受的源文件是https://github.com/deeplearning4j/deeplearning4j/blob/master/deeplearning4j-nlp-parent/deeplearning4j-nlp/src/main/java/org/deeplearning4j/models/word2vec/StaticWord2Vec.java,它有一些未在此文件中声明的变量log
的引用。
package org.deeplearning4j.models.word2vec;
import lombok.extern.slf4j.Slf4j;
import org.deeplearning4j.models.embeddings.WeightLookupTable;
import org.deeplearning4j.models.embeddings.reader.ModelUtils;
import org.deeplearning4j.models.embeddings.wordvectors.WordVectors;
import org.deeplearning4j.models.word2vec.wordstore.VocabCache;
import org.nd4j.linalg.api.ndarray.INDArray;
import org.nd4j.linalg.compression.AbstractStorage;
import org.nd4j.linalg.factory.Nd4j;
import org.nd4j.linalg.ops.transforms.Transforms;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
/**
* This is special limited Word2Vec implementation, suited for serving as lookup table in concurrent multi-gpu environment
* This implementation DOES NOT load all vectors onto any of gpus, instead of that it holds vectors in, optionally, compressed state in host memory.
* This implementation DOES NOT provide some of original Word2Vec methods, such as wordsNearest or wordsNearestSum.
*
* @author raver119@gmail.com
*/
@Slf4j
public class StaticWord2Vec implements WordVectors {
private List<Map<Integer, INDArray>> cacheWrtDevice = new ArrayList<>();
private AbstractStorage<Integer> storage;
private long cachePerDevice = 0L;
private VocabCache<VocabWord> vocabCache;
private String unk = null;
... snipped
该类扩展了一个接口,但没有显式扩展父类。使用javap检查Maven生成的类文件,我看到:
Compiled from "StaticWord2Vec.java"
public class org.deeplearning4j.models.word2vec.StaticWord2Vec
implements org.deeplearning4j.models.embeddings.wordvectors.WordVectors {
private static final org.slf4j.Logger log;
... snipped