Keras Convolution3D 子样本错误

Posted

技术标签:

【中文标题】Keras Convolution3D 子样本错误【英文标题】:Keras Convolution3D subsample error 【发布时间】:2017-07-01 22:04:18 【问题描述】:

我试图使用 keras 构建一个 3D 卷积层。它工作正常,但是当我添加一个子样本参数时它崩溃了。代码:

l_1 = Convolution3D(2, 10,10,10,
    border_mode='same', 
    name = 'l_1',
    activation='relu',
    subsample = (5,5,5)
    )(inputs)

错误是:

Traceback (most recent call last):
  File "image_proc_09.py", line 244, in <module>
    )(inputs)
  File "/usr/local/lib/python2.7/dist-packages/keras/engine/topology.py", line 572, in __call__
    self.add_inbound_node(inbound_layers, node_indices, tensor_indices)
  File "/usr/local/lib/python2.7/dist-packages/keras/engine/topology.py", line 635, in add_inbound_node
    Node.create_node(self, inbound_layers, node_indices, tensor_indices)
  File "/usr/local/lib/python2.7/dist-packages/keras/engine/topology.py", line 166, in create_node
    output_tensors = to_list(outbound_layer.call(input_tensors[0], mask=input_masks[0]))
  File "/usr/local/lib/python2.7/dist-packages/keras/layers/convolutional.py", line 1234, in call
    filter_shape=self.W_shape)
  File "/usr/local/lib/python2.7/dist-packages/keras/backend/theano_backend.py", line 1627, in conv3d
    dim_ordering, volume_shape, filter_shape)
  File "/usr/local/lib/python2.7/dist-packages/keras/backend/theano_backend.py", line 1686, in _old_theano_conv3d
    assert(strides == (1, 1, 1))
AssertionError

我正在使用 theano 0.8.2。

谢谢

【问题讨论】:

【参考方案1】:

您不能将subsample 参数与border_mode='same' 一起使用。使用'valid''full'

查看line of code where the assertion error happens

【讨论】:

以上是关于Keras Convolution3D 子样本错误的主要内容,如果未能解决你的问题,请参考以下文章

使用 Keras Tuner RandomSearch 错误进行超参数调优

如何在 Keras 模型中训练和验证样本较小时测量过拟合

具有两种不同输入样本大小的 Keras 多任务学习

混淆矩阵值错误:找到样本数量不一致的输入变量:[3, 360]

Keras 的 predict_generator 未返回正确数量的样本

Keras 警告:Epoch 包含的样本不止 `samples_per_epoch`