计算2维卷积:
import theano.tensor as T
inputs = T.tensor4(name='input', dtype='float64')
conv_out = T.nnet.conv.conv2d(inputs, [[[[1., 0.]],[[0., 1.]]]])
f = theano.function([inputs], conv_out)
n = np.asarray([[[[1., 1., 2., 2., 4., 4.]],
[[2., 2., 4., 4., 3., 3.]]]], dtype='float64')
fn = f(n)
print n.shape
print fn
print fn.shape
输出:
(1, 2, 1, 6)
[[[[ 3. 4. 6. 8. 7.]]]]
(1, 1, 1, 5)