Package ai.djl.mxnet.engine
Class MxSymbolBlock
java.lang.Object
ai.djl.nn.AbstractBaseBlock
ai.djl.nn.AbstractSymbolBlock
ai.djl.mxnet.engine.MxSymbolBlock
- All Implemented Interfaces:
ai.djl.nn.Block,ai.djl.nn.SymbolBlock
public class MxSymbolBlock
extends ai.djl.nn.AbstractSymbolBlock
MxSymbolBlock is the MXNet implementation of SymbolBlock.
You can create a MxSymbolBlock using Model.load(java.nio.file.Path, String).
-
Field Summary
Fields inherited from class ai.djl.nn.AbstractBaseBlock
inputNames, inputShapes, outputDataTypes, version -
Constructor Summary
ConstructorsConstructorDescriptionMxSymbolBlock(ai.djl.ndarray.NDManager manager) Constructs an emptyMxSymbolBlock.MxSymbolBlock(ai.djl.ndarray.NDManager manager, Symbol symbol) Constructs aMxSymbolBlockfor aSymbol. -
Method Summary
Modifier and TypeMethodDescriptionai.djl.util.PairList<String,ai.djl.ndarray.types.Shape> ai.djl.util.PairList<String,ai.djl.ndarray.types.Shape> protected ai.djl.ndarray.NDListforwardInternal(ai.djl.training.ParameterStore parameterStore, ai.djl.ndarray.NDList inputs, boolean training, ai.djl.util.PairList<String, Object> params) List<ai.djl.nn.Parameter>Returns the list of inputs and parameter NDArrays.ai.djl.nn.ParameterListReturns the layers' name.ai.djl.ndarray.types.Shape[]getOutputShapes(ai.djl.ndarray.types.Shape[] inputShapes) Returns the Symbolic graph from the model.voidloadParameters(ai.djl.ndarray.NDManager manager, DataInputStream is) voidoptimizeFor(String optimization) Applies Optimization algorithm for the model.voidvoidvoidsetInputNames(List<String> inputNames) Sets the names of the input data.Methods inherited from class ai.djl.nn.AbstractSymbolBlock
getChildrenMethods inherited from class ai.djl.nn.AbstractBaseBlock
beforeInitialize, cast, clear, forward, forward, forwardInternal, getInputShapes, getOutputDataTypes, getParameters, initialize, initializeChildBlocks, isInitialized, loadMetadata, prepare, readInputShapes, saveInputShapes, saveMetadata, setInitializer, setInitializer, setInitializer, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface ai.djl.nn.Block
cast, clear, forward, forward, forward, freezeParameters, freezeParameters, getInputShapes, getOutputDataTypes, getOutputShapes, getParameters, initialize, isInitialized, setInitializer, setInitializer, setInitializer
-
Constructor Details
-
MxSymbolBlock
Constructs aMxSymbolBlockfor aSymbol.You can create a
MxSymbolBlockusingModel.load(java.nio.file.Path, String).- Parameters:
manager- the manager to use for the blocksymbol- the symbol containing the block's symbolic graph
-
MxSymbolBlock
public MxSymbolBlock(ai.djl.ndarray.NDManager manager) Constructs an emptyMxSymbolBlock.- Parameters:
manager- the manager to use for the block
-
-
Method Details
-
setInputNames
Sets the names of the input data.- Parameters:
inputNames- the names of the input data
-
getAllParameters
Returns the list of inputs and parameter NDArrays.- Returns:
- the list of inputs and parameter NDArrays
-
getLayerNames
Returns the layers' name.- Returns:
- a List of String containing the layers' name
-
getSymbol
Returns the Symbolic graph from the model.- Returns:
- a
Symbolobject
-
optimizeFor
Applies Optimization algorithm for the model.- Parameters:
optimization- the name of the optimization
-
describeInput
- Specified by:
describeInputin interfaceai.djl.nn.Block- Overrides:
describeInputin classai.djl.nn.AbstractBaseBlock
-
getDirectParameters
public ai.djl.nn.ParameterList getDirectParameters() -
describeOutput
-
forwardInternal
protected ai.djl.ndarray.NDList forwardInternal(ai.djl.training.ParameterStore parameterStore, ai.djl.ndarray.NDList inputs, boolean training, ai.djl.util.PairList<String, Object> params) - Specified by:
forwardInternalin classai.djl.nn.AbstractBaseBlock
-
getOutputShapes
public ai.djl.ndarray.types.Shape[] getOutputShapes(ai.djl.ndarray.types.Shape[] inputShapes) - Specified by:
getOutputShapesin interfaceai.djl.nn.Block- Overrides:
getOutputShapesin classai.djl.nn.AbstractSymbolBlock
-
removeLastBlock
public void removeLastBlock() -
saveParameters
- Specified by:
saveParametersin interfaceai.djl.nn.Block- Overrides:
saveParametersin classai.djl.nn.AbstractBaseBlock- Throws:
IOException
-
loadParameters
public void loadParameters(ai.djl.ndarray.NDManager manager, DataInputStream is) throws IOException, ai.djl.MalformedModelException - Specified by:
loadParametersin interfaceai.djl.nn.Block- Overrides:
loadParametersin classai.djl.nn.AbstractBaseBlock- Throws:
IOExceptionai.djl.MalformedModelException
-