Package org.nd4j.linalg.factory.ops
Class NDCNN
- java.lang.Object
-
- org.nd4j.linalg.factory.ops.NDCNN
-
public class NDCNN extends Object
-
-
Constructor Summary
Constructors Constructor Description NDCNN()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description INDArrayavgPooling2d(INDArray input, Pooling2DConfig Pooling2DConfig)2D Convolution layer operation - average pooling 2dINDArrayavgPooling3d(INDArray input, Pooling3DConfig Pooling3DConfig)3D convolution layer operation - average pooling 3dINDArraybatchToSpace(INDArray x, int[] blocks, int[] croppingTop, int... croppingBottom)Convolution 2d layer batch to space operation on 4d input.
Reduces input batch dimension by rearranging data into a larger spatial dimensionsINDArraycol2Im(INDArray in, Conv2DConfig Conv2DConfig)col2im operation for use in 2D convolution operations.INDArrayconv1d(INDArray input, INDArray weights, INDArray bias, Conv1DConfig Conv1DConfig)Conv1d operation.INDArrayconv1d(INDArray input, INDArray weights, Conv1DConfig Conv1DConfig)Conv1d operation.INDArrayconv2d(INDArray layerInput, INDArray weights, INDArray bias, Conv2DConfig Conv2DConfig)2D Convolution operation with optional biasINDArrayconv2d(INDArray layerInput, INDArray weights, Conv2DConfig Conv2DConfig)2D Convolution operation with optional biasINDArrayconv3d(INDArray input, INDArray weights, INDArray bias, Conv3DConfig Conv3DConfig)Convolution 3D operation with optional biasINDArrayconv3d(INDArray input, INDArray weights, Conv3DConfig Conv3DConfig)Convolution 3D operation with optional biasINDArraydeconv2d(INDArray layerInput, INDArray weights, INDArray bias, DeConv2DConfig DeConv2DConfig)2D deconvolution operation with optional biasINDArraydeconv2d(INDArray layerInput, INDArray weights, DeConv2DConfig DeConv2DConfig)2D deconvolution operation with optional biasINDArraydeconv3d(INDArray input, INDArray weights, INDArray bias, DeConv3DConfig DeConv3DConfig)3D CNN deconvolution operation with or without optional biasINDArraydeconv3d(INDArray input, INDArray weights, DeConv3DConfig DeConv3DConfig)3D CNN deconvolution operation with or without optional biasINDArraydepthToSpace(INDArray x, int blockSize, DataFormat dataFormat)Convolution 2d layer batch to space operation on 4d input.
Reduces input channels dimension by rearranging data into a larger spatial dimensions
Example: if input has shape [mb, 8, 2, 2] and block size is 2, then output size is [mb, 8/(2*2), 2*2, 2*2]
= [mb, 2, 4, 4]INDArraydepthWiseConv2d(INDArray layerInput, INDArray depthWeights, INDArray bias, Conv2DConfig Conv2DConfig)Depth-wise 2D convolution operation with optional biasINDArraydepthWiseConv2d(INDArray layerInput, INDArray depthWeights, Conv2DConfig Conv2DConfig)Depth-wise 2D convolution operation with optional biasINDArraydilation2D(INDArray df, INDArray weights, int[] strides, int[] rates, boolean isSameMode)TODO doc stringINDArrayextractImagePatches(INDArray input, int kH, int kW, int sH, int sW, int rH, int rW, boolean sameMode)Extract image patchesINDArrayim2Col(INDArray in, Conv2DConfig Conv2DConfig)im2col operation for use in 2D convolution operations.INDArraylocalResponseNormalization(INDArray input, LocalResponseNormalizationConfig LocalResponseNormalizationConfig)2D convolution layer operation - local response normalizationINDArraymaxPooling2d(INDArray input, Pooling2DConfig Pooling2DConfig)2D Convolution layer operation - max pooling 2dINDArraymaxPooling3d(INDArray input, Pooling3DConfig Pooling3DConfig)3D convolution layer operation - max pooling 3d operation.INDArray[]maxPoolWithArgmax(INDArray input, Pooling2DConfig Pooling2DConfig)2D Convolution layer operation - Max pooling on the input and outputs both max values and indicesINDArrayseparableConv2d(INDArray layerInput, INDArray depthWeights, INDArray pointWeights, INDArray bias, Conv2DConfig Conv2DConfig)Separable 2D convolution operation with optional biasINDArrayseparableConv2d(INDArray layerInput, INDArray depthWeights, INDArray pointWeights, Conv2DConfig Conv2DConfig)Separable 2D convolution operation with optional biasINDArrayspaceToBatch(INDArray x, int[] blocks, int[] paddingTop, int... paddingBottom)Convolution 2d layer space to batch operation on 4d input.
Increases input batch dimension by rearranging data from spatial dimensions into batch dimensionINDArrayspaceToDepth(INDArray x, int blockSize, DataFormat dataFormat)Convolution 2d layer space to depth operation on 4d input.
Increases input channels (reduced spatial dimensions) by rearranging data into a larger channels dimension
Example: if input has shape [mb, 2, 4, 4] and block size is 2, then output size is [mb, 8/(2*2), 2*2, 2*2]
= [mb, 2, 4, 4]INDArrayupsampling2d(INDArray input, int scale)Upsampling layer for 2D inputs.
scale is used for both height and width dimensions.INDArrayupsampling2d(INDArray input, int scaleH, int scaleW, boolean nchw)2D Convolution layer operation - Upsampling 2dINDArrayupsampling3d(INDArray input, boolean ncdhw, int scaleD, int scaleH, int scaleW)3D Convolution layer operation - Upsampling 3d
-
-
-
Method Detail
-
avgPooling2d
public INDArray avgPooling2d(INDArray input, Pooling2DConfig Pooling2DConfig)
2D Convolution layer operation - average pooling 2d- Parameters:
input- the input to average pooling 2d operation - 4d CNN (image) activations in NCHW format (shape [minibatch, channels, height, width]) or NHWC format (shape [minibatch, height, width, channels]) (NUMERIC type)Pooling2DConfig- Configuration Object- Returns:
- output Result after applying average pooling on the input (NUMERIC type)
-
avgPooling3d
public INDArray avgPooling3d(INDArray input, Pooling3DConfig Pooling3DConfig)
3D convolution layer operation - average pooling 3d- Parameters:
input- the input to average pooling 3d operation - 5d activations in NCDHW format (shape [minibatch, channels, depth, height, width]) or NDHWC format (shape [minibatch, depth, height, width, channels]) (NUMERIC type)Pooling3DConfig- Configuration Object- Returns:
- output after applying average pooling on the input (NUMERIC type)
-
batchToSpace
public INDArray batchToSpace(INDArray x, int[] blocks, int[] croppingTop, int... croppingBottom)
Convolution 2d layer batch to space operation on 4d input.
Reduces input batch dimension by rearranging data into a larger spatial dimensions- Parameters:
x- Input variable. 4d input (NUMERIC type)blocks- Block size, in the height/width dimension (Size: Exactly(count=2))croppingTop- (Size: Exactly(count=2))croppingBottom- (Size: Exactly(count=2))- Returns:
- output Output variable (NUMERIC type)
-
col2Im
public INDArray col2Im(INDArray in, Conv2DConfig Conv2DConfig)
col2im operation for use in 2D convolution operations. Outputs a 4d array with shape
[minibatch, inputChannels, height, width]- Parameters:
in- Input - rank 6 input with shape [minibatch, inputChannels, kernelHeight, kernelWidth, outputHeight, outputWidth] (NUMERIC type)Conv2DConfig- Configuration Object- Returns:
- output Col2Im output variable (NUMERIC type)
-
conv1d
public INDArray conv1d(INDArray input, INDArray weights, INDArray bias, Conv1DConfig Conv1DConfig)
Conv1d operation.- Parameters:
input- the inputs to conv1d (NUMERIC type)weights- weights for conv1d op - rank 3 array with shape [kernelSize, inputChannels, outputChannels] (NUMERIC type)bias- bias for conv1d op - rank 1 array with shape [outputChannels]. May be null. (NUMERIC type)Conv1DConfig- Configuration Object- Returns:
- output result of conv1d op (NUMERIC type)
-
conv1d
public INDArray conv1d(INDArray input, INDArray weights, Conv1DConfig Conv1DConfig)
Conv1d operation.- Parameters:
input- the inputs to conv1d (NUMERIC type)weights- weights for conv1d op - rank 3 array with shape [kernelSize, inputChannels, outputChannels] (NUMERIC type)Conv1DConfig- Configuration Object- Returns:
- output result of conv1d op (NUMERIC type)
-
conv2d
public INDArray conv2d(INDArray layerInput, INDArray weights, INDArray bias, Conv2DConfig Conv2DConfig)
2D Convolution operation with optional bias- Parameters:
layerInput- the input to max pooling 2d operation - 4d CNN (image) activations in NCHW format (NUMERIC type)weights- Weights for the convolution operation. 4 dimensions with format [kernelHeight, kernelWidth, inputChannels, outputChannels] (NUMERIC type)bias- Optional 1D bias array with shape [outputChannels]. May be null. (NUMERIC type)Conv2DConfig- Configuration Object- Returns:
- output result of conv2d op (NUMERIC type)
-
conv2d
public INDArray conv2d(INDArray layerInput, INDArray weights, Conv2DConfig Conv2DConfig)
2D Convolution operation with optional bias- Parameters:
layerInput- the input to max pooling 2d operation - 4d CNN (image) activations in NCHW format (NUMERIC type)weights- Weights for the convolution operation. 4 dimensions with format [kernelHeight, kernelWidth, inputChannels, outputChannels] (NUMERIC type)Conv2DConfig- Configuration Object- Returns:
- output result of conv2d op (NUMERIC type)
-
conv3d
public INDArray conv3d(INDArray input, INDArray weights, INDArray bias, Conv3DConfig Conv3DConfig)
Convolution 3D operation with optional bias- Parameters:
input- the input to average pooling 3d operation - 5d activations in NCDHW format (shape [minibatch, channels, depth, height, width]) or NDHWC format (shape [minibatch, depth, height, width, channels]) (NUMERIC type)weights- Weights for conv3d. Rank 5 with shape [kernelDepth, kernelHeight, kernelWidth, inputChannels, outputChannels]. (NUMERIC type)bias- Optional 1D bias array with shape [outputChannels]. May be null. (NUMERIC type)Conv3DConfig- Configuration Object- Returns:
- output Conv3d output variable (NUMERIC type)
-
conv3d
public INDArray conv3d(INDArray input, INDArray weights, Conv3DConfig Conv3DConfig)
Convolution 3D operation with optional bias- Parameters:
input- the input to average pooling 3d operation - 5d activations in NCDHW format (shape [minibatch, channels, depth, height, width]) or NDHWC format (shape [minibatch, depth, height, width, channels]) (NUMERIC type)weights- Weights for conv3d. Rank 5 with shape [kernelDepth, kernelHeight, kernelWidth, inputChannels, outputChannels]. (NUMERIC type)Conv3DConfig- Configuration Object- Returns:
- output Conv3d output variable (NUMERIC type)
-
deconv2d
public INDArray deconv2d(INDArray layerInput, INDArray weights, INDArray bias, DeConv2DConfig DeConv2DConfig)
2D deconvolution operation with optional bias- Parameters:
layerInput- the input to deconvolution 2d operation - 4d CNN (image) activations in NCHW format (shape [minibatch, channels, height, width]) or NHWC format (shape [minibatch, height, width, channels]) (NUMERIC type)weights- Weights for the 2d deconvolution operation. 4 dimensions with format [inputChannels, outputChannels, kernelHeight, kernelWidth] (NUMERIC type)bias- Optional 1D bias array with shape [outputChannels]. May be null. (NUMERIC type)DeConv2DConfig- Configuration Object- Returns:
- output result of deconv2d op (NUMERIC type)
-
deconv2d
public INDArray deconv2d(INDArray layerInput, INDArray weights, DeConv2DConfig DeConv2DConfig)
2D deconvolution operation with optional bias- Parameters:
layerInput- the input to deconvolution 2d operation - 4d CNN (image) activations in NCHW format (shape [minibatch, channels, height, width]) or NHWC format (shape [minibatch, height, width, channels]) (NUMERIC type)weights- Weights for the 2d deconvolution operation. 4 dimensions with format [inputChannels, outputChannels, kernelHeight, kernelWidth] (NUMERIC type)DeConv2DConfig- Configuration Object- Returns:
- output result of deconv2d op (NUMERIC type)
-
deconv3d
public INDArray deconv3d(INDArray input, INDArray weights, INDArray bias, DeConv3DConfig DeConv3DConfig)
3D CNN deconvolution operation with or without optional bias- Parameters:
input- Input array - shape [bS, iD, iH, iW, iC] (NDHWC) or [bS, iC, iD, iH, iW] (NCDHW) (NUMERIC type)weights- Weights array - shape [kD, kH, kW, oC, iC] (NUMERIC type)bias- Bias array - optional, may be null. If non-null, must have shape [outputChannels] (NUMERIC type)DeConv3DConfig- Configuration Object- Returns:
- output result of 3D CNN deconvolution operation (NUMERIC type)
-
deconv3d
public INDArray deconv3d(INDArray input, INDArray weights, DeConv3DConfig DeConv3DConfig)
3D CNN deconvolution operation with or without optional bias- Parameters:
input- Input array - shape [bS, iD, iH, iW, iC] (NDHWC) or [bS, iC, iD, iH, iW] (NCDHW) (NUMERIC type)weights- Weights array - shape [kD, kH, kW, oC, iC] (NUMERIC type)DeConv3DConfig- Configuration Object- Returns:
- output result of 3D CNN deconvolution operation (NUMERIC type)
-
depthToSpace
public INDArray depthToSpace(INDArray x, int blockSize, DataFormat dataFormat)
Convolution 2d layer batch to space operation on 4d input.
Reduces input channels dimension by rearranging data into a larger spatial dimensions
Example: if input has shape [mb, 8, 2, 2] and block size is 2, then output size is [mb, 8/(2*2), 2*2, 2*2]
= [mb, 2, 4, 4]- Parameters:
x- the input to depth to space pooling 2d operation - 4d activations in NCHW format (shape [minibatch, channels, height, width]) or NHWC format (shape [minibatch, height, width, channels]) (NUMERIC type)blockSize- Block size, in the height/width dimensiondataFormat- Data format: "NCHW" or "NHWC"- Returns:
- output Output variable (NUMERIC type)
-
depthWiseConv2d
public INDArray depthWiseConv2d(INDArray layerInput, INDArray depthWeights, INDArray bias, Conv2DConfig Conv2DConfig)
Depth-wise 2D convolution operation with optional bias- Parameters:
layerInput- the input to max pooling 2d operation - 4d CNN (image) activations in NCHW format (NUMERIC type)depthWeights- Depth-wise conv2d weights. 4 dimensions with format [kernelHeight, kernelWidth, inputChannels, depthMultiplier] (NUMERIC type)bias- Optional 1D bias array with shape [outputChannels]. May be null. (NUMERIC type)Conv2DConfig- Configuration Object- Returns:
- output result of depthwise conv2d op (NUMERIC type)
-
depthWiseConv2d
public INDArray depthWiseConv2d(INDArray layerInput, INDArray depthWeights, Conv2DConfig Conv2DConfig)
Depth-wise 2D convolution operation with optional bias- Parameters:
layerInput- the input to max pooling 2d operation - 4d CNN (image) activations in NCHW format (NUMERIC type)depthWeights- Depth-wise conv2d weights. 4 dimensions with format [kernelHeight, kernelWidth, inputChannels, depthMultiplier] (NUMERIC type)Conv2DConfig- Configuration Object- Returns:
- output result of depthwise conv2d op (NUMERIC type)
-
dilation2D
public INDArray dilation2D(INDArray df, INDArray weights, int[] strides, int[] rates, boolean isSameMode)
TODO doc string- Parameters:
df- (NUMERIC type)weights- df (NUMERIC type)strides- weights (Size: Exactly(count=2))rates- strides (Size: Exactly(count=2))isSameMode- isSameMode- Returns:
- output Computed the grayscale dilation of 4-D input and 3-D filters tensors. (NUMERIC type)
-
extractImagePatches
public INDArray extractImagePatches(INDArray input, int kH, int kW, int sH, int sW, int rH, int rW, boolean sameMode)
Extract image patches- Parameters:
input- Input array. Must be rank 4, with shape [minibatch, height, width, channels] (NUMERIC type)kH- Kernel heightkW- Kernel widthsH- Stride heightsW- Stride widthrH- Rate heightrW- Rate widthsameMode- If true: use same mode padding. If false- Returns:
- output The result is a 4D tensor which is indexed by batch, row, and column. (NUMERIC type)
-
im2Col
public INDArray im2Col(INDArray in, Conv2DConfig Conv2DConfig)
im2col operation for use in 2D convolution operations. Outputs a 6d array with shape
[minibatch, inputChannels, kernelHeight, kernelWidth, outputHeight, outputWidth]- Parameters:
in- Input - rank 4 input with shape [minibatch, inputChannels, height, width] (NUMERIC type)Conv2DConfig- Configuration Object- Returns:
- output Im2Col output variable (NUMERIC type)
-
localResponseNormalization
public INDArray localResponseNormalization(INDArray input, LocalResponseNormalizationConfig LocalResponseNormalizationConfig)
2D convolution layer operation - local response normalization- Parameters:
input- the inputs to lrn (NUMERIC type)LocalResponseNormalizationConfig- Configuration Object- Returns:
- output Result after Local Response Normalization (NUMERIC type)
-
maxPoolWithArgmax
public INDArray[] maxPoolWithArgmax(INDArray input, Pooling2DConfig Pooling2DConfig)
2D Convolution layer operation - Max pooling on the input and outputs both max values and indices- Parameters:
input- the input to max pooling 2d operation - 4d CNN (image) activations in NCHW format (shape [minibatch, channels, height, width]) or NHWC format (shape [minibatch, height, width, channels]) (NUMERIC type)Pooling2DConfig- Configuration Object
-
maxPooling2d
public INDArray maxPooling2d(INDArray input, Pooling2DConfig Pooling2DConfig)
2D Convolution layer operation - max pooling 2d- Parameters:
input- the input to max pooling 2d operation - 4d CNN (image) activations in NCHW format (shape [minibatch, channels, height, width]) or NHWC format (shape [minibatch, height, width, channels]) (NUMERIC type)Pooling2DConfig- Configuration Object- Returns:
- output Result after applying max pooling on the input (NUMERIC type)
-
maxPooling3d
public INDArray maxPooling3d(INDArray input, Pooling3DConfig Pooling3DConfig)
3D convolution layer operation - max pooling 3d operation.- Parameters:
input- the input to average pooling 3d operation - 5d activations in NCDHW format (shape [minibatch, channels, depth, height, width]) or NDHWC format (shape [minibatch, depth, height, width, channels]) (NUMERIC type)Pooling3DConfig- Configuration Object- Returns:
- output Result after applying max pooling on the input (NUMERIC type)
-
separableConv2d
public INDArray separableConv2d(INDArray layerInput, INDArray depthWeights, INDArray pointWeights, INDArray bias, Conv2DConfig Conv2DConfig)
Separable 2D convolution operation with optional bias- Parameters:
layerInput- the input to max pooling 2d operation - 4d CNN (image) activations in NCHW format (shape [minibatch, channels, height, width]) or NHWC format (shape [minibatch, height, width, channels]) (NUMERIC type)depthWeights- Separable conv2d depth weights. 4 dimensions with format [kernelHeight, kernelWidth, inputChannels, depthMultiplier] (NUMERIC type)pointWeights- Point weights, rank 4 with format [1, 1, inputChannels*depthMultiplier, outputChannels]. May be null (NUMERIC type)bias- Optional bias, rank 1 with shape [outputChannels]. May be null. (NUMERIC type)Conv2DConfig- Configuration Object- Returns:
- output result of separable convolution 2d operation (NUMERIC type)
-
separableConv2d
public INDArray separableConv2d(INDArray layerInput, INDArray depthWeights, INDArray pointWeights, Conv2DConfig Conv2DConfig)
Separable 2D convolution operation with optional bias- Parameters:
layerInput- the input to max pooling 2d operation - 4d CNN (image) activations in NCHW format (shape [minibatch, channels, height, width]) or NHWC format (shape [minibatch, height, width, channels]) (NUMERIC type)depthWeights- Separable conv2d depth weights. 4 dimensions with format [kernelHeight, kernelWidth, inputChannels, depthMultiplier] (NUMERIC type)pointWeights- Point weights, rank 4 with format [1, 1, inputChannels*depthMultiplier, outputChannels]. May be null (NUMERIC type)Conv2DConfig- Configuration Object- Returns:
- output result of separable convolution 2d operation (NUMERIC type)
-
spaceToBatch
public INDArray spaceToBatch(INDArray x, int[] blocks, int[] paddingTop, int... paddingBottom)
Convolution 2d layer space to batch operation on 4d input.
Increases input batch dimension by rearranging data from spatial dimensions into batch dimension- Parameters:
x- Input variable. 4d input (NUMERIC type)blocks- Block size, in the height/width dimension (Size: Exactly(count=2))paddingTop- Optional 2d int[] array for padding the result: values [[pad top, pad bottom], [pad left, pad right]] (Size: Exactly(count=2))paddingBottom- Optional 2d int[] array for padding the result: values [[pad top, pad bottom], [pad left, pad right]] (Size: Exactly(count=2))- Returns:
- output Output variable (NUMERIC type)
-
spaceToDepth
public INDArray spaceToDepth(INDArray x, int blockSize, DataFormat dataFormat)
Convolution 2d layer space to depth operation on 4d input.
Increases input channels (reduced spatial dimensions) by rearranging data into a larger channels dimension
Example: if input has shape [mb, 2, 4, 4] and block size is 2, then output size is [mb, 8/(2*2), 2*2, 2*2]
= [mb, 2, 4, 4]- Parameters:
x- the input to depth to space pooling 2d operation - 4d activations in NCHW format (shape [minibatch, channels, height, width]) or NHWC format (shape [minibatch, height, width, channels]) (NUMERIC type)blockSize- Block size, in the height/width dimensiondataFormat- Data format: "NCHW" or "NHWC"- Returns:
- output Output variable (NUMERIC type)
-
upsampling2d
public INDArray upsampling2d(INDArray input, int scale)
Upsampling layer for 2D inputs.
scale is used for both height and width dimensions.- Parameters:
input- Input in NCHW format (NUMERIC type)scale- The scale for both height and width dimensions.- Returns:
- output Upsampled input (NUMERIC type)
-
upsampling2d
public INDArray upsampling2d(INDArray input, int scaleH, int scaleW, boolean nchw)
2D Convolution layer operation - Upsampling 2d- Parameters:
input- Input in NCHW format (NUMERIC type)scaleH- Scale to upsample in height dimensionscaleW- Scale to upsample in width dimensionnchw- If true: input is in NCHW (minibatch, channels, height, width) format. False: NHWC format- Returns:
- output Upsampled input (NUMERIC type)
-
upsampling3d
public INDArray upsampling3d(INDArray input, boolean ncdhw, int scaleD, int scaleH, int scaleW)
3D Convolution layer operation - Upsampling 3d- Parameters:
input- Input in NCHW format (NUMERIC type)ncdhw- If true: input is in NCDHW (minibatch, channels, depth, height, width) format. False: NDHWC formatscaleD- Scale to upsample in depth dimensionscaleH- Scale to upsample in height dimensionscaleW- Scale to upsample in width dimension- Returns:
- output Upsampled input (NUMERIC type)
-
-