public abstract class Deconvolution extends AbstractBlock
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).
Modifier and Type | Class and Description |
---|---|
static class |
Deconvolution.DeconvolutionBuilder<T extends Deconvolution.DeconvolutionBuilder>
A builder that can build any
Deconvolution block. |
Modifier and Type | Field and Description |
---|---|
protected Parameter |
bias |
protected Shape |
dilation |
protected int |
filters |
protected int |
groups |
protected boolean |
includeBias |
protected Shape |
kernelShape |
protected Shape |
outPadding |
protected Shape |
padding |
protected Shape |
stride |
protected Parameter |
weight |
children, inputNames, inputShapes, parameters, parameterShapeCallbacks, version
Constructor and Description |
---|
Deconvolution(Deconvolution.DeconvolutionBuilder<?> builder)
Creates a
Deconvolution object. |
Modifier and Type | Method and Description |
---|---|
protected void |
beforeInitialize(Shape[] inputs)
Performs any action necessary before initialization.
|
protected NDList |
forwardInternal(ParameterStore parameterStore,
NDList inputs,
boolean training,
ai.djl.util.PairList<java.lang.String,java.lang.Object> params) |
protected abstract LayoutType[] |
getExpectedLayout()
Returns the expected layout of the input.
|
Shape[] |
getOutputShapes(NDManager manager,
Shape[] inputs)
Returns the expected output shapes of the block for the specified input shapes.
|
protected abstract java.lang.String |
getStringLayout()
Returns the string representing the layout of the input.
|
void |
loadMetadata(byte version,
java.io.DataInputStream is)
Overwrite this to load additional metadata with the parameter values.
|
protected abstract int |
numDimensions()
Returns the number of dimensions of the input.
|
addChildBlock, addParameter, addParameter, addParameter, cast, clear, describeInput, forward, getChildren, getDirectParameters, getParameters, getParameterShape, initialize, initializeChildBlocks, isInitialized, loadParameters, readInputShapes, saveInputShapes, saveMetadata, saveParameters, setInitializer, setInitializer, toString
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
forward, forward, validateLayout
protected Shape kernelShape
protected Shape stride
protected Shape padding
protected Shape outPadding
protected Shape dilation
protected int filters
protected int groups
protected boolean includeBias
protected Parameter weight
protected Parameter bias
public Deconvolution(Deconvolution.DeconvolutionBuilder<?> builder)
Deconvolution
object.builder
- the Builder
that has the necessary configurationsprotected abstract LayoutType[] getExpectedLayout()
protected abstract java.lang.String getStringLayout()
protected abstract int numDimensions()
protected NDList forwardInternal(ParameterStore parameterStore, NDList inputs, boolean training, ai.djl.util.PairList<java.lang.String,java.lang.Object> params)
forwardInternal
in class AbstractBlock
protected void beforeInitialize(Shape[] inputs)
beforeInitialize
in class AbstractBlock
inputs
- the expected shapes of the inputpublic Shape[] getOutputShapes(NDManager manager, Shape[] inputs)
manager
- an NDManagerinputs
- the shapes of the inputspublic void loadMetadata(byte version, java.io.DataInputStream is) throws java.io.IOException, MalformedModelException
If you overwrite AbstractBlock.saveMetadata(DataOutputStream)
or need to provide
backward compatibility to older binary formats, you prabably need to overwrite this. This
default implementation checks if the version number fits, if not it throws an MalformedModelException
. After that it restores the input shapes.
loadMetadata
in class AbstractBlock
version
- the version used for loading this metadata.is
- the input stream we are loading fromjava.io.IOException
- loading failedMalformedModelException
- data can be loaded but has wrong format