def set_up(self, bottom, bottom_diff, params=None):
     self.bottom = bottom
     self.bottom_diff = bottom_diff
     self.top = hmarray.zeros(bottom.shape)
     self.mask = hmarray.random(bottom.shape)
     self.top_diff = hmarray.zeros(bottom.shape)
     return [(self.top, self.top_diff)]
def get_data():
    # data = np.asarray([
    #     transformer.preprocess('data', im),
    # ]).view(hmarray)
    data = hmarray.random((10, 3, 227, 227), _range=(0, 255))

    # data *= hmarray.random((5, 3, 227, 227), _range=(0, 2))
    # data -= hmarray.random((5, 3, 227, 227), _range=(-20, +20))
    return data
def get_data():
    # data = np.asarray([
    #     transformer.preprocess('data', im),
    # ]).view(hmarray)
    data = hmarray.random((10, 3, 227, 227), _range=(0, 255))

    # data *= hmarray.random((5, 3, 227, 227), _range=(0, 2))
    # data -= hmarray.random((5, 3, 227, 227), _range=(-20, +20))
    return data
예제 #4
0
 def set_up(self, bottom, bottom_diff):
     self.bottom, self.bottom_diff = bottom, bottom_diff
     N = self.num_output
     K = np.prod(bottom.shape[1:])
     scale = 1.0 / np.sqrt(self.num_output)
     if self.weights is None:
         self.weights = hmarray.random((N, K), _range=(-scale, scale))
     self.weights_diff = hmarray.zeros((N, K))
     self.weights_history = hmarray.zeros((N, K))
     self.bias_diff = hmarray.zeros((self.num_output, ))
     self.bias_history = hmarray.zeros((self.num_output, ))
     self.bias_multiplier = hmarray((1, self.bottom.shape[0]))
     self.bias_multiplier.fill(1)
     self.bias_multiplier.sync_ocl()
     top_shape = (bottom.shape[0], N)
     self.top = hmarray.zeros(top_shape)
     self.top_diff = hmarray.zeros(top_shape)
     return [(self.top, self.top_diff)]
예제 #5
0
    def set_up(self, bottom, bottom_diff):
        self.bottom = bottom
        self.bottom_diff = bottom_diff
        num, channels, height, width = bottom.shape

        weights_shape = (self.num_output, channels * self.kernel_size *
                         self.kernel_size)
        if self.weights is not None:
            self.weights = self.weights.reshape(weights_shape)
        else:
            n = 1.0 / np.sqrt(self.num_output)
            self.weights = hmarray.random(weights_shape, _range=(-n, n))
        self.weights_diff = hmarray.zeros(weights_shape)
        self.weights_history = hmarray.zeros(weights_shape)

        height_out = (height + 2 * self.padding - self.kernel_size) // \
            self.stride + 1
        width_out = (width + 2 * self.padding - self.kernel_size) // \
            self.stride + 1
        top_shape = (num, self.num_output, height_out, width_out)
        self.top = hmarray.zeros(top_shape)
        self.top_diff = hmarray.zeros(top_shape)
        return [(self.top, self.top_diff)]
예제 #6
0
    def set_up(self, bottom, bottom_diff):
        self.bottom = bottom
        self.bottom_diff = bottom_diff
        num, channels, height, width = bottom.shape

        weights_shape = (self.num_output,
                         channels * self.kernel_size * self.kernel_size)
        if self.weights is not None:
            self.weights = self.weights.reshape(weights_shape)
        else:
            n = 1.0 / np.sqrt(self.num_output)
            self.weights = hmarray.random(weights_shape, _range=(-n, n))
        self.weights_diff = hmarray.zeros(weights_shape)
        self.weights_history = hmarray.zeros(weights_shape)

        height_out = (height + 2 * self.padding - self.kernel_size) // \
            self.stride + 1
        width_out = (width + 2 * self.padding - self.kernel_size) // \
            self.stride + 1
        top_shape = (num, self.num_output, height_out, width_out)
        self.top = hmarray.zeros(top_shape)
        self.top_diff = hmarray.zeros(top_shape)
        return [(self.top, self.top_diff)]
예제 #7
0
def get_data():
    data = hmarray.random((32, 3, 224, 224), _range=(0, 255))
    data.sync_ocl()
    return data