def _initialize_theta(self): filter_shape = self.filter_shape image_shape = self.image_shape poolsize = self.poolsize conv_in = np.prod(filter_shape[1:]) conv_out = filter_shape[0] * np.prod(filter_shape[2:]) pool_out = conv_out / poolsize**2 conv_map_size = image_shape[-1] - filter_shape[-1] + 1 assert conv_map_size > 0 pool_map_size = int(conv_map_size / poolsize) assert pool_map_size > 0 self.conv_w = shared( nn_random_paramters(conv_in, conv_out, shape=filter_shape)) self.conv_b = shared( nn_random_paramters(conv_in, conv_out, shape=(filter_shape[0], 1, 1))) self.pool_w = shared( nn_random_paramters(conv_out, pool_out, shape=(filter_shape[0], 1, 1))) self.pool_b = shared( nn_random_paramters(conv_out, pool_out, shape=(filter_shape[0], 1, 1))) self.output_shape = (image_shape[0], filter_shape[0], pool_map_size, pool_map_size) return [self.conv_w, self.conv_b, self.pool_w, self.pool_b]
def _initialize_theta(self): """Return a set value which can be used to initialize weights. Override this function to use other initial value. """ return nn_random_paramters(self.n_in+1, self.n_out)