Java Code Examples for org.deeplearning4j.models.word2vec.Word2Vec#setLookupTable()

The following examples show how to use org.deeplearning4j.models.word2vec.Word2Vec#setLookupTable() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WordVectorSerializer.java    From deeplearning4j with Apache License 2.0 6 votes vote down vote up
/**
 * This method loads Word2Vec model from input stream
 *
 * @param stream InputStream
 * @param readExtendedTable boolean
 * @return Word2Vec
 */
public static Word2Vec readWord2Vec(
            @NonNull InputStream stream,
            boolean readExtendedTable) throws IOException {
    SequenceVectors<VocabWord> vectors = readSequenceVectors(stream, readExtendedTable);

    Word2Vec word2Vec = new Word2Vec
            .Builder(vectors.getConfiguration())
            .layerSize(vectors.getLayerSize())
            .build();
    word2Vec.setVocab(vectors.getVocab());
    word2Vec.setLookupTable(vectors.lookupTable());
    word2Vec.setModelUtils(vectors.getModelUtils());

    return word2Vec;
}
 
Example 2
Source File: WordVectorSerializer.java    From deeplearning4j with Apache License 2.0 5 votes vote down vote up
/**
 * Load word vectors from the given pair
 *
 * @param pair the given pair
 * @return a read only word vectors impl based on the given lookup table and vocab
 */
public static Word2Vec fromPair(Pair<InMemoryLookupTable, VocabCache> pair) {
    Word2Vec vectors = new Word2Vec();
    vectors.setLookupTable(pair.getFirst());
    vectors.setVocab(pair.getSecond());
    vectors.setModelUtils(new BasicModelUtils());
    return vectors;
}