def __init__(self, rng, filter_shape, input_shape, scale=1.0):
self.filter_shape = filter_shape
self.input_shape = input_shape
self.output_shape = (input_shape[0], filter_shape[0], input_shape[2], input_shape[3])
self.input_units = np.prod(self.input_shape)
self.output_units = np.prod(self.output_shape)
self.theano_rng = RandomStreams(rng.randint(2 ** 30))
fan_in = np.prod(filter_shape[1:])
fan_out = filter_shape[0] * np.prod(filter_shape[2:])
W_bound = scale * np.sqrt(6. / (fan_in + fan_out))
W = np.asarray(
rng.uniform(low=-W_bound, high=W_bound, size=filter_shape),
dtype=theano.config.floatX)
b = np.zeros((filter_shape[0],), dtype=theano.config.floatX)
self.W = theano.shared(value=W, borrow=True)
self.b = theano.shared(value=b, borrow=True)
self.params = [self.W, self.b]
评论列表
文章目录