Class SimpleTextEncoder

java.lang.Object
ai.djl.nn.AbstractBaseBlock
ai.djl.nn.AbstractBlock
ai.djl.modality.nlp.Encoder
ai.djl.basicmodelzoo.nlp.SimpleTextEncoder
All Implemented Interfaces:
ai.djl.nn.Block

public class SimpleTextEncoder extends ai.djl.modality.nlp.Encoder
SimpleTextEncoder implements a Encoder that employs a RecurrentBlock to encode text input.
  • Field Summary

    Fields inherited from class ai.djl.modality.nlp.Encoder

    block

    Fields inherited from class ai.djl.nn.AbstractBlock

    children, parameters

    Fields inherited from class ai.djl.nn.AbstractBaseBlock

    inputNames, inputShapes, outputDataTypes, version
  • Constructor Summary

    Constructors
    Constructor
    Description
    SimpleTextEncoder(ai.djl.modality.nlp.embedding.TrainableTextEmbedding trainableTextEmbedding, ai.djl.nn.recurrent.RecurrentBlock recurrentBlock)
    Contructs a new instance of SimpleTextEncoder with the given RecurrentBlock and TrainableTextEmbedding.
    SimpleTextEncoder(ai.djl.nn.recurrent.RecurrentBlock recurrentBlock)
    Contructs a new instance of SimpleTextEncoder with the given RecurrentBlock.
  • Method Summary

    Modifier and Type
    Method
    Description
    ai.djl.ndarray.NDList
    getStates(ai.djl.ndarray.NDList encoderOutput)

    Methods inherited from class ai.djl.modality.nlp.Encoder

    forwardInternal, forwardInternal, getOutputShapes, initializeChildBlocks, loadParameters, saveParameters

    Methods inherited from class ai.djl.nn.AbstractBlock

    addChildBlock, addChildBlock, addChildBlockSingleton, addParameter, getChildren, getDirectParameters

    Methods inherited from class ai.djl.nn.AbstractBaseBlock

    beforeInitialize, cast, clear, describeInput, forward, forward, getInputShapes, getOutputDataTypes, getParameters, initialize, isInitialized, loadMetadata, prepare, readInputShapes, saveInputShapes, saveMetadata, setInitializer, setInitializer, setInitializer, toString

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

    Methods inherited from interface ai.djl.nn.Block

    forward, freezeParameters, freezeParameters, getOutputShapes
  • Constructor Details

    • SimpleTextEncoder

      public SimpleTextEncoder(ai.djl.nn.recurrent.RecurrentBlock recurrentBlock)
      Contructs a new instance of SimpleTextEncoder with the given RecurrentBlock. Use this constructor if you are planning to use pre-trained embeddings that don't need further training.
      Parameters:
      recurrentBlock - the recurrent block to be used to encode
    • SimpleTextEncoder

      public SimpleTextEncoder(ai.djl.modality.nlp.embedding.TrainableTextEmbedding trainableTextEmbedding, ai.djl.nn.recurrent.RecurrentBlock recurrentBlock)
      Contructs a new instance of SimpleTextEncoder with the given RecurrentBlock and TrainableTextEmbedding. Use this constructor if you are planning to use pre-trained or fresh embeddings that need further training.
      Parameters:
      trainableTextEmbedding - the TrainableTextEmbedding to train embeddings with
      recurrentBlock - the recurrent block to be used to encode
  • Method Details

    • getStates

      public ai.djl.ndarray.NDList getStates(ai.djl.ndarray.NDList encoderOutput)
      Specified by:
      getStates in class ai.djl.modality.nlp.Encoder