def __init__(self, rng, input, image_shape, filter_shape, poolsize=(2, 2)):
# ???????????????????
assert image_shape[1] == filter_shape[1]
fan_in = np.prod(filter_shape[1:])
fan_out = filter_shape[0] * np.prod(filter_shape[2:]) / np.prod(poolsize)
W_bound = np.sqrt(6.0 / (fan_in + fan_out))
self.W = theano.shared(
np.asarray(rng.uniform(low=-W_bound, high=W_bound, size=filter_shape),
dtype=theano.config.floatX), # @UndefinedVariable
borrow=True)
b_values = np.zeros((filter_shape[0],), dtype=theano.config.floatX) # @UndefinedVariable
self.b = theano.shared(value=b_values, borrow=T)
# ??????????????????
conv_out = conv.conv2d(
input=input,
filters=self.W,
filter_shape=filter_shape,
image_shape=image_shape)
# Max-pooling????????????????????
pooled_out = downsample.max_pool_2d(
input=conv_out,
ds=poolsize,
ignore_border=True)
# ????????
self.output = T.tanh(pooled_out + self.b.dimshuffle('x', 0, 'x', 'x'))
self.params = [self.W, self.b]
评论列表
文章目录