質問編集履歴

4

変更点を記入

2018/10/01 02:49

投稿

nematoda
nematoda

スコア9

test CHANGED
File without changes
test CHANGED
@@ -190,9 +190,7 @@
190
190
 
191
191
  ### 試したこと
192
192
 
193
- 他のextensions(LogReport,snapshot,PlintReport,ProgressBar)は問題なく動きます。
193
+
194
-
195
- Evaluatorをコメントアウトにした状態の場合,プログラムが動きます
196
194
 
197
195
 
198
196
 

3

質問の変更、コードの一部変更

2018/10/01 02:48

投稿

nematoda
nematoda

スコア9

test CHANGED
@@ -1 +1 @@
1
- ChainerのEvaluator使えない
1
+ Chainer 評価空白
test CHANGED
@@ -2,9 +2,9 @@
2
2
 
3
3
  Chainerを用いて、入力画像を2つのグループに分類するCNNを作ろうと考えています。
4
4
 
5
- そして、作ったモデルを評価するためにextensions.Evaluatorを使うつもりです
5
+ そして、作ったモデルを評価するためにextensionsを使うつもりです
6
-
6
+
7
- しかし、extensions.Evaluatorを使うとエラー出ません、プログラムが動かくなっていまいました
7
+ しかし、extensionsを使っても以下のよに値が表示されるずの箇所空白になっていま
8
8
 
9
9
  原因がわかる方、解決方法がわかる方は是非教えてください
10
10
 
@@ -16,6 +16,32 @@
16
16
 
17
17
  エラーメッセージ
18
18
 
19
+ test:2001
20
+
21
+ 10001
22
+
23
+ epoch main/loss main/accuracy validation/main/loss validation/main/accuracy elapsed_time
24
+
25
+ 1 127.978
26
+
27
+ 2 136.339
28
+
29
+ 3 144.826
30
+
31
+ 4 153.156
32
+
33
+ 5 161.596
34
+
35
+ 6 169.946
36
+
37
+ 7 178.368
38
+
39
+ 8 186.679
40
+
41
+ 9 195.067
42
+
43
+ 10 203.447
44
+
19
45
  ```
20
46
 
21
47
 
@@ -26,19 +52,15 @@
26
52
 
27
53
  ```python
28
54
 
29
- #coding:UTF-8
30
-
31
55
  import os
32
56
 
33
57
  import numpy as np
34
58
 
35
59
  from PIL import Image
36
60
 
37
- np.set_printoptions(threshold=np.inf)
38
-
39
- import math
61
+ import matplotlib
40
-
62
+
41
- import random
63
+ matplotlib.use('Agg')
42
64
 
43
65
  import chainer
44
66
 
@@ -100,10 +122,6 @@
100
122
 
101
123
 
102
124
 
103
-
104
-
105
- chainer.cuda.check_cuda_available()
106
-
107
125
  model = MyChain()
108
126
 
109
127
  optimizer = optimizers.Adam()
@@ -118,19 +136,27 @@
118
136
 
119
137
  model.to_gpu(gpu_device)
120
138
 
121
-
122
-
123
- image_files = 'halfimages.txt'
139
+ image_files = 'millionimages.txt'
124
140
 
125
141
  dataset = chainer.datasets.LabeledImageDataset(image_files)
126
142
 
127
-
143
+ split_at = int(len(dataset) * 0.8)
144
+
128
-
145
+ train,test = chainer.datasets.split_dataset(dataset,split_at)
146
+
147
+
148
+
149
+
150
+
151
+ batchsize = 128
152
+
153
+ train_iter = iterators.SerialIterator(train,batchsize,repeat=True,shuffle=True) #batchsizeを設定
154
+
129
- iterator = iterators.SerialIterator(dataset,50)
155
+ test_iter = iterators.SerialIterator(test,batchsize,repeat=False,shuffle=False)
130
-
156
+
131
- updater = training.StandardUpdater(iterator,optimizer,device=gpu_device)
157
+ updater = training.StandardUpdater(train_iter,optimizer,device=gpu_device)
132
-
158
+
133
- trainer = training.Trainer(updater,(10,'epoch'),out='result_validation')
159
+ trainer = training.Trainer(updater,(10,'epoch'),out='result_validation') #epochを設定
134
160
 
135
161
 
136
162
 
@@ -138,14 +164,14 @@
138
164
 
139
165
  trainer.extend(extensions.snapshot(filename='snapshot_epoch-{.updater.epoch}'))
140
166
 
141
- trainer.extend(extensions.Evaluator(iterator, model,device=gpu_device))
167
+ trainer.extend(extensions.Evaluator(test_iter, model,device=gpu_device))
142
-
143
- trainer.extend(extensions.PlotReport(['main/accuracy', 'val/main/accuracy'], x_key='epoch', file_name='accuracy.png'))
144
-
145
- trainer.extend(extensions.PlotReport(['main/loss', 'validation/main/loss'], file_name='loss.png'))
146
168
 
147
169
  trainer.extend(extensions.PrintReport(['epoch', 'main/loss', 'main/accuracy', 'validation/main/loss', 'validation/main/accuracy', 'elapsed_time']))
148
170
 
171
+ trainer.extend(extensions.PlotReport(['main/accuracy', 'validation/main/accuracy'],x_key='epoch', file_name='accuracy.png'))
172
+
173
+ trainer.extend(extensions.PlotReport(['main/loss', 'validaion/main/loss'],x_key='epoch', file_name='loss.png'))
174
+
149
175
  trainer.extend(extensions.ProgressBar())
150
176
 
151
177
 
@@ -156,6 +182,8 @@
156
182
 
157
183
 
158
184
 
185
+
186
+
159
187
  ```
160
188
 
161
189
 

2

誤字の修正

2018/09/26 08:51

投稿

nematoda
nematoda

スコア9

test CHANGED
File without changes
test CHANGED
File without changes

1

誤字の修正

2018/09/13 08:20

投稿

nematoda
nematoda

スコア9

test CHANGED
File without changes
test CHANGED
@@ -164,7 +164,7 @@
164
164
 
165
165
  他のextensions(LogReport,snapshot,PlintReport,ProgressBar)は問題なく動きます。
166
166
 
167
- Evaluatorをコメントアウトにした状態の場合のみプログラムが動かなくなります
167
+ Evaluatorをコメントアウトにした状態の場合,プログラムが動ます
168
168
 
169
169
 
170
170