org.deeplearning4j.models.word2vec.StaticWord2Vec Maven / Gradle / Ivy
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 [email protected]
*/
@Slf4j
public class StaticWord2Vec implements WordVectors {
private List