Supported Convolutional Layers

What is a convolutional neural network?

Each layer in a neural network configuration represents a unit of hidden units. When layers are stacked together, they represent a deep neural network.

Available layers


Convolution1D

[source]

1D convolution layer. Expects input activations of shape [minibatch,channels,sequenceLength]


Convolution2D

[source]

2D convolution layer


Convolution3D

[source]

3D convolution layer configuration

hasBias
public boolean hasBias() 

An optional dataFormat from: “NDHWC”, “NCDHW”. Defaults to “NCDHW”. The data format of the input and output data. the format could be “NCDHW”, the data storage order is: [batchSize, inputChannels, inputDepth, inputHeight, inputWidth]. Alternatively, the format “NDHWC”, the data is stored in the order of: [batchSize, inputDepth, inputHeight, inputWidth, inputChannels].

kernelSize
public Builder kernelSize(int... kernelSize) 

Set kernel size for 3D convolutions in (depth, height, width) order

  • param kernelSize kernel size
  • return 3D convolution layer builder
stride
public Builder stride(int... stride) 

Set stride size for 3D convolutions in (depth, height, width) order

  • param stride kernel size
  • return 3D convolution layer builder
padding
public Builder padding(int... padding) 

Set padding size for 3D convolutions in (depth, height, width) order

  • param padding kernel size
  • return 3D convolution layer builder
dilation
public Builder dilation(int... dilation) 

Set dilation size for 3D convolutions in (depth, height, width) order

  • param dilation kernel size
  • return 3D convolution layer builder

Deconvolution2D

[source]

2D deconvolution layer configuration

Deconvolutions are also known as transpose convolutions or fractionally strided convolutions. In essence, deconvolutions swap forward and backward pass with regular 2D convolutions.

See the paper by Matt Zeiler for details: http://www.matthewzeiler.com/wp-content/uploads/2017/07/cvpr2010.pdf

For an intuitive guide to convolution arithmetic and shapes, see: https://arxiv.org/abs/1603.07285v1

hasBias
public boolean hasBias()

Deconvolution2D layer nIn in the input layer is the number of channels nOut is the number of filters to be used in the net or in other words the channels The builder specifies the filter/kernel size, the stride and padding The pooling layer takes the kernel size

convolutionMode
public Builder convolutionMode(ConvolutionMode convolutionMode) 

Set the convolution mode for the Convolution layer. See {- link ConvolutionMode} for more details

  • param convolutionMode Convolution mode for layer
kernelSize
public Builder kernelSize(int... kernelSize) 

Size of the convolution rows/columns

  • param kernelSize the height and width of the kernel
  • return

DepthwiseConvolution2D

[source]

2D depth-wise convolution layer configuration.

Performs a channels-wise convolution, which operates on each of the input maps separately. A channel multiplier is used to specify the number of outputs per input map. This convolution is carried out with the specified kernel sizes, stride and padding values.

depthMultiplier
public Builder depthMultiplier(int depthMultiplier) 

Set channels multiplier for depth-wise convolution

  • param depthMultiplier integer value, for each input map we get depthMultiplier outputs in channels-wise step.
  • return Builder
kernelSize
public Builder kernelSize(int... kernelSize) 

Size of the convolution rows/columns

  • param kernelSize the height and width of the kernel
stride
public Builder stride(int... stride) 

Stride of the convolution in rows/columns (height/width) dimensions

  • param stride Stride of the layer
padding
public Builder padding(int... padding) 

Padding of the convolution in rows/columns (height/width) dimensions

  • param padding Padding of the layer

SeparableConvolution2D

[source]

2D Separable convolution layer configuration.

Separable convolutions split a regular convolution operation into two simpler operations, which are usually computationally more efficient.

The first step in a separable convolution is a channels-wise convolution, which operates on each of the input maps separately. A channels multiplier is used to specify the number of outputs per input map in this step. This convolution is carried out with the specified kernel sizes, stride and padding values.

The second step is a point-wise operation, in which the intermediary outputs of the channels-wise convolution are mapped to the desired number of feature maps, by using a 1x1 convolution.

The result of chaining these two operations will result in a tensor of the same shape as that for a standard conv2d operation.

hasBias
public boolean hasBias()

SeparableConvolution2D layer nIn in the input layer is the number of channels nOut is the number of filters to be used in the net or in other words the channels The builder specifies the filter/kernel size, the stride and padding The pooling layer takes the kernel size

constrainPointWise
public Builder constrainPointWise(LayerConstraint... constraints) 

Set channels multiplier of channels-wise step in separable convolution

  • param depthMultiplier integer value, for each input map we get depthMultipler outputs in channels-wise step.
  • return Builder
kernelSize
public Builder kernelSize(int... kernelSize) 

Size of the convolution rows/columns (height/width)

  • param kernelSize the height and width of the kernel
stride
public Builder stride(int... stride) 

Stride of the convolution rows/columns (height/width)

  • param stride the stride of the kernel (in h/w dimensions)
padding
public Builder padding(int... padding) 

Padding - rows/columns (height/width)

  • param padding the padding in h/w dimensions

Cropping1D

[source]

Cropping layer for convolutional (1d) neural networks. Allows cropping to be done separately for top/bottom

getOutputType
public InputType getOutputType(int layerIndex, InputType inputType) 
  • param cropTopBottom Amount of cropping to apply to both the top and the bottom of the input activations
build
public Cropping1D build() 
  • param cropping Cropping amount for top/bottom (in that order). Must be length 1 or 2 array.

Cropping2D

[source]

Cropping layer for convolutional (2d) neural networks. Allows cropping to be done separately for top/bottom/left/right

getOutputType
public InputType getOutputType(int layerIndex, InputType inputType) 
  • param cropTopBottom Amount of cropping to apply to both the top and the bottom of the input activations
  • param cropLeftRight Amount of cropping to apply to both the left and the right of the input activations
build
public Cropping2D build() 
  • param cropping Cropping amount for top/bottom/left/right (in that order). Must be length 4 array.

Cropping3D

[source]

Cropping layer for convolutional (3d) neural networks. Allows cropping to be done separately for upper and lower bounds of depth, height and width dimensions.

getOutputType
public InputType getOutputType(int layerIndex, InputType inputType) 
  • param cropDepth Amount of cropping to apply to both depth boundaries of the input activations
  • param cropHeight Amount of cropping to apply to both height boundaries of the input activations
  • param cropWidth Amount of cropping to apply to both width boundaries of the input activations
build
public Cropping3D build() 
  • param cropping Cropping amount, must be length 3 or 6 array, i.e. either crop depth, crop height, crop width or crop left depth, crop right depth, crop left height, crop right height, crop left width, crop right width

API Reference

API Reference

Detailed API docs for all libraries including DL4J, ND4J, DataVec, and Arbiter.

Examples

Examples

Explore sample projects and demos for DL4J, ND4J, and DataVec in multiple languages including Java and Kotlin.

Tutorials

Tutorials

Step-by-step tutorials for learning concepts in deep learning while using the DL4J API.

Guide

Guide

In-depth documentation on different scenarios including import, distributed training, early stopping, and GPU setup.

Deploying models? There's a tool for that.