AttributeError: module 'keras.backend' has no attribute 'set_image_dim_ordering'

conda环境中的Keras版本比例子程序中的版本高,因此没有K.image_data_format()这个变量

用 K.image_data_format() == 'channels_first' 替换K.image_dim_ordering() == 'th'成功解决,前面K.image_data_format() == 'channels_first'是相对于低版本的keras,后者是针对高版本的Keras,出现错误时候两者互换都试试应该都可以解决啦。