回答編集履歴
1
Issue の参考コメントを掲載
answer
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
keras 2.3.1 では `keras.backend.image_dim_ordering()` がなく、代わりに `keras.backend.image_data_format()` が使用できるようです。
|
3
3
|
|
4
4
|
そこで以下のように `keras.backend.image_data_format()` を使用すれば該当エラーが解消されるかと思います:
|
5
|
-
```
|
5
|
+
```Python
|
6
6
|
if K.image_data_format() == 'channels_first': # <- ココを変更
|
7
7
|
X_train = X_train.reshape(X_train.shape[0], 1, img_rows, img_cols)
|
8
8
|
X_test = X_test.reshape(X_test.shape[0], 1, img_rows, img_cols)
|
@@ -15,5 +15,27 @@
|
|
15
15
|
|
16
16
|
このことに関しては以下の Issue の一連が多少参考になるかと思います。
|
17
17
|
https://github.com/keras-team/keras/issues/12649
|
18
|
-
関数が返す値の対応関係については、上記 Issue の `TheHugeManatee commented on 7 Apr 2020` をご参考ください
|
18
|
+
関数が返す値の対応関係については、上記 Issue の `TheHugeManatee commented on 7 Apr 2020` をご参考ください:
|
19
|
+
```
|
20
|
+
# TheHugeManatee commented on 7 Apr 2020
|
21
|
+
The way I understand it, with the new API:
|
22
|
+
setting:
|
23
|
+
K.set_image_dim_ordering('tf') --> K.set_image_data_format('channels_last')
|
24
|
+
K.set_image_dim_ordering('th') --> K.set_image_data_format('channels_first')
|
25
|
+
|
26
|
+
checking:
|
27
|
+
K.image_dim_ordering() == 'tf' --> K.image_data_format() == 'channels_last'
|
28
|
+
K.image_dim_ordering() == 'th' --> K.image_data_format() == 'channels_first'
|
29
|
+
|
30
|
+
I'm not very familiar with it so there might be other edge cases.
|
31
|
+
|
32
|
+
[Edited: Corrected the order as per @CarMiranda 's comment below]
|
33
|
+
```
|
34
|
+
|
19
|
-
また、上記 Issue の `aclex commented on 20 Sep 2019` によれば v2.2.4 -> v2.2.5 のタイミングで関数の変更が入ったようです
|
35
|
+
また、上記 Issue の `aclex commented on 20 Sep 2019` によれば v2.2.4 -> v2.2.5 のタイミングで関数の変更が入ったようです:
|
36
|
+
```
|
37
|
+
# aclex commented on 20 Sep 2019
|
38
|
+
From my little version-wise research, this attribute disappears in 2.2.4 -> 2.2.5 version change. So in my case everything still works fine with 2.2.4.
|
39
|
+
|
40
|
+
Thanks everyone for suggestions to fix it!
|
41
|
+
```
|