Deeplearning4j
Community ForumND4J JavadocDL4J Javadoc
EN 1.0.0-M1.1
EN 1.0.0-M1.1
  • Deeplearning4j Suite Overview
  • Release Notes
    • 1.0.0-M1.1
    • 1.0.0-M1
    • 1.0.0-beta7
    • 1.0.0-beta6
    • 1.0.0-beta5
    • 1.0.0-beta4
    • 1.0.0-beta3
    • 1.0.0-beta2
    • 1.0.0-beta
    • 1.0.0-alpha
    • 0.9.1
    • 0.9.0
    • 0.8.0
    • 0.7.2
    • 0.7.1
    • 0.7.0
    • 0.6.0
    • 0.5.0
    • 0.4.0
  • Multi-Project
    • Tutorials
      • Beginners
      • Quickstart
    • How To Guides
      • Import in to your favorite IDE
      • Contribute
        • Eclipse Contributors
      • Developer Docs
        • Github Actions/Build Infra
        • Javacpp
        • Release
        • Testing
      • Build From Source
      • Benchmark
      • Beginners
    • Reference
      • Examples Tour
    • Explanation
      • The core workflow
      • Configuration
        • Backends
          • Performance Issues
          • CPU
          • Cudnn
        • Memory
          • Workspaces
      • Build Tools
      • Snapshots
      • Maven
  • Deeplearning4j
    • Tutorials
      • Quick Start
      • Language Processing
        • Doc2Vec
        • Sentence Iterator
        • Tokenization
        • Vocabulary Cache
    • How To Guides
      • Custom Layers
      • Keras Import
        • Functional Models
        • Sequential Models
        • Custom Layers
        • Keras Import API Overview
          • Advanced Activations
          • Convolutional Layers
          • Core Layers
          • Embedding Layers
          • Local Layers
          • Noise Layers
          • Normalization Layers
          • Pooling Layers
          • Recurrent Layers
          • Wrapper Layers
        • Supported Features Overview
          • Activations
          • Constraints
          • Initializers
          • Losses
          • Optimizers
          • Regularizers
      • Tuning and Training
        • Visualization
        • Troubleshooting Training
        • Early Stopping
        • Evaluation
        • Transfer Learning
    • Reference
      • Model Zoo
        • Zoo Models
      • Activations
      • Auto Encoders
      • Computation Graph
      • Convolutional Layers
      • DataSet Iterators
      • Layers
      • Model Listeners
      • Saving and Loading Models
      • Multi Layer Network
      • Recurrent Layers
      • Updaters/Optimizers
      • Vertices
      • Word2vec/Glove/Doc2Vec
    • Explanation
  • datavec
    • Tutorials
      • Overview
    • How To Guides
    • Reference
      • Analysis
      • Conditions
      • Executors
      • Filters
      • Normalization
      • Operations
      • Transforms
      • Readers
      • Records
      • Reductions
      • Schemas
      • Serialization
      • Visualization
    • Explanation
  • Nd4j
    • Tutorials
      • Quickstart
    • How To Guides
      • Other Framework Interop
        • Tensorflow
        • TVM
        • Onnx
      • Matrix Manipulation
      • Element wise Operations
      • Basics
    • Reference
      • Op Descriptor Format
      • Tensor
      • Syntax
    • Explanation
  • Samediff
    • Tutorials
      • Quickstart
    • How To Guides
      • Importing Tensorflow
      • Adding Operations
        • codegen
    • Reference
      • Operation Namespaces
        • Base Operations
        • Bitwise
        • CNN
        • Image
        • LinAlg
        • Loss
        • Math
        • NN
        • Random
        • RNN
      • Variables
    • Explanation
      • Model Import Framework
  • Libnd4j
    • How To Guides
      • Building on Windows
      • Building for raspberry pi or Jetson Nano
      • Building on ios
      • How to Add Operations
      • How to Setup CLion
    • Reference
      • Understanding graph execution
      • Overview of working with libnd4j
      • Helpers Overview (CUDNN, OneDNN,Armcompute)
    • Explanation
  • Python4j
    • Tutorials
      • Quickstart
    • How To Guides
      • Write Python Script
    • Reference
      • Python Types
      • Python Path
      • Garbage Collection
      • Python Script Execution
    • Explanation
  • RL4j
    • Tutorials
    • How To Guides
    • Reference
    • Explanation
  • Spark
    • Tutorials
      • DL4J on Spark Quickstart
    • How To Guides
      • How To
      • Data How To
    • Reference
      • Parameter Server
      • Technical Reference
    • Explanation
      • Spark API Reference
  • codegen
Powered by GitBook
On this page
  • Available layers
  • Convolution1D
  • Convolution2D
  • Convolution3D
  • Deconvolution2D
  • Cropping1D
  • Cropping2D

Was this helpful?

Edit on Git
Export as PDF
  1. Deeplearning4j
  2. Reference

Convolutional Layers

Also known as CNN.

PreviousComputation GraphNextDataSet Iterators

Was this helpful?

Available layers

Convolution1D

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

Convolution2D

2D convolution layer

Convolution3D

3D convolution layer configuration

hasBias

public boolean hasBias()

An optional dataFormat: “NDHWC” or “NCDHW”. Defaults to “NCDHW”. The data format of the input and output data. For “NCDHW” (also known as ‘channels first’ format), the data storage order is: [batchSize, inputChannels, inputDepth, inputHeight, inputWidth]. For “NDHWC” (‘channels last’ format), the data is stored in the order of: [batchSize, inputDepth, inputHeight, inputWidth, inputChannels].

kernelSize

public Builder kernelSize(int... kernelSize)

The data format for input and output activations. NCDHW: activations (in/out) should have shape [minibatch, channels, depth, height, width] NDHWC: activations (in/out) should have shape [minibatch, depth, height, width, channels]

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

dataFormat

public Builder dataFormat(DataFormat dataFormat)

The data format for input and output activations. NCDHW: activations (in/out) should have shape [minibatch, channels, depth, height, width] NDHWC: activations (in/out) should have shape [minibatch, depth, height, width, channels]

  • param dataFormat Data format to use for activations

setKernelSize

public void setKernelSize(int... kernelSize)

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

  • param kernelSize kernel size

setStride

public void setStride(int... stride)

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

  • param stride kernel size

setPadding

public void setPadding(int... padding)

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

  • param padding kernel size

setDilation

public void setDilation(int... dilation)

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

  • param dilation kernel size

Deconvolution2D

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.

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

Cropping1D

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

setCropping

public void setCropping(int... cropping)

Cropping amount for top/bottom (in that order). Must be length 1 or 2 array.

build

public Cropping1D build()
  • param cropping Cropping amount for top/bottom (in that order). Must be length 1 or 2 array.

Cropping2D

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

setCropping

public void setCropping(int... cropping)

Cropping amount for top/bottom/left/right (in that order). A length 4 array.

build

public Cropping2D build()
  • param cropping Cropping amount for top/bottom/left/right (in that order). Must be length 4 array.

Cropping3D

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

setCropping

public void setCropping(int... cropping)

Cropping amount, a length 6 array, i.e. crop left depth, crop right depth, crop left height, crop right height, crop left width, crop right width

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

See the paper by Matt Zeiler for details:

For an intuitive guide to convolution arithmetic and shapes, see:

[source]
[source]
[source]
[source]
http://www.matthewzeiler.com/wp-content/uploads/2017/07/cvpr2010.pdf
https://arxiv.org/abs/1603.07285v1
[source]
[source]
[source]