質問編集履歴
1
調査して分かったことがあったため、タイトル、及び一部説明を修正しています。
title
CHANGED
@@ -1,1 +1,1 @@
|
|
1
|
-
|
1
|
+
KerasとTensorflowのバージョンを変更するとエラーが発生する
|
body
CHANGED
@@ -20,9 +20,7 @@
|
|
20
20
|
from keras.optimizers import Adam
|
21
21
|
|
22
22
|
import matplotlib.pyplot as plt
|
23
|
-
|
24
23
|
import sys
|
25
|
-
|
26
24
|
import numpy as np
|
27
25
|
|
28
26
|
# GANで使う処理をまとめたデータクラス
|
@@ -37,7 +35,6 @@
|
|
37
35
|
|
38
36
|
# 潜在変数の次元数
|
39
37
|
self.z_dim = 100
|
40
|
-
|
41
38
|
optimizer = Adam(0.0002, 0.5)
|
42
39
|
|
43
40
|
# discriminatorモデル
|
@@ -67,7 +64,6 @@
|
|
67
64
|
# Discriminatorへの入力になるため、Discriminatorの入力に次元数を合わせる
|
68
65
|
model.add(Dense(np.prod(self.img_shape), activation='tanh'))
|
69
66
|
model.add(Reshape(self.img_shape))
|
70
|
-
|
71
67
|
model.summary()
|
72
68
|
|
73
69
|
return model
|
@@ -108,7 +104,6 @@
|
|
108
104
|
print('Number of batches:', num_batches)
|
109
105
|
|
110
106
|
for epoch in range(epochs):
|
111
|
-
|
112
107
|
for iteration in range(num_batches):
|
113
108
|
|
114
109
|
# ---------------------
|
@@ -119,7 +114,6 @@
|
|
119
114
|
noise = np.random.normal(0, 1, (half_batch, self.z_dim))
|
120
115
|
gen_imgs = self.generator.predict(noise)
|
121
116
|
|
122
|
-
|
123
117
|
# pickup images (half-batch size) from dataset
|
124
118
|
# 学習用データから、0~60000の乱数を、half_batch数分取得
|
125
119
|
idx = np.random.randint(0, X_train.shape[0], half_batch)
|
@@ -135,7 +129,6 @@
|
|
135
129
|
# average each loss
|
136
130
|
d_loss = 0.5 * np.add(d_loss_real, d_loss_fake)
|
137
131
|
|
138
|
-
|
139
132
|
# ---------------------
|
140
133
|
# Generator learning
|
141
134
|
# ---------------------
|
@@ -151,7 +144,7 @@
|
|
151
144
|
# progress
|
152
145
|
print ("epoch:%d, iter:%d, [D loss: %f, acc.: %.2f%%] [G loss: %f]" % (epoch, iteration, d_loss[0], 100*d_loss[1], g_loss))
|
153
146
|
|
154
|
-
|
147
|
+
# save images
|
155
148
|
if epoch % save_interval == 0:
|
156
149
|
self.save_imgs(epoch)
|
157
150
|
|
@@ -190,5 +183,11 @@
|
|
190
183
|
FailedPreconditionError: Error while reading resource variable _AnonymousVar37 from Container: localhost. This could mean that the variable was uninitialized. Not found: Resource localhost/_AnonymousVar37/N10tensorflow3VarE does not exist.
|
191
184
|
[[node mul_21/ReadVariableOp (defined at /usr/local/lib/python3.6/dist-packages/keras/backend/tensorflow_backend.py:3009) ]] [Op:__inference_keras_scratch_graph_1851]
|
192
185
|
|
193
|
-
|
186
|
+
上記コードは、Kerasのバージョンが2.1.3、Tensorflowがtensorflow-gpu 1.14.0のときはエラーなく動いていたのですが、
|
187
|
+
バージョン変更するとエラーが発生して途中で止まってしまいます。※1
|
194
|
-
エラーの原因、改善方法等分かる方がおられましたら宜しくお願い致します。
|
188
|
+
エラーの原因、改善方法等分かる方がおられましたら宜しくお願い致します。
|
189
|
+
|
190
|
+
※前回質問時からの変更点。
|
191
|
+
・調査して分かったことがあったため、タイトルを「Google Colaboratory上でGANを実行するとFailedPreconditionErrorが発生する」から
|
192
|
+
「KerasとTensorflowのバージョンを変更するとエラーが発生する」に変更しました。
|
193
|
+
・KerasとTensorflowのバージョンによってエラー発生有無が変わることが分かったため、※1部分の説明を修正しました。
|