错误AttributeError: module ‘keras.backend‘ has no attribute ‘image_dim_ordering‘

运行语句if K.image_dim_ordering() == ‘tf’: 出现错误AttributeError: module ‘keras.backend’ has no attribute ‘image_dim_ordering’

原因是keras版本的原因,在新版本中把 image_dim_ordering更改为image_data_format,所以要使用

K.image_data_format() == 'channel_last'
K.image_data_format() == 'channel_first'

替代

K.image_dim_ordering() == 'tf'
K.image_dim_ordering() == 'th'

注意’tf’、‘th’和’channel_last’、'channel_first’的对应关系。

猜你喜欢

转载自blog.csdn.net/weixin_41963310/article/details/109412169
今日推荐