![](https://csdnimg.cn/release/download_crawler_static/87176307/bg6.jpg)
范文 范例 指导 学习
29. rng.uniform(low=-W_bound, high=W_bound, size=filter_s
hape),
30. dtype=theano.config.floatX
31. ),
32. borrow=True
33. )
34.
35. # the bias is a 1D tensor -- one bias per output feature map
36. #偏置 b 是一维向量,每个输出图的特征图都对应一个偏置,
37. #而输出的特征图的个数由 filter 个数决定,因此用 filter_shape[0]即
number of filters 来初始化
38. b_values = numpy.zeros((filter_shape[0],), dtype=theano.confi
g.floatX)
39. self.b = theano.shared(value=b_values, borrow=True)
40.
41. #将输入图像与 filter 卷积,conv.conv2d 函数
42. #卷积完没有加 b 再通过 sigmoid,这里是一处简化。
43. conv_out = conv.conv2d(
44. input=input,
45. filters=self.W,
46. filter_shape=filter_shape,
47. image_shape=image_shape
48. )
49.
50. #maxpooling,最大子采样过程
51. pooled_out = downsample.max_pool_2d(
52. input=conv_out,
53. ds=poolsize,
54. ignore_border=True
55. )
56.
57. #加偏置,再通过 tanh 映射,得到卷积+子采样层的最终输出
58. #因为 b 是一维向量,这里用维度转换函数 dimshuffle 将其 reshape。比如 b 是
(10,),
59. #则 b.dimshuffle('x', 0, 'x', 'x')) 将其 reshape 为(1,10,1,1)
word 版本整理分享