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 aEncoder
that employs aRecurrentBlock
to encode text input.
-
-
Constructor Summary
Constructors Constructor Description SimpleTextEncoder(ai.djl.modality.nlp.embedding.TrainableTextEmbedding trainableTextEmbedding, ai.djl.nn.recurrent.RecurrentBlock recurrentBlock)
Contructs a new instance ofSimpleTextEncoder
with the givenRecurrentBlock
andTrainableTextEmbedding
.SimpleTextEncoder(ai.djl.nn.recurrent.RecurrentBlock recurrentBlock)
Contructs a new instance ofSimpleTextEncoder
with the givenRecurrentBlock
.
-
Method Summary
All Methods Instance Methods Concrete Methods 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
-
-
-
-
Constructor Detail
-
SimpleTextEncoder
public SimpleTextEncoder(ai.djl.nn.recurrent.RecurrentBlock recurrentBlock)
Contructs a new instance ofSimpleTextEncoder
with 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 ofSimpleTextEncoder
with the givenRecurrentBlock
andTrainableTextEmbedding
. Use this constructor if you are planning to use pre-trained or fresh embeddings that need further training.- Parameters:
trainableTextEmbedding
- theTrainableTextEmbedding
to train embeddings withrecurrentBlock
- the recurrent block to be used to encode
-
-