def forward(self, x):
     col = utils.im2col(x, self.kernel_size, self.stride, self.pad)
     n, c, kh, kw, out_h, out_w = col.shape
     col = col.reshape(n, c, kh * kw, out_h, out_w)
     col = col.transpose(0, 1, 3, 4, 2).reshape(-1, kh * kw)
     indexes = self.indexes.ravel()
     col = col[np.arange(len(indexes)), indexes]
     return col.reshape(n, c, out_h, out_w)
    def forward(self, x):
        col = utils.im2col(x, self.kernel_size, self.stride, self.pad)

        n, c, kh, kw, out_h, out_w = col.shape
        col = col.reshape(n, c, kh * kw, out_h, out_w)
        self.indexes = col.argmax(axis=2)
        y = col.max(axis=2)
        return y
    def forward(self, x, gy):
        xp = cuda.get_array_module(x)

        col = utils.im2col(x,
                           self.kernel_size,
                           self.stride,
                           self.pad,
                           to_matrix=False)
        gW = xp.tensordot(gy, col, ((0, 2, 3), (0, 4, 5)))
        return gW
    def forward(self, x, W, b):
        kh, kw = W.shape[2:]
        col = utils.im2col(x, (kh, kw), self.stride, self.pad)

        y = np.tensordot(col, W, ((1, 2, 3), (1, 2, 3)))
        if b is not None:
            y += b
        y = np.rollaxis(y, 3, 1)
        # y = np.transpose(y, (0, 3, 1, 2))
        return y
    def forward(self, x, W, b):
        xp = cuda.get_array_module(x)

        KH, KW = W.shape[2:]
        col = utils.im2col(x, (KH, KW), self.stride, self.pad, to_matrix=False)

        y = xp.tensordot(col, W, ((1, 2, 3), (1, 2, 3)))
        if b is not None:
            y += b
        y = xp.rollaxis(y, 3, 1)
        # y = np.transpose(y, (0, 3, 1, 2))
        return y
 def forward(self, x):
     col = utils.im2col(x,
                        self.kernel_size,
                        self.stride,
                        self.pad,
                        to_matrix=False)
     N, C, KH, KW, OH, OW = col.shape
     col = col.reshape(N, C, KH * KW, OH, OW)
     col = col.transpose(0, 1, 3, 4, 2).reshape(-1, KH * KW)
     indexes = self.indexes.ravel()
     col = col[np.arange(len(indexes)), indexes]
     return col.reshape(N, C, OH, OW)
    def forward(self, x):
        col = utils.im2col(x,
                           self.kernel_size,
                           self.stride,
                           self.pad,
                           to_matrix=False)

        N, C, KH, KW, OH, OW = col.shape
        col = col.reshape(N, C, KH * KW, OH, OW)
        self.indexes = col.argmax(axis=2)
        y = col.max(axis=2)
        return y
 def forward(self, x):
     self.input_shape = x.shape
     y = utils.im2col(x, self.kernel_size, self.stride, self.pad,
                      self.to_matrix)
     return y
 def forward(self, x, gy):
     col = utils.im2col(x, self.kernel_size, self.stride, self.pad)
     gW = np.tensordot(gy, col, ((0, 2, 3), (0, 4, 5)))
     return gW