python - keras "image_dim_ordering"配置不起作用

标签 python tensorflow neural-network keras theano

我一直在尝试将 keras 图像暗淡顺序从 tensorflow 顺序更改为 theano 顺序。我修改了 ~/.keras/keras.json 文件,行 "image_dim_ordering": "th" 不起作用,但行 "backend": "theano" 配置正在运行。

{
"floatx": "float32",
"epsilon": 1e-07,
"backend": "theano",
"image_dim_ordering": "th"  
}

当我在程序开头添加 backend.image_dim_ordering('th') 时,权重加载出现了新问题。我确定权重正在使用 theano 后端,并且按“th”顺序。

ValueError: Layer weight shape (3,3,3,64) not compatible with provided weight shape(64,3,3,3)

程序开头没有 backend.image_dim_ordering('th') 的原始错误:

Exception: Layer weight shape (3, 3, 640, 64) not compatible with provided weight shape (64, 3, 3, 3)

我使用的是python 2.7.12,在win7和Ubuntu 16.04系统中都会出现这个问题。

最佳答案

使用set_image_dim_ordering而不是image_dim_ordering。后者只获取数据排序格式,但不设置:

import keras.backend as K
K.set_image_dim_ordering('th')

关于python - keras "image_dim_ordering"配置不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43860033/

相关文章:

machine-learning - 使用 TensorFlow 1.2.1 和 InceptionV3 对图像进行分类

python - 使用 keras v2.0 未学习 XOR

machine-learning - 预训练如何改善神经网络的分类?

python - 将数据帧转换为没有列名的嵌套字典

python - 使用 Selenium Python (NSFW) 从网页中抓取 URL

tensorflow - 组合条件和控制依赖关系

tensorflow - 训练集上对比损失函数的准确性有所提高,但验证准确性变差或没有提高

python - Pandas DataFrame - 删除特定列中与前一行具有相同值的行

python - 为什么其他窗口(GUI)在Python中运行时其他窗口(GUI)没有打开?

TensorFlow:如何使用 TensorHub 模块导出估算器?