Class Word2Vec
java.lang.Object
ai.beestream.jitnn.nn.Module
ai.beestream.jitnn.nn.models.Word2Vec
- All Implemented Interfaces:
AutoCloseable
word2vec (Mikolov et al., 2013) with negative sampling: an input embedding (the word vectors)
and an output embedding, initialised like the original C code (input uniform in +-0.5 / dim,
output zero). Skip-gram predicts a context word from the centre word, CBOW the centre word from
the mean of its context. Examples come from
Corpus.-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionWord2Vec(int vocab, int dim, Word2Vec.Mode mode, long seed) word2vec overvocabwords with vectors ofdim, trained asmodesays, initialised fromseed. -
Method Summary
Modifier and TypeMethodDescriptionintdim()The vector size.The word vectors of ids x.loss(int[] centres, int[] contexts, int[] negatives, int k) The loss of a batch: skip-gram takes centres [B] and contexts [B]; CBOW takes the centre words [B] and their contexts [B * window2] (window2 per sample). negatives holds k words per sample.float[]vectors()All word vectors [vocab, dim] on the host.Methods inherited from class Module
buffer, buffers, child, close, isClosed, isTraining, loadStateDict, parameter, parameterCount, parameters, stateDict, train, zeroGrad
-
Constructor Details
-
Word2Vec
word2vec overvocabwords with vectors ofdim, trained asmodesays, initialised fromseed.
-
-
Method Details
-
loss
The loss of a batch: skip-gram takes centres [B] and contexts [B]; CBOW takes the centre words [B] and their contexts [B * window2] (window2 per sample). negatives holds k words per sample. -
forward
-
vectors
public float[] vectors()All word vectors [vocab, dim] on the host. -
dim
public int dim()The vector size.
-