我一直在尝试将 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/