tensorflow - 关于 keras 中的 set_image_dim_ordering ('tf' )

标签 tensorflow keras

在试验 Keras 实现时,我做了如下操作:

from keras import backend as K
K.set_image_dim_ordering('tf') 

它会生成以下错误消息。这是什么意思?我认为 set_image_dim_ordering 包含在 Keras 中。

File "train.py", line 14, in <module>
K.set_image_dim_ordering('tf')

AttributeError: 'module' 对象没有属性 'set_image_dim_ordering'

最佳答案

Keras 是深度学习框架,可以使用“TensorFlow”、“Theano”和“CNTK”作为后端。 每个后端都有自己的偏好来使用 channel 排序

  • Theano: channel 一阶
  • Tensorflow: channel 上次订单
  • CNTK: channel 上次订单

如果您使用“Theano”作为后端,您应该设置“channels_first order”并且在导入 keras 库之后您可以使用这行代码:

keras.backend.set_image_data_format('channels_first')

数据形状如下:( channel ,行,列)。

注意:“数据形状”中的 channel 顺序应等于“后端”中的 channel 顺序。例如,如果您使用 Tensorflow 作为后端,那么您数据的输入形状应该是channel last order(对于 RGB 图像:(行,列,channel ))

关于tensorflow - 关于 keras 中的 set_image_dim_ordering ('tf' ),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40697938/

相关文章:

tensorflow - 训练期间GPU利用率大部分为0%

c++ - 错误 : Invalid options syntax: -//tensorflow:libtensorflow_cc. 所以

python - 如何根据神经网络预测改变pygame中的事件

python - ML : are there any python libraries/examples available for generating the questions and answers from the plain text

python - 如何在 Keras 中使用 ImageDataGenerator 调整标签?

keras - 使用 SageMaker 时使用 Keras 提前停止和回调

python - 在 Tensorflow 中,变量和张量有什么区别?

tensorflow - python3识别 tensorflow ,但不识别它的任何属性

python - 在 keras 中的一组文档上应用共享嵌入层

python - 使用 StandardScalar 和 KerasRegressors 的 make_pipeline