public Im2col(INDArray x, int kh, int kw, int sy, int sx, int ph, int pw, boolean isSameMode, INDArray z) { super(x); this.kh = kh; this.kw = kw; this.sy = sy; this.sx = sx; this.ph = ph; this.pw = pw; this.isSameMode = isSameMode; this.z = z; extraArgs = this.extraArgs(); }
@Override public Object[] extraArgs() { return new Object[] {kw, kh, sx, sy, pw, ph, isSameMode ? 1.0 : 0.0, type.ordinal(), extra}; }
public Col2Im(INDArray x, int sy, int sx, int ph, int pw, int h, int w, boolean isSameMode, INDArray z) { super(x); this.sy = sy; this.sx = sx; this.ph = ph; this.pw = pw; this.h = h; this.w = w; this.z = z; this.isSameMode = isSameMode; extraArgs = this.extraArgs(); }
public Pooling2D(INDArray x, int kh, int kw, int sy, int sx, int ph, int pw, boolean isSameMode, Pooling2DType type, double extra, int virtualHeight, int virtualWidth, INDArray z) { super(x); this.kh = kh; this.kw = kw; this.sy = sy; this.sx = sx; this.ph = ph; this.pw = pw; this.isSameMode = isSameMode; this.type = type; this.z = z; this.extra = extra; this.im2colShape = getNewOutputShape(x, kh, kw, sy, sx, ph, pw, virtualHeight, virtualWidth, false); extraArgs = this.extraArgs(); }
public static INDArray im2col(INDArray img, int kh, int kw, int sy, int sx, int ph, int pw, boolean isSameMode, INDArray out) { Im2col im2col = new Im2col(img, kh, kw, sy, sx, ph, pw, isSameMode, out); return Nd4j.getExecutioner().exec(im2col).z(); }
public static INDArray col2im(INDArray col, INDArray z, int sy, int sx, int ph, int pw, int h, int w) { if (col.rank() != 6) throw new IllegalArgumentException("col2im input array must be rank 6"); if (z.rank() != 4) throw new IllegalArgumentException("col2im output array must be rank 4"); Col2Im col2Im = new Col2Im(col, sy, sx, ph, pw, h, w, false, z); Nd4j.getExecutioner().exec(col2Im); return z; }
public Col2Im(INDArray x, int sy, int sx, int ph, int pw, int h, int w) { this(x, sy, sx, ph, pw, h, w, false, getNewOutputArray(x, h, w)); }
public Im2col(INDArray x, int kh, int kw, int sy, int sx, int ph, int pw, boolean isSameMode) { this(x, kh, kw, sy, sx, ph, pw, isSameMode, getNewOutputArray(x, kh, kw, sy, sx, ph, pw, false)); }
public static INDArray pooling2D(INDArray img, int kh, int kw, int sy, int sx, int ph, int pw, boolean isSameMode, Pooling2D.Pooling2DType type, double extra, int virtualHeight, int virtualWidth, INDArray out) { Pooling2D pooling = new Pooling2D(img, kh, kw, sy, sx, ph, pw, isSameMode, type, extra, virtualHeight, virtualWidth, out); return Nd4j.getExecutioner().exec(pooling).z(); }
extraz.get().put(10, ((Pooling2D) op).getIm2colShape().addressPointer());
/** * Implement column formatted images * @param img the image to process * @param kh the kernel height * @param kw the kernel width * @param sy the stride along y * @param sx the stride along x * @param ph the padding width * @param pw the padding height * @param pval the padding value (not used) * @param isSameMode whether padding mode is 'same' * @return the column formatted image * */ public static INDArray im2col(INDArray img, int kh, int kw, int sy, int sx, int ph, int pw, int pval, boolean isSameMode) { Im2col im2col = new Im2col(img, kh, kw, sy, sx, ph, pw, isSameMode); return Nd4j.getExecutioner().exec(im2col).z(); }
/** * Rearrange matrix * columns into blocks * @param col the column * transposed image to convert * @param sy stride y * @param sx stride x * @param ph padding height * @param pw padding width * @param h height * @param w width * @return */ public static INDArray col2im(INDArray col, int sy, int sx, int ph, int pw, int h, int w) { if (col.rank() != 6) throw new IllegalArgumentException("col2im input array must be rank 6"); Col2Im col2Im = new Col2Im(col, sy, sx, ph, pw, h, w); return Nd4j.getExecutioner().exec(col2Im).z(); }
/** * Implement column formatted images * @param img the image to process * @param kh the kernel height * @param kw the kernel width * @param sy the stride along y * @param sx the stride along x * @param ph the padding width * @param pw the padding height * @param isSameMode whether to cover the whole image or not * @return the column formatted image * */ public static INDArray im2col(INDArray img, int kh, int kw, int sy, int sx, int ph, int pw, boolean isSameMode) { Nd4j.getCompressor().autoDecompress(img); Im2col im2col = new Im2col(img, kh, kw, sy, sx, ph, pw, isSameMode); return Nd4j.getExecutioner().exec(im2col).z(); }