首页 > 其他 > 详细

theano中对图像进行convolution 运算

时间:2016-02-07 02:23:09      阅读:234      评论:0      收藏:0      [点我收藏+]

(1) 定义计算过程中需要的symbolic expression

"""
定义相关的symbolic experssion
"""
# convolution layer的输入,根据theano,它应该是一个4d tensor
input = T.tensor4(name=input)
# 共享权值W,它的shape为2,3,9,9
w_shp = (2,3,9,9)
w_bound = numpy.sqrt(3*9*9)
W = theano.shared(numpy.asarray(rng.uniform(low= -1.0/w_bound, high = 1.0/w_bound,size=w_shp),dtype=input.dtype),name=W)
# 偏执向量b,它的shape为2
b_shp = (2,)
b = theano.shared(numpy.asarray(rng.uniform(low= -.5, high = .5,size=b_shp),dtype=input.dtype),name=b)
# 利用卷积核W对输入进行卷积运算
conv_out = conv.conv2d(input,W)
# 计算sigmoid函数
output = T.nnet.sigmoid(conv_out+b.dimshuffle(x,0,x,x))
# 输入输出function
f = theano.function([input],output)

 

theano中对图像进行convolution 运算

原文:http://www.cnblogs.com/lutingting/p/5184539.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!