Class Deconvolution
- All Implemented Interfaces:
Block
- Direct Known Subclasses:
Conv1dTranspose,Conv2dTranspose
The need for transposed convolutions generally arises from the desire to use a transformation going in the opposite direction of a normal convolution, i.e., from something that has the shape of the output of some convolution to something that has the shape of its input while maintaining a connectivity pattern that is compatible with said convolution.
Current implementations of Deconvolution are Conv1dTranspose with input
dimension of LayoutType.WIDTH and Conv2dTranspose with input dimension of LayoutType.WIDTH and LayoutType.HEIGHT. These implementations share the same core
principal as a Deconvolution layer does, with the difference being the number of input
dimension each operates on as denoted by ConvXdTranspose for X dimension(s).
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classA builder that can build anyDeconvolutionblock. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Parameterprotected Shapeprotected intprotected intprotected booleanprotected Shapeprotected Shapeprotected Shapeprotected Shapeprotected ParameterFields inherited from class ai.djl.nn.AbstractBlock
children, parametersFields inherited from class ai.djl.nn.AbstractBaseBlock
inputNames, inputShapes, outputDataTypes, version -
Constructor Summary
ConstructorsConstructorDescriptionDeconvolution(Deconvolution.DeconvolutionBuilder<?> builder) Creates aDeconvolutionobject. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidbeforeInitialize(Shape... inputShapes) Performs any action necessary before initialization.protected NDListforwardInternal(ParameterStore parameterStore, NDList inputs, boolean training, ai.djl.util.PairList<String, Object> params) A helper forBlock.forward(ParameterStore, NDList, boolean, PairList)after initialization.protected abstract LayoutType[]Returns the expected layout of the input.Shape[]getOutputShapes(Shape[] inputs) Returns the expected output shapes of the block for the specified input shapes.protected abstract StringReturns the string representing the layout of the input.voidloadMetadata(byte loadVersion, DataInputStream is) Overwrite this to load additional metadata with the parameter values.protected abstract intReturns the number of dimensions of the input.protected voidSets the shape ofParameters.Methods inherited from class ai.djl.nn.AbstractBlock
addChildBlock, addChildBlock, addChildBlockSingleton, addParameter, getChildren, getDirectParametersMethods inherited from class ai.djl.nn.AbstractBaseBlock
cast, clear, describeInput, forward, forward, forwardInternal, getInputShapes, getOutputDataTypes, getParameters, initialize, initializeChildBlocks, isInitialized, loadParameters, readInputShapes, saveInputShapes, saveMetadata, saveParameters, 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
forward, freezeParameters, freezeParameters, getCustomMetadata, getOutputShapes
-
Field Details
-
kernelShape
-
stride
-
padding
-
outPadding
-
dilation
-
filters
protected int filters -
groups
protected int groups -
includeBias
protected boolean includeBias -
weight
-
bias
-
-
Constructor Details
-
Deconvolution
Creates aDeconvolutionobject.- Parameters:
builder- theBuilderthat has the necessary configurations
-
-
Method Details
-
getExpectedLayout
Returns the expected layout of the input.- Returns:
- the expected layout of the input
-
getStringLayout
Returns the string representing the layout of the input.- Returns:
- the string representing the layout of the input
-
numDimensions
protected abstract int numDimensions()Returns the number of dimensions of the input.- Returns:
- the number of dimensions of the input
-
forwardInternal
protected NDList forwardInternal(ParameterStore parameterStore, NDList inputs, boolean training, ai.djl.util.PairList<String, Object> params) A helper forBlock.forward(ParameterStore, NDList, boolean, PairList)after initialization.- Specified by:
forwardInternalin classAbstractBaseBlock- Parameters:
parameterStore- the parameter storeinputs- the input NDListtraining- true for a training forward passparams- optional parameters- Returns:
- the output of the forward pass
-
beforeInitialize
Performs any action necessary before initialization. For example, keep the input information or verify the layout.- Overrides:
beforeInitializein classAbstractBaseBlock- Parameters:
inputShapes- the expected shapes of the input
-
prepare
Sets the shape ofParameters.- Overrides:
preparein classAbstractBaseBlock- Parameters:
inputs- the shapes of inputs
-
getOutputShapes
Returns the expected output shapes of the block for the specified input shapes.- Parameters:
inputs- the shapes of the inputs- Returns:
- the expected output shapes of the block
-
loadMetadata
public void loadMetadata(byte loadVersion, DataInputStream is) throws IOException, MalformedModelException Overwrite this to load additional metadata with the parameter values.If you overwrite
AbstractBaseBlock.saveMetadata(DataOutputStream)or need to provide backward compatibility to older binary formats, you probably need to overwrite this. This default implementation checks if the version number fits, if not it throws anMalformedModelException. After that it restores the input shapes.- Overrides:
loadMetadatain classAbstractBaseBlock- Parameters:
loadVersion- the version used for loading this metadata.is- the input stream we are loading from- Throws:
IOException- loading failedMalformedModelException- data can be loaded but has wrong format
-