public class Conv2D extends Convolution
Conv2D layer works on two dimensions of input,
LayoutType.WIDTH and LayoutType.HEIGHT as usually a Conv2D layer is used
to process data with two spatial dimensions, namely image. The concept itself works just as how
Convolution does, and each filter slides through an input data by two directions, first
traversing the LayoutType.WIDTH then traverses each row of the data.
First proposed by LeCun et al.'s paper, 2-dimensional convolution
layer gained its rising interest with the publication of
paper about AlexNet for image classification task. It is still commonly used in image-related
tasks and adapted in other tasks, including but not limited to 1-dimensional data which may be
transformed to 2-dimensional data, though Conv1D is now available for use.
The input to a Conv2D is an NDList with a single 4-D NDArray. The layout of the NDArray must be "NCHW". The
shapes are
data: (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], stride[0], dilate[0]) out_width = f(width, kernel[1], pad[1], stride[1], dilate[1]) where f(x, k, p, s, d) = floor((x + 2 * p - d * (k - 1) - 1)/s) + 1
Both weight and bias are learn-able parameters.
| Modifier and Type | Class and Description |
|---|---|
static class |
Conv2D.Builder
|
Convolution.ConvolutionBuilder<T extends Convolution.ConvolutionBuilder>bias, dilate, includeBias, kernel, numFilters, numGroups, pad, stride, weightchildren, inputNames, inputShapes, parameters, parameterShapeCallbacks, version| Modifier and Type | Method and Description |
|---|---|
static Conv2D.Builder |
builder()
Creates a builder to build a
Conv2D. |
protected LayoutType[] |
getExpectedLayout()
Returns the expected layout of the input.
|
protected java.lang.String |
getStringLayout()
Returns the string representing the layout of the input.
|
protected int |
numDimensions()
Returns the number of dimensions of the input.
|
beforeInitialize, forward, getOutputShapes, loadMetadataaddChildBlock, addParameter, addParameter, addParameter, cast, clear, describeInput, getChildren, getDirectParameters, getParameters, getParameterShape, initialize, initializeChildBlocks, isInitialized, loadParameters, readInputShapes, saveInputShapes, saveMetadata, saveParameters, setInitializer, setInitializer, toStringclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitforward, forward, validateLayoutprotected LayoutType[] getExpectedLayout()
getExpectedLayout in class Convolutionprotected java.lang.String getStringLayout()
getStringLayout in class Convolutionprotected int numDimensions()
numDimensions in class Convolutionpublic static Conv2D.Builder builder()
Conv2D.