public class ConvolutionUtils extends Object
Modifier and Type | Field and Description |
---|---|
static String |
NCHW_NHWC_ERROR_MSG |
Modifier and Type | Method and Description |
---|---|
static INDArray |
adapt2dMask(INDArray mask,
INDArray output,
@NonNull CNN2DFormat format,
LayerWorkspaceMgr workspaceMgr,
ArrayType type) |
static INDArray |
cnn1dMaskReduction(INDArray in,
int kernel,
int stride,
int padding,
int dilation,
ConvolutionMode cm)
Given a mask array for a 1D CNN layer of shape [minibatch, sequenceLength], reduce the mask according to the 1D CNN layer configuration.
|
static INDArray |
cnn2dMaskReduction(INDArray inMask,
int[] kernel,
int[] stride,
int[] padding,
int[] dilation,
ConvolutionMode convolutionMode)
Reduce a 2d CNN layer mask array (of 0s and 1s) according to the layer configuration.
|
static int[] |
effectiveKernelSize(int[] kernel,
int[] dilation) |
static long[] |
getDeconvolution3DOutputSize(INDArray inputData,
int[] kernel,
int[] strides,
int[] padding,
int[] dilation,
ConvolutionMode convolutionMode,
Convolution3D.DataFormat dataFormat)
Get the output size of a deconvolution operation for given input data.
|
static int[] |
getDeconvolutionOutputSize(INDArray inputData,
int[] kernel,
int[] strides,
int[] padding,
ConvolutionMode convolutionMode,
int[] dilation,
CNN2DFormat format)
Get the output size of a deconvolution operation for given input data.
|
static int[] |
getHeightAndWidth(int[] shape)
Get the height and width
for an image
|
static int[] |
getHeightAndWidth(NeuralNetConfiguration conf)
Get the height and width
from the configuration
|
static int[] |
getHWDFromInputType(InputType inputType)
Get heigh/width/channels as length 3 int[] from the InputType
|
static int[] |
getOutputSize(INDArray inputData,
int[] kernel,
int[] strides,
int[] padding,
ConvolutionMode convolutionMode)
Deprecated.
|
static int[] |
getOutputSize(INDArray inputData,
int[] kernel,
int[] strides,
int[] padding,
ConvolutionMode convolutionMode,
int[] dilation)
|
static int[] |
getOutputSize(INDArray inputData,
int[] kernel,
int[] strides,
int[] padding,
ConvolutionMode convolutionMode,
int[] dilation,
CNN2DFormat format)
Get the output size (height/width) for the given input data and CNN configuration
|
static int[] |
getSameModeBottomRightPadding(int[] outSize,
int[] inSize,
int[] kernel,
int[] strides,
int[] dilation)
Get bottom and right padding for same mode only.
|
static int[] |
getSameModeTopLeftPadding(int[] outSize,
int[] inSize,
int[] kernel,
int[] strides,
int[] dilation)
Get top and left padding for same mode only.
|
static int |
numChannels(int[] shape)
Returns the number of
feature maps for a given shape (must be at least 3 dimensions
|
static long |
numFeatureMap(NeuralNetConfiguration conf) |
static INDArray |
reshape2dTo4d(INDArray in2d,
long[] toShape,
CNN2DFormat format,
LayerWorkspaceMgr workspaceMgr,
ArrayType type) |
static INDArray |
reshape2dTo5d(Convolution3D.DataFormat format,
INDArray in2d,
long n,
long d,
long h,
long w,
long ch,
LayerWorkspaceMgr workspaceMgr,
ArrayType type) |
static INDArray |
reshape3dMask(INDArray mask,
LayerWorkspaceMgr workspaceMgr,
ArrayType type) |
static INDArray |
reshape4dMask(INDArray mask,
LayerWorkspaceMgr workspaceMgr,
ArrayType arrayType) |
static INDArray |
reshape4dTo2d(INDArray in,
CNN2DFormat format,
LayerWorkspaceMgr workspaceMgr,
ArrayType type) |
static INDArray |
reshape4dTo2d(INDArray in,
LayerWorkspaceMgr workspaceMgr,
ArrayType type) |
static INDArray |
reshape5dTo2d(Convolution3D.DataFormat format,
INDArray in,
LayerWorkspaceMgr workspaceMgr,
ArrayType type) |
static INDArray |
reshapeCnn3dMask(Convolution3D.DataFormat format,
INDArray mask,
INDArray label,
LayerWorkspaceMgr workspaceMgr,
ArrayType type) |
static INDArray |
reshapeMaskIfRequired(INDArray mask,
INDArray output,
CNN2DFormat format,
LayerWorkspaceMgr workspaceMgr,
ArrayType type) |
static INDArray |
reshapeMaskIfRequired(INDArray mask,
INDArray output,
LayerWorkspaceMgr workspaceMgr,
ArrayType type)
|
static void |
validateCnnKernelStridePadding(int[] kernelSize,
int[] stride,
int[] padding)
Perform validation on the CNN layer kernel/stride/padding.
|
static void |
validateConvolutionModePadding(ConvolutionMode mode,
int[] padding)
Check that the convolution mode is consistent with the padding specification
|
static void |
validateShapes(INDArray inputData,
int[] eKernel,
int[] strides,
int[] padding,
ConvolutionMode convolutionMode,
int[] dilation,
int[] inShape,
boolean atrous) |
public static final String NCHW_NHWC_ERROR_MSG
@Deprecated public static int[] getOutputSize(INDArray inputData, int[] kernel, int[] strides, int[] padding, ConvolutionMode convolutionMode)
public static int[] getDeconvolutionOutputSize(INDArray inputData, int[] kernel, int[] strides, int[] padding, ConvolutionMode convolutionMode, int[] dilation, CNN2DFormat format)
inputData
- Input datakernel
- Kernel size (height/width)strides
- Strides (height/width)padding
- Padding (height/width)convolutionMode
- Convolution mode (Same, Strict, Truncate)dilation
- Kernel dilation (height/width)public static long[] getDeconvolution3DOutputSize(INDArray inputData, int[] kernel, int[] strides, int[] padding, int[] dilation, ConvolutionMode convolutionMode, Convolution3D.DataFormat dataFormat)
inputData
- Input datakernel
- Kernel size (height/width)strides
- Strides (height/width)padding
- Padding (height/width)convolutionMode
- Convolution mode (Same, Strict, Truncate)dilation
- Kernel dilation (height/width)@Deprecated public static int[] getOutputSize(INDArray inputData, int[] kernel, int[] strides, int[] padding, ConvolutionMode convolutionMode, int[] dilation)
public static int[] getOutputSize(INDArray inputData, int[] kernel, int[] strides, int[] padding, ConvolutionMode convolutionMode, int[] dilation, CNN2DFormat format)
inputData
- Input datakernel
- Kernel size (height/width)strides
- Strides (height/width)padding
- Padding (height/width)convolutionMode
- Convolution mode (Same, Strict, Truncate)dilation
- Kernel dilation (height/width)format
- Format for input activationspublic static void validateShapes(INDArray inputData, int[] eKernel, int[] strides, int[] padding, ConvolutionMode convolutionMode, int[] dilation, int[] inShape, boolean atrous)
public static int[] effectiveKernelSize(int[] kernel, int[] dilation)
public static int[] getSameModeTopLeftPadding(int[] outSize, int[] inSize, int[] kernel, int[] strides, int[] dilation)
outSize
- Output size (length 2 array, height dimension first)inSize
- Input size (length 2 array, height dimension first)kernel
- Kernel size (length 2 array, height dimension first)strides
- Strides (length 2 array, height dimension first)dilation
- Dilation (length 2 array, height dimension first)public static int[] getSameModeBottomRightPadding(int[] outSize, int[] inSize, int[] kernel, int[] strides, int[] dilation)
outSize
- Output size (length 2 array, height dimension first)inSize
- Input size (length 2 array, height dimension first)kernel
- Kernel size (length 2 array, height dimension first)strides
- Strides (length 2 array, height dimension first)dilation
- Dilation (length 2 array, height dimension first)public static int[] getHeightAndWidth(NeuralNetConfiguration conf)
conf
- the configuration to get height and width frompublic static long numFeatureMap(NeuralNetConfiguration conf)
conf
- the configuration to get
the number of kernels frompublic static int[] getHeightAndWidth(int[] shape)
shape
- the shape of the imagepublic static int numChannels(int[] shape)
shape
- the shape to get the
number of feature maps forpublic static void validateConvolutionModePadding(ConvolutionMode mode, int[] padding)
public static void validateCnnKernelStridePadding(int[] kernelSize, int[] stride, int[] padding)
kernelSize
- Kernel size array to checkstride
- Stride array to checkpadding
- Padding array to checkpublic static INDArray reshape4dTo2d(INDArray in, LayerWorkspaceMgr workspaceMgr, ArrayType type)
public static INDArray reshape4dTo2d(INDArray in, CNN2DFormat format, LayerWorkspaceMgr workspaceMgr, ArrayType type)
public static INDArray reshape5dTo2d(@NonNull Convolution3D.DataFormat format, INDArray in, LayerWorkspaceMgr workspaceMgr, ArrayType type)
public static INDArray reshapeCnn3dMask(@NonNull Convolution3D.DataFormat format, INDArray mask, INDArray label, LayerWorkspaceMgr workspaceMgr, ArrayType type)
public static INDArray reshape2dTo4d(INDArray in2d, long[] toShape, CNN2DFormat format, LayerWorkspaceMgr workspaceMgr, ArrayType type)
public static INDArray reshape2dTo5d(Convolution3D.DataFormat format, INDArray in2d, long n, long d, long h, long w, long ch, LayerWorkspaceMgr workspaceMgr, ArrayType type)
@Deprecated public static INDArray reshapeMaskIfRequired(INDArray mask, INDArray output, LayerWorkspaceMgr workspaceMgr, ArrayType type)
public static INDArray reshapeMaskIfRequired(INDArray mask, INDArray output, CNN2DFormat format, LayerWorkspaceMgr workspaceMgr, ArrayType type)
public static INDArray adapt2dMask(INDArray mask, INDArray output, @NonNull @NonNull CNN2DFormat format, LayerWorkspaceMgr workspaceMgr, ArrayType type)
public static INDArray reshape3dMask(INDArray mask, LayerWorkspaceMgr workspaceMgr, ArrayType type)
public static INDArray reshape4dMask(INDArray mask, LayerWorkspaceMgr workspaceMgr, ArrayType arrayType)
public static int[] getHWDFromInputType(InputType inputType)
inputType
- Input type to getpublic static INDArray cnn1dMaskReduction(INDArray in, int kernel, int stride, int padding, int dilation, ConvolutionMode cm)
in
- Input sizekernel
- Kernel sizestride
- Stridepadding
- Paddingdilation
- Dilationcm
- Convolution modepublic static INDArray cnn2dMaskReduction(INDArray inMask, int[] kernel, int[] stride, int[] padding, int[] dilation, ConvolutionMode convolutionMode)
inMask
- Input mask array - rank 4, shape [mb,c,h,1] or [mb,c,w,1] or [mb,c,h,w]kernel
- Kernel configuration for the layerstride
- Stridepadding
- Paddingdilation
- DilationconvolutionMode
- Convolution modeCopyright © 2020. All rights reserved.