【发布时间】:2018-05-16 00:43:51
【问题描述】:
我试图查看我的数据在通过 Keras 模型中的卷积层后的样子。我正在使用 Theano 后端。我的代码是从 Keras Github 拼凑而成的:
def get_layer0_outputs(model, test_data):
output = model.layers[0].output
inputs = [K.learning_phase()] + model.inputs
func = K.function(inputs, [output])
return func([0] + [test_data])
我在这里要做的是为我的网络中的第一层(Conv2D 层)编译一个函数。 test_data 参数是 np.ndarray。我的模型已正确加载,并且我已经对其进行了相当准确的训练。
但是,当我调用这个函数时,我得到一个神秘的堆栈跟踪:
Traceback (most recent call last):
File "/usr/local/lib/python3.5/dist-packages/theano/compile/function_module.py", line 884, in __call__
self.fn() if output_subset is None else\
File "/usr/local/lib/python3.5/dist-packages/theano/gof/op.py", line 872, in rval
r = p(n, [x[0] for x in i], o)
File "/usr/local/lib/python3.5/dist-packages/theano/tensor/nnet/abstract_conv.py", line 1626, in perform
conv_out = self.conv(img, kern, mode="valid", dilation=self.filter_dilation)
File "/usr/local/lib/python3.5/dist-packages/theano/tensor/nnet/abstract_conv.py", line 1531, in conv
dilated_kern[n, im0, ...],
IndexError: index 1 is out of bounds for axis 1 with size 1
这是什么意思?我是否错误地调用了我的函数?
【问题讨论】: