Package org.nd4j.linalg.convolution
Class Convolution
- java.lang.Object
-
- org.nd4j.linalg.convolution.Convolution
-
public class Convolution extends Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Convolution.Type
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static INDArray
col2im(INDArray col, int[] stride, int[] padding, int height, int width)
static INDArray
col2im(INDArray col, int sH, int sW, int ph, int pW, int kH, int kW)
Rearrange matrix columns into blocksstatic INDArray
col2im(INDArray col, INDArray z, int sH, int sW, int pH, int pW, int kH, int kW, int dH, int dW)
static INDArray
conv2d(INDArray input, INDArray kernel, Convolution.Type type)
2d convolution (aka the last 2 dimensionsstatic INDArray
convn(INDArray input, INDArray kernel, Convolution.Type type)
ND Convolutionstatic INDArray
convn(INDArray input, INDArray kernel, Convolution.Type type, int[] axes)
ND Convolutionstatic long
effectiveKernelSize(long kernel, int dilation)
static INDArray
im2col(INDArray img, int[] kernel, int[] stride, int[] padding)
static INDArray
im2col(INDArray img, int kh, int kw, int sy, int sx, int ph, int pw, boolean isSameMode)
Implement column formatted imagesstatic INDArray
im2col(INDArray img, int kh, int kw, int sy, int sx, int ph, int pw, boolean isSameMode, INDArray out)
static INDArray
im2col(INDArray img, int kh, int kw, int sy, int sx, int ph, int pw, int pval, boolean isSameMode)
Implement column formatted imagesstatic INDArray
im2col(INDArray img, int kh, int kw, int sy, int sx, int ph, int pw, int dh, int dw, boolean isSameMode)
static INDArray
im2col(INDArray img, int kh, int kw, int sy, int sx, int ph, int pw, int dH, int dW, boolean isSameMode, INDArray out)
Execute im2col.static long
outputSize(long size, long k, long s, long p, int dilation, boolean isSameMode)
static long
outSize(long size, long k, long s, long p, int dilation, boolean coverAll)
Deprecated.static INDArray
pooling2D(INDArray img, int kh, int kw, int sy, int sx, int ph, int pw, int dh, int dw, boolean isSameMode, Pooling2D.Pooling2DType type, Pooling2D.Divisor divisor, double extra, int virtualHeight, int virtualWidth, INDArray out)
Pooling 2d implementation
-
-
-
Method Detail
-
col2im
public static INDArray col2im(INDArray col, int[] stride, int[] padding, int height, int width)
- Parameters:
col
-stride
-padding
-height
-width
-- Returns:
-
col2im
public static INDArray col2im(INDArray col, int sH, int sW, int ph, int pW, int kH, int kW)
Rearrange matrix columns into blocks- Parameters:
col
- the column transposed image to convertsH
- stride heightsW
- stride widthph
- padding heightpW
- padding widthkH
- heightkW
- width- Returns:
-
col2im
public static INDArray col2im(INDArray col, INDArray z, int sH, int sW, int pH, int pW, int kH, int kW, int dH, int dW)
-
im2col
public static INDArray im2col(INDArray img, int[] kernel, int[] stride, int[] padding)
- Parameters:
img
-kernel
-stride
-padding
-- Returns:
-
im2col
public static INDArray im2col(INDArray img, int kh, int kw, int sy, int sx, int ph, int pw, boolean isSameMode)
Implement column formatted images- Parameters:
img
- the image to processkh
- the kernel heightkw
- the kernel widthsy
- the stride along ysx
- the stride along xph
- the padding widthpw
- the padding heightisSameMode
- whether to cover the whole image or not- Returns:
- the column formatted image
-
im2col
public static INDArray im2col(INDArray img, int kh, int kw, int sy, int sx, int ph, int pw, int dh, int dw, boolean isSameMode)
-
im2col
public static INDArray im2col(INDArray img, int kh, int kw, int sy, int sx, int ph, int pw, boolean isSameMode, INDArray out)
-
im2col
public static INDArray im2col(INDArray img, int kh, int kw, int sy, int sx, int ph, int pw, int dH, int dW, boolean isSameMode, INDArray out)
Execute im2col. Note the input must be NCHW.- Parameters:
img
- the input image in NCHWkh
-kw
-sy
-sx
-ph
-pw
-dH
-dW
-isSameMode
-out
-- Returns:
-
pooling2D
public static INDArray pooling2D(INDArray img, int kh, int kw, int sy, int sx, int ph, int pw, int dh, int dw, boolean isSameMode, Pooling2D.Pooling2DType type, Pooling2D.Divisor divisor, double extra, int virtualHeight, int virtualWidth, INDArray out)
Pooling 2d implementation- Parameters:
img
-kh
-kw
-sy
-sx
-ph
-pw
-dh
-dw
-isSameMode
-type
-extra
- optional argument. I.e. used in pnorm pooling.virtualHeight
-virtualWidth
-out
-- Returns:
-
im2col
public static INDArray im2col(INDArray img, int kh, int kw, int sy, int sx, int ph, int pw, int pval, boolean isSameMode)
Implement column formatted images- Parameters:
img
- the image to processkh
- the kernel heightkw
- the kernel widthsy
- the stride along ysx
- the stride along xph
- the padding widthpw
- the padding heightpval
- the padding value (not used)isSameMode
- whether padding mode is 'same'- Returns:
- the column formatted image
-
outSize
@Deprecated public static long outSize(long size, long k, long s, long p, int dilation, boolean coverAll)
Deprecated.The out size for a convolution- Parameters:
size
-k
-s
-p
-coverAll
-- Returns:
-
outputSize
public static long outputSize(long size, long k, long s, long p, int dilation, boolean isSameMode)
-
effectiveKernelSize
public static long effectiveKernelSize(long kernel, int dilation)
-
conv2d
public static INDArray conv2d(INDArray input, INDArray kernel, Convolution.Type type)
2d convolution (aka the last 2 dimensions- Parameters:
input
- the input to opkernel
- the kernel to convolve withtype
-- Returns:
-
convn
public static INDArray convn(INDArray input, INDArray kernel, Convolution.Type type, int[] axes)
ND Convolution- Parameters:
input
- the input to opkernel
- the kerrnel to op withtype
- the opType of convolutionaxes
- the axes to do the convolution along- Returns:
- the convolution of the given input and kernel
-
convn
public static INDArray convn(INDArray input, INDArray kernel, Convolution.Type type)
ND Convolution- Parameters:
input
- the input to opkernel
- the kernel to op withtype
- the opType of convolution- Returns:
- the convolution of the given input and kernel
-
-