Package ai.djl.basicmodelzoo.nlp
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
blockFields inherited from class ai.djl.nn.AbstractBlock
children, parametersFields inherited from class ai.djl.nn.AbstractBaseBlock
inputNames, inputShapes, outputDataTypes, version -
Constructor Summary
ConstructorsConstructorDescriptionSimpleTextEncoder(ai.djl.modality.nlp.embedding.TrainableTextEmbedding trainableTextEmbedding, ai.djl.nn.recurrent.RecurrentBlock recurrentBlock) Contructs a new instance ofSimpleTextEncoderwith the givenRecurrentBlockandTrainableTextEmbedding.SimpleTextEncoder(ai.djl.nn.recurrent.RecurrentBlock recurrentBlock) Contructs a new instance ofSimpleTextEncoderwith the givenRecurrentBlock. -
Method Summary
Modifier and TypeMethodDescriptionai.djl.ndarray.NDListgetStates(ai.djl.ndarray.NDList encoderOutput) Methods inherited from class ai.djl.modality.nlp.Encoder
forwardInternal, forwardInternal, getOutputShapes, initializeChildBlocks, loadParameters, saveParametersMethods inherited from class ai.djl.nn.AbstractBlock
addChildBlock, addChildBlock, addChildBlockSingleton, addParameter, getChildren, getDirectParametersMethods 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, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods 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 ofSimpleTextEncoderwith the givenRecurrentBlock. 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 ofSimpleTextEncoderwith the givenRecurrentBlockandTrainableTextEmbedding. Use this constructor if you are planning to use pre-trained or fresh embeddings that need further training.- Parameters:
trainableTextEmbedding- theTrainableTextEmbeddingto train embeddings withrecurrentBlock- the recurrent block to be used to encode
-
-
Method Details
-
getStates
public ai.djl.ndarray.NDList getStates(ai.djl.ndarray.NDList encoderOutput) - Specified by:
getStatesin classai.djl.modality.nlp.Encoder
-