Class Conv3d
- java.lang.Object
-
- ai.djl.nn.AbstractBaseBlock
-
- ai.djl.nn.AbstractBlock
-
- ai.djl.nn.convolutional.Convolution
-
- ai.djl.nn.convolutional.Conv3d
-
- All Implemented Interfaces:
Block
public class Conv3d extends Convolution
Conv3dlayer behaves just asConvolutiondoes, with the distinction being it operates of 3-dimensional data such as medical images or video data. The traversal of each filter begins fromLayoutType.WIDTHthen toLayoutType.HEIGHT, and lastly across eachLayoutType.DEPTHin the specifieddepthsize of the data.The utilization of
Conv3dlayer allows deeper analysis of visual data such as those in medical images, or even analysis on temporal data such as video data as a whole instead of processing each frame with aConv2dlayer, despite this being a common practice in computer vision researches. The benefit of utilizing this kind of layer is the maintaining of serial data across 2-dimensional data, hence could be beneficial for research focus on such as object tracking. The drawback is that this kind of layer is more costly compared to other convolution layer types since dot product operation is performed on all three dimensions.The input to a
Conv3dis anNDListwith a single 5-DNDArray. The layout of theNDArraymust be "NCDHW". The shapes aredata: (batch_size, channel, depth, height, width)weight: (num_filter, channel, kernel[0], kernel[1], kernel[2])bias: (num_filter,)out: (batch_size, num_filter, out_depth, out_height, out_width)
out_depth = f(depth, kernel[0], pad[0], stride[0], dilate[0])
out_height = f(height, kernel[1], pad[1], stride[1], dilate[1])
out_width = f(width, kernel[2], pad[2], stride[2], dilate[2])
where f(x, k, p, s, d) = floor((x + 2 * p - d * (k - 1) - 1)/s) + 1
Both
weightandbiasare learn-able parameters.- See Also:
Convolution
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classConv3d.Builder-
Nested classes/interfaces inherited from class ai.djl.nn.convolutional.Convolution
Convolution.ConvolutionBuilder<T extends Convolution.ConvolutionBuilder>
-
-
Field Summary
-
Fields inherited from class ai.djl.nn.convolutional.Convolution
bias, dilation, filters, groups, includeBias, kernelShape, 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 Conv3d.Builderbuilder()Creates a builder to build aConv3d.static NDListconv3d(NDArray input, NDArray weight)Applies 3D convolution over an input signal composed of several input planes.static NDListconv3d(NDArray input, NDArray weight, NDArray bias)Applies 3D convolution over an input signal composed of several input planes.static NDListconv3d(NDArray input, NDArray weight, NDArray bias, Shape stride)Applies 3D convolution over an input signal composed of several input planes.static NDListconv3d(NDArray input, NDArray weight, NDArray bias, Shape stride, Shape padding)Applies 3D convolution over an input signal composed of several input planes.static NDListconv3d(NDArray input, NDArray weight, NDArray bias, Shape stride, Shape padding, Shape dilation)Applies 3D convolution over an input signal composed of several input planes.static NDListconv3d(NDArray input, NDArray weight, NDArray bias, Shape stride, Shape padding, Shape dilation, int groups)Applies 3D convolution 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.Convolution
beforeInitialize, forwardInternal, getDilation, getFilters, getGroups, getKernelShape, getOutputShapes, getPadding, getStride, isIncludeBias, 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 classConvolution- 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 classConvolution- Returns:
- the string representing the layout of the input
-
numDimensions
protected int numDimensions()
Returns the number of dimensions of the input.- Specified by:
numDimensionsin classConvolution- Returns:
- the number of dimensions of the input
-
conv3d
public static NDList conv3d(NDArray input, NDArray weight)
Applies 3D convolution over an input signal composed of several input planes.- Parameters:
input- the inputNDArrayof shape (batchSize, inputChannel, depth, height, width)weight- filtersNDArrayof shape (outChannel, inputChannel/groups, depth, height, width)- Returns:
- the output of the conv3d operation
-
conv3d
public static NDList conv3d(NDArray input, NDArray weight, NDArray bias)
Applies 3D convolution over an input signal composed of several input planes.- Parameters:
input- the inputNDArrayof shape (batchSize, inputChannel, depth, height, width)weight- filtersNDArrayof shape (outChannel, inputChannel/groups, depth, height, width)bias- biasNDArrayof shape (outChannel)- Returns:
- the output of the conv3d operation
-
conv3d
public static NDList conv3d(NDArray input, NDArray weight, NDArray bias, Shape stride)
Applies 3D convolution over an input signal composed of several input planes.- Parameters:
input- the inputNDArrayof shape (batchSize, inputChannel, depth, height, width)weight- filtersNDArrayof shape (outChannel, inputChannel/groups, depth, height, width)bias- biasNDArrayof shape (outChannel)stride- the stride of the convolving kernel: Shape(depth, height, width)- Returns:
- the output of the conv3d operation
-
conv3d
public static NDList conv3d(NDArray input, NDArray weight, NDArray bias, Shape stride, Shape padding)
Applies 3D convolution over an input signal composed of several input planes.- Parameters:
input- the inputNDArrayof shape (batchSize, inputChannel, depth, height, width)weight- filtersNDArrayof shape (outChannel, inputChannel/groups, depth, height, width)bias- biasNDArrayof shape (outChannel)stride- the stride of the convolving kernel: Shape(depth, height, width)padding- implicit paddings on both sides of the input: Shape(depth, height, width)- Returns:
- the output of the conv3d operation
-
conv3d
public static NDList conv3d(NDArray input, NDArray weight, NDArray bias, Shape stride, Shape padding, Shape dilation)
Applies 3D convolution over an input signal composed of several input planes.- Parameters:
input- the inputNDArrayof shape (batchSize, inputChannel, depth, height, width)weight- filtersNDArrayof shape (outChannel, inputChannel/groups, depth, height, width)bias- biasNDArrayof shape (outChannel)stride- the stride of the convolving kernel: Shape(depth, height, width)padding- implicit paddings on both sides of the input: Shape(depth, height, width)dilation- the spacing between kernel elements: Shape(depth, height, width)- Returns:
- the output of the conv3d operation
-
conv3d
public static NDList conv3d(NDArray input, NDArray weight, NDArray bias, Shape stride, Shape padding, Shape dilation, int groups)
Applies 3D convolution over an input signal composed of several input planes.- Parameters:
input- the inputNDArrayof shape (batchSize, inputChannel, depth, height, width)weight- filtersNDArrayof shape (outChannel, inputChannel/groups, depth, height, width)bias- biasNDArrayof shape (outChannel)stride- the stride of the convolving kernel: Shape(depth, height, width)padding- implicit paddings on both sides of the input: Shape(depth, height, width)dilation- the spacing between kernel elements: Shape(depth, 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 conv3d operation
-
builder
public static Conv3d.Builder builder()
Creates a builder to build aConv3d.- Returns:
- a new builder
-
-