回答編集履歴
2
初期化を追加
answer
CHANGED
@@ -7,6 +7,8 @@
|
|
7
7
|
`train_accuracy += sess.run(acc, feed_dict={`
|
8
8
|
に修正してはいかがでしょうか
|
9
9
|
|
10
|
+
あとはこれをしようとすると、`train_accuracy`を初期化しないといけませんね。
|
11
|
+
|
10
12
|
**■テスト精度**
|
11
13
|
上のやり方でうまくいくようなら、`train_accuracy `関係のコードをコピペして、trainという文字列をtestに置換して動かせばうまくいきそうです。
|
12
14
|
|
@@ -18,6 +20,7 @@
|
|
18
20
|
for step in range(FLAGS.max_steps):
|
19
21
|
# 訓練
|
20
22
|
#############################################
|
23
|
+
train_accuracy = 0
|
21
24
|
for i in range(int(len(train_image)/FLAGS.batch_size)):
|
22
25
|
# batch_size分の画像に対して訓練の実行
|
23
26
|
batch = FLAGS.batch_size*i
|
@@ -48,6 +51,7 @@
|
|
48
51
|
# テスト
|
49
52
|
#############################################
|
50
53
|
# テストデータに対する精度を表示
|
54
|
+
test_accuracy= 0
|
51
55
|
for i in range(int(len(test_image)/FLAGS.batch_size)):
|
52
56
|
# batch_size分の画像に対して訓練の実行
|
53
57
|
batch = FLAGS.batch_size*i
|
1
コード中のコメント修正
answer
CHANGED
@@ -26,16 +26,18 @@
|
|
26
26
|
images_placeholder: train_image[batch:batch+FLAGS.batch_size],
|
27
27
|
labels_placeholder: train_label[batch:batch+FLAGS.batch_size],
|
28
28
|
keep_prob: 0.5})
|
29
|
+
|
29
|
-
|
30
|
+
# 1 batch終わるたびにデータを追加する
|
30
31
|
train_accuracy += sess.run(acc, feed_dict={
|
31
32
|
images_placeholder: train_image,
|
32
33
|
labels_placeholder: train_label,
|
33
34
|
keep_prob: 1.0})
|
35
|
+
|
36
|
+
# 1 step毎にデータを表示する
|
34
37
|
print("step %d, training accuracy %g" %(step, train_accuracy))
|
35
38
|
|
36
39
|
# TensorBoard
|
37
40
|
#############################################
|
38
|
-
|
39
41
|
# 1 step終わるたびにTensorBoardに表示する値を追加する
|
40
42
|
summary_str = sess.run(summary_op, feed_dict={
|
41
43
|
images_placeholder: train_image,
|
@@ -54,11 +56,14 @@
|
|
54
56
|
images_placeholder: test_image[batch:batch+FLAGS.batch_size],
|
55
57
|
labels_placeholder: test_label[batch:batch+FLAGS.batch_size],
|
56
58
|
keep_prob: 0.5})
|
59
|
+
|
57
|
-
|
60
|
+
# 1 batch終わるたびにデータを追加する
|
58
61
|
test_accuracy += sess.run(acc, feed_dict={
|
59
62
|
images_placeholder: test_image,
|
60
63
|
labels_placeholder: test_label,
|
61
64
|
keep_prob: 1.0})
|
65
|
+
|
66
|
+
# 1 step毎にデータを表示する
|
62
67
|
print("step %d, testing accuracy %g" %(step, test_accuracy))
|
63
68
|
|
64
69
|
```
|