conv2d()得到了一个意想不到的关键字参数' border_mode'

时间:2018-01-30 15:32:04

标签: python keras theano lstm

当我尝试使用keras-2.1.3和theano-1.0.1运行此代码时 https://github.com/marcellacornia/sam/blob/master/attentive_convlstm.py

def get_initial_states(self, x):
    initial_state = K.sum(x, axis=1)
    initial_state = K.conv2d(initial_state, K.zeros((self.nb_filters_out, self.nb_filters_in, 1, 1)), border_mode='same')
    initial_states = [initial_state for _ in range(len(self.states))]

    return initial_states

Traceback (most recent call last):
  File "main.py", line 63, in <module>
    m = Model(input=[x, x_maps], output=sam_resnet([x, x_maps]))
  File "E:\sam-master\models.py", line 136, in sam_resnet
    nb_cols=3, nb_rows=3)(att_convlstm)
  File "C:\ProgramData\Anaconda3\lib\site-packages\keras\engine\topology.py", line 617, in __call__
    output = self.call(inputs, **kwargs)
  File "E:\sam-master\attentive_convlstm.py", line 143, in call
    initial_states = self.get_initial_states(x)
  File "E:\sam-master\attentive_convlstm.py", line 42, in get_initial_states
    initial_state = K.conv2d(initial_state, K.zeros((self.nb_filters_out, self.nb_filters_in, 1, 1)), border_mode='same')
TypeError: conv2d() got an unexpected keyword argument 'border_mode'

2 个答案:

答案 0 :(得分:2)

嗯,keras中没有border_mode

padding='valid'padding='same'

请务必检查documentation以正确使用图层和功能。

答案 1 :(得分:2)

作为一个旁注,以防万一仍有问题,这是与Keras1.x向后兼容的问题。 “ border_mode”曾经作为(至少)Keras1.1.0中Convolution2D类的参数而存在,因此在许多较旧的代码中仍然存在。

在Keras2系列(我参考2.3.1)中,您将看到几乎所有到Convolution2D的API都已更改,因此如果您使用旧版的Keras移植存储库,我怀疑border_mode是您最大的担忧。