2017-05-09 99 views
1

我一直在試圖將keras圖像暗淡爲了從tensorflow爲了theano順序改變。我修改~/.keras/keras.json文件,該行"image_dim_ordering": "th"不工作,但行"backend": "theano"配置工作。keras「image_dim_ordering」配置不工作

{ 
"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系統。

+2

您使用的是Keras 2.0 API嗎?如果是,則'image_dim_ordering'被'image_data_format'替代。見[這裏](https://keras.io/backend/)。 –

+0

謝謝,這有助於很多。 – patric

+0

這是否解決了您的問題? –

回答

1

使用set_image_dim_ordering,而不是image_dim_ordering。後者僅獲取數據排序格式,但未設置它:

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

感謝您的建議,我在詢問時複製了錯誤的代碼,對不起。 – patric

+0

你的腳本現在工作嗎?如果是這樣,請接受我的回答 –