Keras意外的关键字参数' dim_ordering'

时间:2017-01-27 10:52:48

标签: python tensorflow keras

我在Keras开发了tensorflow后端。我的程序在两台机器上顺利运行,但第三台机器它给我以下错误消息:

conv1 = Convolution2D(nb_filter=64,nb_col=7,nb_row=7,subsample=(2,2),border_mode='same', init=my_init,)(input)
File "/usr/local/lib/python2.7/dist-packages/keras/engine/topology.py", line 546, in __call__
self.build(input_shapes[0])
File "/usr/local/lib/python2.7/dist-packages/keras/layers/convolutional.py", line 436, in build
constraint=self.W_constraint)
File "/usr/local/lib/python2.7/dist-packages/keras/engine/topology.py", line 418, in add_weight
weight = initializer(shape, name=name)
TypeError: my_init() got an unexpected keyword argument 'dim_ordering'

我将keras和tensorflow更新到最新版本,但错误仍然存​​在。以下是相应的代码段:

def my_init(shape, name=None):
   return kr.initializations.normal(shape, scale=1e-1, name=name)

def build(input_shape, output_shape, use_l2_norm):
   tf.python.control_flow_ops = tf
   input = Input(shape=input_shape)

   conv1 = Convolution2D(nb_filter=64,nb_col=7,nb_row=7,
           subsample=(2,2),border_mode='same', init=my_init)(input)

奇怪的是,从错误信息中可以清楚地看出这一行:

   weight = initializer(shape, name=name) 
在keras / engine / topology.py中的

调用my_init方法,但是没有参数dim_ordering,它传递了my_init方法

BTW keras.json在所有三个机器上都是一样的:

{
"image_dim_ordering": "tf", 
"epsilon": 1e-07, 
"floatx": "float32", 
"backend": "tensorflow"
}

0 个答案:

没有答案