public class EncoderDecoder extends AbstractBlock
| Modifier and Type | Field and Description |
|---|---|
protected Decoder |
decoder |
protected Encoder |
encoder |
children, inputNames, inputShapes, parameters, parameterShapeCallbacks, 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 inputs,
boolean training)
Applies the operating function of the block once.
|
NDList |
forward(ParameterStore parameterStore,
NDList inputs,
boolean training,
ai.djl.util.PairList<java.lang.String,java.lang.Object> params)
Applies the operating function of the block once.
|
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.
|
Shape[] |
getOutputShapes(NDManager manager,
Shape[] inputShapes)
Returns the expected output shapes of the block for the specified input shapes.
|
Shape[] |
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, addParameter, addParameter, beforeInitialize, cast, clear, getChildren, getDirectParameters, getParameters, getParameterShape, initializeChildBlocks, isInitialized, loadMetadata, readInputShapes, saveInputShapes, saveMetadata, setInitializer, setInitializer, toStringclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitvalidateLayoutpublic 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 shapespublic NDList forward(ParameterStore parameterStore, NDList inputs, boolean training)
parameterStore - the parameter storeinputs - the input NDListtraining - true for a training forward passpublic NDList forward(ParameterStore parameterStore, NDList inputs, boolean training, ai.djl.util.PairList<java.lang.String,java.lang.Object> params)
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.
parameterStore - the parameter storedata - the input data NDListlabels - the input labels NDListparams - optional parametersBlock.forward(ParameterStore, NDList, boolean, PairList)public Shape[] 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(NDManager manager, Shape[] inputShapes)
manager - an NDManagerinputShapes - 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