Package ai.djl.nn.convolutional
Class Conv2dTranspose
- java.lang.Object
-
- ai.djl.nn.AbstractBaseBlock
-
- ai.djl.nn.AbstractBlock
-
- ai.djl.nn.convolutional.Deconvolution
-
- ai.djl.nn.convolutional.Conv2dTranspose
-
- All Implemented Interfaces:
Block
public class Conv2dTranspose extends Deconvolution
The input to aConv2dTransposeis anNDListwith a single 4-DNDArray. The layout of theNDArraymust be "NCHW". The shapes aredata: (batch_size, channel, height, width)weight: (num_filter, channel, kernel[0], kernel[1])bias: (num_filter,)out: (batch_size, num_filter, out_height, out_width)
out_height = f(height, kernel[0], pad[0], oPad[0], stride[0], dilate[0])
out_width = f(width, kernel[1], pad[1], oPad[1], stride[1], dilate[1])
where f(x, k, p, oP, s, d) = (x-1)*s-2*p+k+oP
Both
weightandbiasare learn-able parameters.- See Also:
Deconvolution
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classConv2dTranspose.BuilderThe Builder to construct aConv2dTransposetype ofBlock.-
Nested classes/interfaces inherited from class ai.djl.nn.convolutional.Deconvolution
Deconvolution.DeconvolutionBuilder<T extends Deconvolution.DeconvolutionBuilder>
-
-
Field Summary
-
Fields inherited from class ai.djl.nn.convolutional.Deconvolution
bias, dilation, filters, groups, includeBias, kernelShape, outPadding, padding, stride, weight
-
Fields inherited from class ai.djl.nn.AbstractBlock
children, parameters
-
Fields inherited from class ai.djl.nn.AbstractBaseBlock
inputNames, inputShapes, outputDataTypes, version
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static Conv2dTranspose.Builderbuilder()Creates a builder to build aConv2dTranspose.static NDListconv2dTranspose(NDArray input, NDArray weight)Applies 2D deconvolution over an input signal composed of several input planes.static NDListconv2dTranspose(NDArray input, NDArray weight, NDArray bias)Applies 2D deconvolution over an input signal composed of several input planes.static NDListconv2dTranspose(NDArray input, NDArray weight, NDArray bias, Shape stride)Applies 2D deconvolution over an input signal composed of several input planes.static NDListconv2dTranspose(NDArray input, NDArray weight, NDArray bias, Shape stride, Shape padding)Applies 2D deconvolution over an input signal composed of several input planes.static NDListconv2dTranspose(NDArray input, NDArray weight, NDArray bias, Shape stride, Shape padding, Shape outPadding)Applies 2D deconvolution over an input signal composed of several input planes.static NDListconv2dTranspose(NDArray input, NDArray weight, NDArray bias, Shape stride, Shape padding, Shape outPadding, Shape dilation)Applies 2D deconvolution over an input signal composed of several input planes.static NDListconv2dTranspose(NDArray input, NDArray weight, NDArray bias, Shape stride, Shape padding, Shape outPadding, Shape dilation, int groups)Applies 2D deconvolution over an input signal composed of several input planes.protected LayoutType[]getExpectedLayout()Returns the expected layout of the input.protected java.lang.StringgetStringLayout()Returns the string representing the layout of the input.protected intnumDimensions()Returns the number of dimensions of the input.-
Methods inherited from class ai.djl.nn.convolutional.Deconvolution
beforeInitialize, forwardInternal, getOutputShapes, loadMetadata, prepare
-
Methods inherited from class ai.djl.nn.AbstractBlock
addChildBlock, addChildBlock, addChildBlockSingleton, addParameter, getChildren, getDirectParameters
-
Methods 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, toString
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface ai.djl.nn.Block
forward, freezeParameters, freezeParameters, getOutputShapes
-
-
-
-
Method Detail
-
getExpectedLayout
protected LayoutType[] getExpectedLayout()
Returns the expected layout of the input.- Specified by:
getExpectedLayoutin classDeconvolution- Returns:
- the expected layout of the input
-
getStringLayout
protected java.lang.String getStringLayout()
Returns the string representing the layout of the input.- Specified by:
getStringLayoutin classDeconvolution- Returns:
- the string representing the layout of the input
-
numDimensions
protected int numDimensions()
Returns the number of dimensions of the input.- Specified by:
numDimensionsin classDeconvolution- Returns:
- the number of dimensions of the input
-
conv2dTranspose
public static NDList conv2dTranspose(NDArray input, NDArray weight)
Applies 2D deconvolution over an input signal composed of several input planes.- Parameters:
input- the inputNDArrayof shape (batchSize, inputChannel, height, width)weight- filtersNDArrayof shape (outChannel, inputChannel/groups, height, width)- Returns:
- the output of the conv2dTranspose operation
-
conv2dTranspose
public static NDList conv2dTranspose(NDArray input, NDArray weight, NDArray bias)
Applies 2D deconvolution over an input signal composed of several input planes.- Parameters:
input- the inputNDArrayof shape (batchSize, inputChannel, height, width)weight- filtersNDArrayof shape (outChannel, inputChannel/groups, height, width)bias- biasNDArrayof shape (outChannel)- Returns:
- the output of the conv2dTranspose operation
-
conv2dTranspose
public static NDList conv2dTranspose(NDArray input, NDArray weight, NDArray bias, Shape stride)
Applies 2D deconvolution over an input signal composed of several input planes.- Parameters:
input- the inputNDArrayof shape (batchSize, inputChannel, height, width)weight- filtersNDArrayof shape (outChannel, inputChannel/groups, height, width)bias- biasNDArrayof shape (outChannel)stride- the stride of the deconvolving kernel: Shape(height, width)- Returns:
- the output of the conv2dTranspose operation
-
conv2dTranspose
public static NDList conv2dTranspose(NDArray input, NDArray weight, NDArray bias, Shape stride, Shape padding)
Applies 2D deconvolution over an input signal composed of several input planes.- Parameters:
input- the inputNDArrayof shape (batchSize, inputChannel, height, width)weight- filtersNDArrayof shape (outChannel, inputChannel/groups, height, width)bias- biasNDArrayof shape (outChannel)stride- the stride of the deconvolving kernel: Shape(height, width)padding- implicit paddings on both sides of the input: Shape(height, width)- Returns:
- the output of the conv2dTranspose operation
-
conv2dTranspose
public static NDList conv2dTranspose(NDArray input, NDArray weight, NDArray bias, Shape stride, Shape padding, Shape outPadding)
Applies 2D deconvolution over an input signal composed of several input planes.- Parameters:
input- the inputNDArrayof shape (batchSize, inputChannel, height, width)weight- filtersNDArrayof shape (outChannel, inputChannel/groups, height, width)bias- biasNDArrayof shape (outChannel)stride- the stride of the deconvolving kernel: Shape(height, width)padding- implicit paddings on both sides of the input: Shape(height, width)outPadding- Controls the amount of implicit zero-paddings on both sides of the output for outputPadding number of points for each dimension.- Returns:
- the output of the conv2dTranspose operation
-
conv2dTranspose
public static NDList conv2dTranspose(NDArray input, NDArray weight, NDArray bias, Shape stride, Shape padding, Shape outPadding, Shape dilation)
Applies 2D deconvolution over an input signal composed of several input planes.- Parameters:
input- the inputNDArrayof shape (batchSize, inputChannel, height, width)weight- filtersNDArrayof shape (outChannel, inputChannel/groups, height, width)bias- biasNDArrayof shape (outChannel)stride- the stride of the deconvolving kernel: Shape(height, width)padding- implicit paddings on both sides of the input: Shape(height, width)outPadding- Controls the amount of implicit zero-paddings on both sides of the output for outputPadding number of points for each dimension.dilation- the spacing between kernel elements: Shape(height, width)- Returns:
- the output of the conv2dTranspose operation
-
conv2dTranspose
public static NDList conv2dTranspose(NDArray input, NDArray weight, NDArray bias, Shape stride, Shape padding, Shape outPadding, Shape dilation, int groups)
Applies 2D deconvolution over an input signal composed of several input planes.- Parameters:
input- the inputNDArrayof shape (batchSize, inputChannel, height, width)weight- filtersNDArrayof shape (outChannel, inputChannel/groups, height, width)bias- biasNDArrayof shape (outChannel)stride- the stride of the deconvolving kernel: Shape(height, width)padding- implicit paddings on both sides of the input: Shape(height, width)outPadding- Controls the amount of implicit zero-paddings on both sides of the output for outputPadding number of points for each dimension. Shape(height, width)dilation- the spacing between kernel elements: Shape(height, width)groups- split input into groups: input channel(input.size(1)) should be divisible by the number of groups- Returns:
- the output of the conv2dTranspose operation
-
builder
public static Conv2dTranspose.Builder builder()
Creates a builder to build aConv2dTranspose.- Returns:
- a new builder
-
-