質問編集履歴
3
エラー文追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -6,7 +6,11 @@
|
|
6
6
|
!pip install keras==2.2.4
|
7
7
|
!pip install tensorflow==1.14.0
|
8
8
|
をインストールする際に下図のエラーが発生していました...
|
9
|
+
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
|
10
|
+
tensorflow 2.7.0 requires keras<2.8,>=2.7.0rc0, but you have keras 2.2.4 which is incompatible.
|
9
11
|
![イメージ説明](https://ddjkaamml8q8x.cloudfront.net/questions/2022-01-28/044d7318-79c3-4e69-95b9-ac4b30d67531.jpeg)
|
12
|
+
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
|
13
|
+
kapre 0.3.7 requires tensorflow>=2.0.0, but you have tensorflow 1.14.0 which is incompatible.
|
10
14
|
![イメージ説明](https://ddjkaamml8q8x.cloudfront.net/questions/2022-01-28/9368e9dc-8f0f-419d-9caa-2c02b411d3ff.jpeg)
|
11
15
|
```main
|
12
16
|
!pip install icrawler
|
2
タグの変更
test
CHANGED
File without changes
|
test
CHANGED
File without changes
|
1
エラー内容の追加
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
Google colabでtensorFlow,keras
|
1
|
+
Google colabでCNNモデル作成時のtensorFlow,kerasバージョン変更の際のエラー
|
test
CHANGED
@@ -1,11 +1,27 @@
|
|
1
1
|
google colabでCNNモデルを作成しようとしているのですがモデルのバージョンを指定せずに(keras2.7.0 tensorflow2.7.0)実行するとエラーを出さずにモデルを作成できるのですが,実装上の関係でkerasは2.24でtensorflowは1.14.0でモデルを作成したいため,それぞれそのバージョンをインストールし,実行すると画像のようなエラーをはいてしまいます.
|
2
2
|
エラーから何を変更すればいいのかわからず困っています.
|
3
3
|
ValueError: Could not interpret optimizer identifier: <tensorflow.python.keras.optimizer_v2.rmsprop.RMSprop object at 0x7fe75d6b5210>
|
4
|
-
|
5
4
|
![イメージ説明](https://ddjkaamml8q8x.cloudfront.net/questions/2022-01-28/3349d3e1-6a35-4570-ad31-7bfda23ed63e.jpeg)
|
6
|
-
|
5
|
+
また,
|
7
6
|
!pip install keras==2.2.4
|
8
7
|
!pip install tensorflow==1.14.0
|
8
|
+
をインストールする際に下図のエラーが発生していました...
|
9
|
+
![イメージ説明](https://ddjkaamml8q8x.cloudfront.net/questions/2022-01-28/044d7318-79c3-4e69-95b9-ac4b30d67531.jpeg)
|
10
|
+
![イメージ説明](https://ddjkaamml8q8x.cloudfront.net/questions/2022-01-28/9368e9dc-8f0f-419d-9caa-2c02b411d3ff.jpeg)
|
11
|
+
```main
|
12
|
+
!pip install icrawler
|
13
|
+
|
14
|
+
from icrawler.builtin import BingImageCrawler
|
15
|
+
|
16
|
+
# 猫の画像を10枚取得
|
17
|
+
crawler = BingImageCrawler(storage={"root_dir": "cat"})
|
18
|
+
crawler.crawl(keyword="猫", max_num=10)
|
19
|
+
|
20
|
+
from icrawler.builtin import BingImageCrawler
|
21
|
+
|
22
|
+
# 犬の画像を10枚取得
|
23
|
+
crawler = BingImageCrawler(storage={"root_dir": "dog"})
|
24
|
+
crawler.crawl(keyword="犬", max_num=10)
|
9
25
|
|
10
26
|
from PIL import Image
|
11
27
|
import os, glob
|
@@ -14,7 +30,7 @@
|
|
14
30
|
# IOError: image file is truncated (0 bytes not processed)回避のため
|
15
31
|
ImageFile.LOAD_TRUNCATED_IMAGES = True
|
16
32
|
|
17
|
-
classes = ["
|
33
|
+
classes = ["dog", "cat"]
|
18
34
|
num_classes = len(classes)
|
19
35
|
image_size = 64
|
20
36
|
num_testdata = 5
|
@@ -73,7 +89,7 @@
|
|
73
89
|
from tensorflow import keras
|
74
90
|
import numpy as np
|
75
91
|
|
76
|
-
classes = ["
|
92
|
+
classes = ["dog", "cat"]
|
77
93
|
num_classes = len(classes)
|
78
94
|
image_size = 64
|
79
95
|
|
@@ -117,7 +133,7 @@
|
|
117
133
|
model.add(Dense(512))
|
118
134
|
model.add(Activation('relu'))
|
119
135
|
model.add(Dropout(0.45))
|
120
|
-
model.add(Dense(
|
136
|
+
model.add(Dense(2))
|
121
137
|
model.add(Activation('softmax'))
|
122
138
|
|
123
139
|
# https://keras.io/ja/optimizers/
|
@@ -143,7 +159,6 @@
|
|
143
159
|
model = train(X_train, y_train, X_test, y_test)
|
144
160
|
|
145
161
|
main()
|
162
|
+
main()
|
146
163
|
```
|
147
|
-
実行する際はこの画像のようにファイルを作って画像を保存してから動かしてください.
|
148
|
-
![イメージ説明](https://ddjkaamml8q8x.cloudfront.net/questions/2022-01-28/b895ce09-5548-40d3-9598-799d40168cb0.jpeg)
|
149
164
|
|