Package org.deeplearning4j.util
Class Convolution1DUtils
- java.lang.Object
-
- org.deeplearning4j.util.Convolution1DUtils
-
public class Convolution1DUtils extends Object
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static int
effectiveKernelSize(int kernel, int dilation)
static long
getOutputSize(long inH, int kernel, int strides, int padding, ConvolutionMode convolutionMode, int dilation)
Get the output size (height) for the given input data and CNN1D configurationstatic int
getOutputSize(INDArray inputData, int kernel, int strides, int padding, ConvolutionMode convolutionMode)
static int
getOutputSize(INDArray inputData, int kernel, int strides, int padding, ConvolutionMode convolutionMode, int dilation)
Get the output size (height) for the given input data and CNN1D configurationstatic RNNFormat
getRnnFormatFromLayer(Layer layer)
Get theRNNFormat
for the given layer.static int
getSameModeBottomRightPadding(int outSize, int inSize, int kernel, int strides, int dilation)
static int
getSameModeTopLeftPadding(int outSize, int inSize, int kernel, int strides, int dilation)
Get top padding for same mode only.static boolean
hasRnnDataFormat(Layer layer)
Returns true if the given layer has anRNNFormat
.static INDArray
reshapeWeightArrayOrGradientForFormat(INDArray w, RNNFormat rnnFormat)
Reshapes the given weight array or weight gradient to work with the specifiedRNNFormat
static void
validateCnn1DKernelStridePadding(int kernel, 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 specificationstatic void
validateShapes(INDArray inputData, int eKernel, int strides, int padding, ConvolutionMode convolutionMode, int dilation, int inShape, boolean atrous)
-
-
-
Method Detail
-
getOutputSize
public static int getOutputSize(INDArray inputData, int kernel, int strides, int padding, ConvolutionMode convolutionMode)
-
hasRnnDataFormat
public static boolean hasRnnDataFormat(Layer layer)
Returns true if the given layer has anRNNFormat
. This is true for:Convolution1DLayer
,Subsampling1DLayer
SimpleRnn
LSTM
EmbeddingSequenceLayer
- Parameters:
layer
- the layer to test- Returns:
- true if the input layer has an rnn format false otherwise
-
getRnnFormatFromLayer
public static RNNFormat getRnnFormatFromLayer(Layer layer)
Get theRNNFormat
for the given layer. Throws anIllegalArgumentException
if a layer doesn't have an rnn format- Parameters:
layer
- the layer to get the format for- Returns:
- the format for the layer
-
reshapeWeightArrayOrGradientForFormat
public static INDArray reshapeWeightArrayOrGradientForFormat(INDArray w, RNNFormat rnnFormat)
Reshapes the given weight array or weight gradient to work with the specifiedRNNFormat
- Parameters:
w
- the weight array or gradientrnnFormat
- theRNNFormat
to use- Returns:
- the reshaped array.
-
getOutputSize
public static long getOutputSize(long inH, int kernel, int strides, int padding, ConvolutionMode convolutionMode, int dilation)
Get the output size (height) for the given input data and CNN1D configuration- Parameters:
inH
- Input size (height, or channels).kernel
- Kernel sizestrides
- Stridepadding
- PaddingconvolutionMode
- Convolution mode (Same, Strict, Truncate)dilation
- Kernel dilation- Returns:
- Output size (width)
-
getOutputSize
public static int getOutputSize(INDArray inputData, int kernel, int strides, int padding, ConvolutionMode convolutionMode, int dilation)
Get the output size (height) for the given input data and CNN1D configuration- Parameters:
inputData
- Input datakernel
- Kernel sizestrides
- Stridepadding
- PaddingconvolutionMode
- Convolution mode (Same, Strict, Truncate)dilation
- Kernel dilation- Returns:
- Output size (width)
-
validateShapes
public static void validateShapes(INDArray inputData, int eKernel, int strides, int padding, ConvolutionMode convolutionMode, int dilation, int inShape, boolean atrous)
-
effectiveKernelSize
public static int effectiveKernelSize(int kernel, int dilation)
-
validateConvolutionModePadding
public static void validateConvolutionModePadding(ConvolutionMode mode, int padding)
Check that the convolution mode is consistent with the padding specification
-
getSameModeTopLeftPadding
public static int getSameModeTopLeftPadding(int outSize, int inSize, int kernel, int strides, int dilation)
Get top padding for same mode only.- Parameters:
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)- Returns:
- Top left padding (length 2 array, height dimension first)
-
getSameModeBottomRightPadding
public static int getSameModeBottomRightPadding(int outSize, int inSize, int kernel, int strides, int dilation)
-
validateCnn1DKernelStridePadding
public static void validateCnn1DKernelStridePadding(int kernel, int stride, int padding)
Perform validation on the CNN layer kernel/stride/padding. Expect int, with values > 0 for kernel size and stride, and values >= 0 for padding.- Parameters:
kernel
- Kernel size to checkstride
- Stride to checkpadding
- Padding to check
-
-