質問編集履歴
4
変更点を記入
title
CHANGED
File without changes
|
body
CHANGED
@@ -94,9 +94,8 @@
|
|
94
94
|
```
|
95
95
|
|
96
96
|
### 試したこと
|
97
|
-
他のextensions(LogReport,snapshot,PlintReport,ProgressBar)は問題なく動きます。
|
98
|
-
Evaluatorをコメントアウトにした状態の場合,プログラムが動きます
|
99
97
|
|
98
|
+
|
100
99
|
### 補足情報(FW/ツールのバージョンなど)
|
101
100
|
Python 2.7.12
|
102
101
|
chainer 4.1.0
|
3
質問の変更、コードの一部変更
title
CHANGED
@@ -1,1 +1,1 @@
|
|
1
|
-
Chainerの
|
1
|
+
Chainer 評価の欄が空白
|
body
CHANGED
@@ -1,24 +1,35 @@
|
|
1
1
|
### 前提・実現したいこと
|
2
2
|
Chainerを用いて、入力画像を2つのグループに分類するCNNを作ろうと考えています。
|
3
|
-
そして、作ったモデルを評価するためにextensions
|
3
|
+
そして、作ったモデルを評価するためにextensionsを使うつもりです
|
4
|
-
しかし、extensions
|
4
|
+
しかし、extensionsを使っても以下のように値が表示されるはずの箇所が空白になっています。
|
5
5
|
原因がわかる方、解決方法がわかる方は是非教えてください
|
6
6
|
### 発生している問題・エラーメッセージ
|
7
7
|
|
8
8
|
```
|
9
9
|
エラーメッセージ
|
10
|
+
test:2001
|
11
|
+
10001
|
12
|
+
epoch main/loss main/accuracy validation/main/loss validation/main/accuracy elapsed_time
|
13
|
+
1 127.978
|
14
|
+
2 136.339
|
15
|
+
3 144.826
|
16
|
+
4 153.156
|
17
|
+
5 161.596
|
18
|
+
6 169.946
|
19
|
+
7 178.368
|
20
|
+
8 186.679
|
21
|
+
9 195.067
|
22
|
+
10 203.447
|
10
23
|
```
|
11
24
|
|
12
25
|
### 該当のソースコード
|
13
26
|
|
14
27
|
```python
|
15
|
-
#coding:UTF-8
|
16
28
|
import os
|
17
29
|
import numpy as np
|
18
30
|
from PIL import Image
|
19
|
-
np.set_printoptions(threshold=np.inf)
|
20
|
-
import
|
31
|
+
import matplotlib
|
21
|
-
|
32
|
+
matplotlib.use('Agg')
|
22
33
|
import chainer
|
23
34
|
from chainer import cuda,Function,report,training,utils,Variable
|
24
35
|
from chainer import datasets,iterators,optimizers,serializers,cuda
|
@@ -49,8 +60,6 @@
|
|
49
60
|
h4 = F.relu(self.l1(h3))
|
50
61
|
return self.l2(h4)
|
51
62
|
|
52
|
-
|
53
|
-
chainer.cuda.check_cuda_available()
|
54
63
|
model = MyChain()
|
55
64
|
optimizer = optimizers.Adam()
|
56
65
|
optimizer.setup(model)
|
@@ -58,25 +67,30 @@
|
|
58
67
|
gpu_device = 0
|
59
68
|
chainer.cuda.get_device(gpu_device).use()
|
60
69
|
model.to_gpu(gpu_device)
|
61
|
-
|
62
|
-
image_files = '
|
70
|
+
image_files = 'millionimages.txt'
|
63
71
|
dataset = chainer.datasets.LabeledImageDataset(image_files)
|
72
|
+
split_at = int(len(dataset) * 0.8)
|
73
|
+
train,test = chainer.datasets.split_dataset(dataset,split_at)
|
64
74
|
|
65
|
-
iterator = iterators.SerialIterator(dataset,50)
|
66
|
-
updater = training.StandardUpdater(iterator,optimizer,device=gpu_device)
|
67
|
-
trainer = training.Trainer(updater,(10,'epoch'),out='result_validation')
|
68
75
|
|
76
|
+
batchsize = 128
|
77
|
+
train_iter = iterators.SerialIterator(train,batchsize,repeat=True,shuffle=True) #batchsizeを設定
|
78
|
+
test_iter = iterators.SerialIterator(test,batchsize,repeat=False,shuffle=False)
|
79
|
+
updater = training.StandardUpdater(train_iter,optimizer,device=gpu_device)
|
80
|
+
trainer = training.Trainer(updater,(10,'epoch'),out='result_validation') #epochを設定
|
81
|
+
|
69
82
|
trainer.extend(extensions.LogReport())
|
70
83
|
trainer.extend(extensions.snapshot(filename='snapshot_epoch-{.updater.epoch}'))
|
71
|
-
trainer.extend(extensions.Evaluator(
|
84
|
+
trainer.extend(extensions.Evaluator(test_iter, model,device=gpu_device))
|
72
|
-
trainer.extend(extensions.PlotReport(['main/accuracy', 'val/main/accuracy'], x_key='epoch', file_name='accuracy.png'))
|
73
|
-
trainer.extend(extensions.PlotReport(['main/loss', 'validation/main/loss'], file_name='loss.png'))
|
74
85
|
trainer.extend(extensions.PrintReport(['epoch', 'main/loss', 'main/accuracy', 'validation/main/loss', 'validation/main/accuracy', 'elapsed_time']))
|
86
|
+
trainer.extend(extensions.PlotReport(['main/accuracy', 'validation/main/accuracy'],x_key='epoch', file_name='accuracy.png'))
|
87
|
+
trainer.extend(extensions.PlotReport(['main/loss', 'validaion/main/loss'],x_key='epoch', file_name='loss.png'))
|
75
88
|
trainer.extend(extensions.ProgressBar())
|
76
89
|
|
77
90
|
trainer.run()
|
78
91
|
|
79
92
|
|
93
|
+
|
80
94
|
```
|
81
95
|
|
82
96
|
### 試したこと
|
2
誤字の修正
title
CHANGED
File without changes
|
body
CHANGED
File without changes
|
1
誤字の修正
title
CHANGED
File without changes
|
body
CHANGED
@@ -81,7 +81,7 @@
|
|
81
81
|
|
82
82
|
### 試したこと
|
83
83
|
他のextensions(LogReport,snapshot,PlintReport,ProgressBar)は問題なく動きます。
|
84
|
-
Evaluatorをコメントアウトにした状態の場合
|
84
|
+
Evaluatorをコメントアウトにした状態の場合,プログラムが動きます
|
85
85
|
|
86
86
|
### 補足情報(FW/ツールのバージョンなど)
|
87
87
|
Python 2.7.12
|