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
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
ConstructorDescriptionSimpleTextEncoder
(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
Modifier and TypeMethodDescriptionai.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 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
-
-
Method Details
-
getStates
public ai.djl.ndarray.NDList getStates(ai.djl.ndarray.NDList encoderOutput) - Specified by:
getStates
in classai.djl.modality.nlp.Encoder
-