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, toStringclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitforward, validateLayoutpublic ai.djl.util.PairList<java.lang.String,Shape> describeInput()
PairList of input names, and shapes.describeInput in interface BlockdescribeInput in class AbstractBlockPairList 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 AbstractBlockparameterStore - 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 Blockforward in class AbstractBlockparameterStore - 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 Blockinitialize in class AbstractBlockmanager - 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 BlocksaveParameters in class AbstractBlockos - 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 BlockloadParameters in class AbstractBlockmanager - 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