質問編集履歴
6
訂正
test
CHANGED
File without changes
|
test
CHANGED
@@ -20,10 +20,6 @@
|
|
20
20
|
|
21
21
|
|
22
22
|
|
23
|
-
*指摘を頂いたので質問内容を大きく変更いたしました。以前の質問に答えてくださった方々は申し訳ありません
|
24
|
-
|
25
|
-
|
26
|
-
|
27
23
|
現在の環境
|
28
24
|
|
29
25
|
Ubuntu 16.04
|
5
質問を絞る
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
Convolution2DからConv2Dに書き直したい
|
test
CHANGED
@@ -1,6 +1,26 @@
|
|
1
1
|
初質問です。
|
2
2
|
|
3
3
|
現在古い環境で動かしていた畳込みネットワークの学習用プログラムを新しい環境で動かせるよう苦戦中です。
|
4
|
+
|
5
|
+
|
6
|
+
|
7
|
+
現在Convolution2D
|
8
|
+
|
9
|
+
```python2.7
|
10
|
+
|
11
|
+
conv1a=F.Convolution2D(96, 96, 1, wscale=w)
|
12
|
+
|
13
|
+
```
|
14
|
+
|
15
|
+
の内容をConv2D用に書き直したいです。
|
16
|
+
|
17
|
+
Convolition2D(入力、出力、フィルタ、ストライド、パディング)だと理解しています
|
18
|
+
|
19
|
+
回答がわかる方はご教授願います。
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
*指摘を頂いたので質問内容を大きく変更いたしました。以前の質問に答えてくださった方々は申し訳ありません
|
4
24
|
|
5
25
|
|
6
26
|
|
@@ -19,359 +39,3 @@
|
|
19
39
|
keras 2.0.2
|
20
40
|
|
21
41
|
tensorflow-gpu 1.5.0
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
もとのファイルは
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
```python2.7
|
34
|
-
|
35
|
-
import math
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
import chainer
|
40
|
-
|
41
|
-
import chainer.functions as F
|
42
|
-
|
43
|
-
import numpy as np
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
class NIN(chainer.FunctionSet):
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
insize = 227
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
def __init__(self):
|
58
|
-
|
59
|
-
w = math.sqrt(2) # MSRA scaling
|
60
|
-
|
61
|
-
super(NIN, self).__init__(
|
62
|
-
|
63
|
-
conv1=F.Convolution2D(3, 96, 11, wscale=w, stride=4),
|
64
|
-
|
65
|
-
conv1a=F.Convolution2D(96, 96, 1, wscale=w),
|
66
|
-
|
67
|
-
conv1b=F.Convolution2D(96, 96, 1, wscale=w),
|
68
|
-
|
69
|
-
conv2=F.Convolution2D(96, 256, 5, wscale=w, pad=2),
|
70
|
-
|
71
|
-
conv2a=F.Convolution2D(256, 256, 1, wscale=w),
|
72
|
-
|
73
|
-
conv2b=F.Convolution2D(256, 256, 1, wscale=w),
|
74
|
-
|
75
|
-
conv3=F.Convolution2D(256, 384, 3, wscale=w, pad=1),
|
76
|
-
|
77
|
-
conv3a=F.Convolution2D(384, 384, 1, wscale=w),
|
78
|
-
|
79
|
-
conv3b=F.Convolution2D(384, 384, 1, wscale=w),
|
80
|
-
|
81
|
-
conv4=F.Convolution2D(384, 1024, 3, wscale=w, pad=1),
|
82
|
-
|
83
|
-
conv4a=F.Convolution2D(1024, 1024, 1, wscale=w),
|
84
|
-
|
85
|
-
conv4b=F.Convolution2D(1024, 1000, 1, wscale=w),
|
86
|
-
|
87
|
-
)
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
def forward(self, x_data,y_data,train=True):
|
92
|
-
|
93
|
-
x = chainer.Variable(x_data, volatile=not train)
|
94
|
-
|
95
|
-
t = chainer.Variable(y_data, volatile=not train)
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
h = F.relu(self.conv1(x))
|
100
|
-
|
101
|
-
h = F.relu(self.conv1a(h))
|
102
|
-
|
103
|
-
h = F.relu(self.conv1b(h))
|
104
|
-
|
105
|
-
h = F.max_pooling_2d(h, 3, stride=2)
|
106
|
-
|
107
|
-
h = F.relu(self.conv2(h))
|
108
|
-
|
109
|
-
h = F.relu(self.conv2a(h))
|
110
|
-
|
111
|
-
h = F.relu(self.conv2b(h))
|
112
|
-
|
113
|
-
h = F.max_pooling_2d(h, 3, stride=2)
|
114
|
-
|
115
|
-
h = F.relu(self.conv3(h))
|
116
|
-
|
117
|
-
h = F.relu(self.conv3a(h))
|
118
|
-
|
119
|
-
h = F.relu(self.conv3b(h))
|
120
|
-
|
121
|
-
h = F.max_pooling_2d(h, 3, stride=2)
|
122
|
-
|
123
|
-
h = F.dropout(h, train=train)
|
124
|
-
|
125
|
-
h = F.relu(self.conv4(h))
|
126
|
-
|
127
|
-
h = F.relu(self.conv4a(h))
|
128
|
-
|
129
|
-
h = F.relu(self.conv4b(h))
|
130
|
-
|
131
|
-
h = F.reshape(F.average_pooling_2d(h, 6), (x_data.shape[0], 1000))
|
132
|
-
|
133
|
-
return F.softmax_cross_entropy(h, t), F.accuracy(h, t)
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
def predict(self, x_data):
|
138
|
-
|
139
|
-
x = chainer.Variable(x_data, volatile=True)
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
h = F.relu(self.conv1(x))
|
144
|
-
|
145
|
-
h = F.relu(self.conv1a(h))
|
146
|
-
|
147
|
-
h = F.relu(self.conv1b(h))
|
148
|
-
|
149
|
-
h = F.max_pooling_2d(h, 3, stride=2)
|
150
|
-
|
151
|
-
h = F.relu(self.conv2(h))
|
152
|
-
|
153
|
-
h = F.relu(self.conv2a(h))
|
154
|
-
|
155
|
-
h = F.relu(self.conv2b(h))
|
156
|
-
|
157
|
-
h = F.max_pooling_2d(h, 3, stride=2)
|
158
|
-
|
159
|
-
h = F.relu(self.conv3(h))
|
160
|
-
|
161
|
-
h = F.relu(self.conv3a(h))
|
162
|
-
|
163
|
-
h = F.relu(self.conv3b(h))
|
164
|
-
|
165
|
-
h = F.max_pooling_2d(h, 3, stride=2)
|
166
|
-
|
167
|
-
h = F.dropout(h, train=False)
|
168
|
-
|
169
|
-
h = F.relu(self.conv4(h))
|
170
|
-
|
171
|
-
h = F.relu(self.conv4a(h))
|
172
|
-
|
173
|
-
h = F.relu(self.conv4b(h))
|
174
|
-
|
175
|
-
h = F.reshape(F.average_pooling_2d(h, 6), (x_data.shape[0], 1000))
|
176
|
-
|
177
|
-
return F.softmax(h)
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
```
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
であり色々調べたとことろ
|
188
|
-
|
189
|
-
FunctionSetは現在ではChainが使われている
|
190
|
-
|
191
|
-
wscaleが現在削除されている(代替えはまだ見つけていない)
|
192
|
-
|
193
|
-
Convolutionは古いのでConv2Dとするのがよい
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
とのことで現在は
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
```python2.7
|
202
|
-
|
203
|
-
import math
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
import chainer
|
208
|
-
|
209
|
-
import chainer.functions as F
|
210
|
-
|
211
|
-
import numpy as np
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
class NIN(chainer.Chain):
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
insize = 227
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
def __init__(self):
|
228
|
-
|
229
|
-
w = math.sqrt(2) # MSRA scaling
|
230
|
-
|
231
|
-
super(NIN, self).__init__(
|
232
|
-
|
233
|
-
conv1=F.Conv2D(3, 96, 11, wscale=w, stride=4),
|
234
|
-
|
235
|
-
conv1a=F.Conv2D(96, 96, 1, wscale=w),
|
236
|
-
|
237
|
-
conv1b=F.Conv2D(96, 96, 1, wscale=w),
|
238
|
-
|
239
|
-
conv2=F.Conv2D(96, 256, 5, wscale=w, pad=2),
|
240
|
-
|
241
|
-
conv2a=F.Conv2D(256, 256, 1, wscale=w),
|
242
|
-
|
243
|
-
conv2b=F.Conv2D(256, 256, 1, wscale=w),
|
244
|
-
|
245
|
-
conv3=F.Conv2D(256, 384, 3, wscale=w, pad=1),
|
246
|
-
|
247
|
-
conv3a=F.Conv2D(384, 384, 1, wscale=w),
|
248
|
-
|
249
|
-
conv3b=F.Conv2D(384, 384, 1, wscale=w),
|
250
|
-
|
251
|
-
conv4=F.Conv2D(384, 1024, 3, wscale=w, pad=1),
|
252
|
-
|
253
|
-
conv4a=F.Conv2D(1024, 1024, 1, wscale=w),
|
254
|
-
|
255
|
-
conv4b=F.Conv2D(1024, 1000, 1, wscale=w),
|
256
|
-
|
257
|
-
)
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
def forward(self, x_data,y_data,train=True):
|
262
|
-
|
263
|
-
x = chainer.Variable(x_data, volatile=not train)
|
264
|
-
|
265
|
-
t = chainer.Variable(y_data, volatile=not train)
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
h = F.relu(self.conv1(x))
|
270
|
-
|
271
|
-
h = F.relu(self.conv1a(h))
|
272
|
-
|
273
|
-
h = F.relu(self.conv1b(h))
|
274
|
-
|
275
|
-
h = F.max_pooling_2d(h, 3, stride=2)
|
276
|
-
|
277
|
-
h = F.relu(self.conv2(h))
|
278
|
-
|
279
|
-
h = F.relu(self.conv2a(h))
|
280
|
-
|
281
|
-
h = F.relu(self.conv2b(h))
|
282
|
-
|
283
|
-
h = F.max_pooling_2d(h, 3, stride=2)
|
284
|
-
|
285
|
-
h = F.relu(self.conv3(h))
|
286
|
-
|
287
|
-
h = F.relu(self.conv3a(h))
|
288
|
-
|
289
|
-
h = F.relu(self.conv3b(h))
|
290
|
-
|
291
|
-
h = F.max_pooling_2d(h, 3, stride=2)
|
292
|
-
|
293
|
-
h = F.dropout(h, train=train)
|
294
|
-
|
295
|
-
h = F.relu(self.conv4(h))
|
296
|
-
|
297
|
-
h = F.relu(self.conv4a(h))
|
298
|
-
|
299
|
-
h = F.relu(self.conv4b(h))
|
300
|
-
|
301
|
-
h = F.reshape(F.average_pooling_2d(h, 6), (x_data.shape[0], 1000))
|
302
|
-
|
303
|
-
return F.softmax_cross_entropy(h, t), F.accuracy(h, t)
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
def predict(self, x_data):
|
308
|
-
|
309
|
-
x = chainer.Variable(x_data, volatile=True)
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
h = F.relu(self.conv1(x))
|
314
|
-
|
315
|
-
h = F.relu(self.conv1a(h))
|
316
|
-
|
317
|
-
h = F.relu(self.conv1b(h))
|
318
|
-
|
319
|
-
h = F.max_pooling_2d(h, 3, stride=2)
|
320
|
-
|
321
|
-
h = F.relu(self.conv2(h))
|
322
|
-
|
323
|
-
h = F.relu(self.conv2a(h))
|
324
|
-
|
325
|
-
h = F.relu(self.conv2b(h))
|
326
|
-
|
327
|
-
h = F.max_pooling_2d(h, 3, stride=2)
|
328
|
-
|
329
|
-
h = F.relu(self.conv3(h))
|
330
|
-
|
331
|
-
h = F.relu(self.conv3a(h))
|
332
|
-
|
333
|
-
h = F.relu(self.conv3b(h))
|
334
|
-
|
335
|
-
h = F.max_pooling_2d(h, 3, stride=2)
|
336
|
-
|
337
|
-
h = F.dropout(h, train=False)
|
338
|
-
|
339
|
-
h = F.relu(self.conv4(h))
|
340
|
-
|
341
|
-
h = F.relu(self.conv4a(h))
|
342
|
-
|
343
|
-
h = F.relu(self.conv4b(h))
|
344
|
-
|
345
|
-
h = F.reshape(F.average_pooling_2d(h, 6), (x_data.shape[0], 1000))
|
346
|
-
|
347
|
-
return F.softmax(h)
|
348
|
-
|
349
|
-
```
|
350
|
-
|
351
|
-
エラー内容が
|
352
|
-
|
353
|
-
```
|
354
|
-
|
355
|
-
Traceback (most recent call last):
|
356
|
-
|
357
|
-
File "~/nin.py", line 18, in __init__
|
358
|
-
|
359
|
-
conv1=F.Conv2D(3, 96, 11, wscale=w, stride=4),
|
360
|
-
|
361
|
-
AttributeError: 'module' object has no attribute 'Conv2D'
|
362
|
-
|
363
|
-
```
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
となっており目下のところ
|
368
|
-
|
369
|
-
・wscaleに代わる重み初期値を割り振るもの
|
370
|
-
|
371
|
-
・conv2Dが使えない原因
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
を解決したいです。
|
376
|
-
|
377
|
-
回答や原因がわかる方はご教授願います。
|
4
変更
test
CHANGED
File without changes
|
test
CHANGED
@@ -16,7 +16,7 @@
|
|
16
16
|
|
17
17
|
openCV 2.4.9.1
|
18
18
|
|
19
|
-
keras 2.
|
19
|
+
keras 2.0.2
|
20
20
|
|
21
21
|
tensorflow-gpu 1.5.0
|
22
22
|
|
3
追記
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
古い
|
1
|
+
古いプログラムの記述を書き換えたい
|
test
CHANGED
@@ -16,6 +16,14 @@
|
|
16
16
|
|
17
17
|
openCV 2.4.9.1
|
18
18
|
|
19
|
+
keras 2.3.1
|
20
|
+
|
21
|
+
tensorflow-gpu 1.5.0
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
|
26
|
+
|
19
27
|
|
20
28
|
|
21
29
|
もとのファイルは
|
2
環境を変更
test
CHANGED
File without changes
|
test
CHANGED
@@ -6,15 +6,15 @@
|
|
6
6
|
|
7
7
|
現在の環境
|
8
8
|
|
9
|
-
Ubuntu 1
|
9
|
+
Ubuntu 16.04
|
10
10
|
|
11
11
|
python 2.7*
|
12
12
|
|
13
|
-
Chainer
|
13
|
+
Chainer 6.5.5
|
14
|
-
|
14
|
+
|
15
|
-
CUDA 9.
|
15
|
+
CUDA 9.0
|
16
|
-
|
16
|
+
|
17
|
-
openCV 4.
|
17
|
+
openCV 2.4.9.1
|
18
18
|
|
19
19
|
|
20
20
|
|
1
エラー内容に記述ミス
test
CHANGED
File without changes
|
test
CHANGED
@@ -346,11 +346,9 @@
|
|
346
346
|
|
347
347
|
Traceback (most recent call last):
|
348
348
|
|
349
|
-
|
350
|
-
|
351
349
|
File "~/nin.py", line 18, in __init__
|
352
350
|
|
353
|
-
conv1=F.Conv
|
351
|
+
conv1=F.Conv2D(3, 96, 11, wscale=w, stride=4),
|
354
352
|
|
355
353
|
AttributeError: 'module' object has no attribute 'Conv2D'
|
356
354
|
|