public class EncoderDecoder extends AbstractBlock
Modifier and Type | Field and Description |
---|---|
protected Decoder |
decoder |
protected Encoder |
encoder |
children, inputNames, inputShapes, parameters, version
Constructor and Description |
---|
EncoderDecoder(Encoder encoder,
Decoder decoder)
|
Modifier and Type | Method and Description |
---|---|
ai.djl.util.PairList<java.lang.String,Shape> |
describeInput()
Returns a
PairList of input names, and shapes. |
NDList |
forward(ParameterStore parameterStore,
NDList data,
NDList labels,
ai.djl.util.PairList<java.lang.String,java.lang.Object> params)
A forward call using both training data and labels.
|
protected NDList |
forwardInternal(ParameterStore parameterStore,
NDList inputs,
boolean training,
ai.djl.util.PairList<java.lang.String,java.lang.Object> params)
A helper for
Block.forward(ParameterStore, NDList, boolean, PairList) after
initialization. |
Shape[] |
getOutputShapes(Shape[] inputShapes)
Returns the expected output shapes of the block for the specified input shapes.
|
void |
initialize(NDManager manager,
DataType dataType,
Shape... inputShapes)
Initializes the parameters of the block.
|
void |
loadParameters(NDManager manager,
java.io.DataInputStream is)
Loads the parameters from the given input stream.
|
void |
saveParameters(java.io.DataOutputStream os)
Writes the parameters of the block to the given outputStream.
|
addChildBlock, addParameter, beforeInitialize, cast, clear, forward, forwardInternal, getChildren, getDirectParameters, getParameters, initializeChildBlocks, isInitialized, loadMetadata, prepare, readInputShapes, saveInputShapes, saveMetadata, setInitializer, setInitializer, setInitializer, toString
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
forward, validateLayout
public ai.djl.util.PairList<java.lang.String,Shape> describeInput()
PairList
of input names, and shapes.describeInput
in interface Block
describeInput
in class AbstractBlock
PairList
of input names, and shapesprotected NDList forwardInternal(ParameterStore parameterStore, NDList inputs, boolean training, ai.djl.util.PairList<java.lang.String,java.lang.Object> params)
Block.forward(ParameterStore, NDList, boolean, PairList)
after
initialization.forwardInternal
in class AbstractBlock
parameterStore
- the parameter storeinputs
- the input NDListtraining
- true for a training forward passparams
- optional parameterspublic NDList forward(ParameterStore parameterStore, NDList data, NDList labels, ai.djl.util.PairList<java.lang.String,java.lang.Object> params)
Within this forward call, it can be assumed that training is true.
forward
in interface Block
forward
in class AbstractBlock
parameterStore
- the parameter storedata
- the input data NDListlabels
- the input labels NDListparams
- optional parametersBlock.forward(ParameterStore, NDList, boolean, PairList)
public void initialize(NDManager manager, DataType dataType, Shape... inputShapes)
This method assumes that inputShapes contains encoder and decoder inputs in index 0 and 1 respectively.
initialize
in interface Block
initialize
in class AbstractBlock
manager
- the NDManager to initialize the parametersdataType
- the datatype of the parametersinputShapes
- the shapes of the inputs to the blockpublic Shape[] getOutputShapes(Shape[] inputShapes)
inputShapes
- the shapes of the inputspublic void saveParameters(java.io.DataOutputStream os) throws java.io.IOException
saveParameters
in interface Block
saveParameters
in class AbstractBlock
os
- the outputstream to save the parameters tojava.io.IOException
- if an I/O error occurspublic void loadParameters(NDManager manager, java.io.DataInputStream is) throws java.io.IOException, MalformedModelException
loadParameters
in interface Block
loadParameters
in class AbstractBlock
manager
- an NDManager to create the parameter arraysis
- the inputstream that stream the parameter valuesjava.io.IOException
- if an I/O error occursMalformedModelException
- if the model file is corrupted or unsupported