Class Doc2Vec

java.lang.Object
ai.beestream.jitnn.nn.Module
ai.beestream.jitnn.nn.models.Doc2Vec
All Implemented Interfaces:
AutoCloseable

public final class Doc2Vec extends Module
Paragraph vectors (Le and Mikolov, 2014) with negative sampling. PV-DBOW predicts the words of a document from its vector alone; PV-DM predicts a word from the mean of the document vector and the word vectors of its context.
  • Constructor Details

    • Doc2Vec

      public Doc2Vec(int vocab, int documents, int dim, Doc2Vec.Mode mode, long seed)
      Paragraph vectors for documents documents over vocab words, vectors of dim, trained as mode says, initialised from seed.
  • Method Details

    • loss

      public Tensor loss(int[] documents, int[] targets, int[] contexts, int[] negatives, int k)
      The loss of a batch: document ids [B], the predicted words [B], for PV-DM the context words [B * window2] (null for PV-DBOW), and k negatives per sample.
    • forward

      public Tensor forward(Tensor x)
      The document vectors of ids x.
      Specified by:
      forward in class Module
    • documentVectors

      public float[] documentVectors()
      All document vectors [documents, dim] on the host.
    • dim

      public int dim()
      The vector size.