在尝试 Theano 的 'pool_2d' 方法时,我收到错误“维数错误:预期为 4,形状为 (16, ) 的为 1”。代码如下。
from theano import tensor, shared, function
from theano.tensor.signal.pool import pool_2d
import numpy
class Test:
def __init__(self):
i = tensor.dtensor4()
o = pool_2d(input = i, ws = (2, 2), ignore_border = True, stride = None, pad = (0, 0), mode = 'max')
self.pool = function([i], o)
def pool(self, iput):
iput = numpy.array(iput)
iput.shape = (1, 1, 4, 4)
print(self.pool(iput))
x = Test()
x.pool([1.,2.,3.,4.,5.,6.,7.,8.,9.,10.,11.,12.,13.,14.,15.,16.])
这里错误的原因是什么?