“IndexError:元组索引超出范围”使用keras后端以直接的方式

时间:2017-12-25 11:42:07

标签: keras convolution

我只是试着用自定义张量的形状(1,18,18,1)对张量进行卷积

kernel_x = K.variable([[-1, -2, -1], [0, 0, 0], [1, 2, 1]])

我用这个:

y_true_boundary_x = K.conv2d(y_true, kernel_x, strides=(1,1), padding="same", data_format="channels_last", dilation_rate=(1, 1))

它引发了错误:

---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
<ipython-input-43-669f14bb3bdc> in <module>()
----> 1 y_true_boundary_x = K.conv2d(y_true, kernel_x, strides=(1,1),     padding="same", data_format="channels_last", dilation_rate=(1, 1))

/anaconda/lib/python3.6/site-packages/keras/backend/theano_backend.py in conv2d(x, kernel, strides, padding, data_format, dilation_rate)
   1899         # Will only work if `kernel` is a shared variable.
   1900         kernel_shape = kernel.eval().shape
-> 1901     kernel_shape = _preprocess_conv2d_filter_shape(kernel_shape, data_format)
   1902 
   1903     x = _preprocess_conv2d_input(x, data_format)

/anaconda/lib/python3.6/site-packages/keras/backend/theano_backend.py in _preprocess_conv2d_filter_shape(filter_shape, data_format)
   1761             return None
   1762     if filter_shape:
-> 1763         filter_shape = (filter_shape[3], filter_shape[2],
   1764                         filter_shape[0], filter_shape[1])
   1765     if filter_shape is not None:

IndexError: tuple index out of range

0 个答案:

没有答案