1
1
{
2
2
"metadata" : {
3
- "language" : " lua" ,
4
- "name" : " " ,
5
- "signature" : " sha256:09d55f40fef1e7c13f11a514fe6a93ec9de3c599d77c239d25bbe6ecf5de96fa"
3
+ "kernelspec" : {
4
+ "display_name" : " iTorch" ,
5
+ "language" : " lua" ,
6
+ "name" : " itorch"
7
+ },
8
+ "language_info" : {
9
+ "name" : " lua" ,
10
+ "version" : " 20100"
11
+ },
12
+ "name" : " "
6
13
},
7
14
"nbformat" : 3 ,
8
15
"nbformat_minor" : 0 ,
21
28
" \n " ,
22
29
" -- Loads the mapping from net outputs to human readable labels\n " ,
23
30
" function load_synset()\n " ,
24
- " local file = io.open '7_imagenet_classification/synset_words.txt'\n " ,
25
31
" local list = {}\n " ,
26
- " while true do\n " ,
27
- " local line = file:read()\n " ,
28
- " if not line then break end\n " ,
32
+ " for line in io.lines'7_imagenet_classification/synset_words.txt' do\n " ,
29
33
" table.insert(list, string.sub(line,11))\n " ,
30
34
" end\n " ,
31
35
" return list\n " ,
37
41
" -- rescale the image\n " ,
38
42
" local im3 = image.scale(im,224,224,'bilinear')*255\n " ,
39
43
" -- RGB2BGR\n " ,
40
- " local im4 = im3:clone()\n " ,
41
- " im4[{1,{},{}}] = im3[{3,{},{}}]\n " ,
42
- " im4[{3,{},{}}] = im3[{1,{},{}}]\n " ,
43
- " \n " ,
44
+ " local im4 = im3:index(1,torch.LongTensor{3,2,1})\n " ,
44
45
" -- subtract imagenet mean\n " ,
45
46
" return im4 - image.scale(img_mean, 224, 224, 'bilinear')\n " ,
46
47
" end"
47
48
],
48
49
"language" : " python" ,
49
50
"metadata" : {},
50
51
"outputs" : [],
51
- "prompt_number" : 1
52
+ "prompt_number" : 16
52
53
},
53
54
{
54
55
"cell_type" : " code" ,
73
74
" \n " ,
74
75
" print '==> Loading network'\n " ,
75
76
" -- Using network in network http://openreview.net/document/9b05a3bb-3a5e-49cb-91f7-0f482af65aea\n " ,
76
- " net = loadcaffe.load(proto_name, './nin_imagenet.caffemodel'):cuda()\n " ,
77
- " net.modules[#net.modules] = nil -- remove the top softmax\n " ,
77
+ " net = loadcaffe.load(proto_name, './nin_imagenet.caffemodel')\n " ,
78
78
" \n " ,
79
79
" -- as we want to classify, let's disable dropouts by enabling evaluation mode\n " ,
80
80
" net:evaluate()"
85
85
{
86
86
"metadata" : {},
87
87
"output_type" : " pyout" ,
88
- "prompt_number" : 2 ,
88
+ "prompt_number" : 3 ,
89
89
"text" : [
90
90
" ==> Loading network\t\n "
91
91
]
92
92
},
93
93
{
94
94
"metadata" : {},
95
95
"output_type" : " pyout" ,
96
- "prompt_number" : 2 ,
96
+ "prompt_number" : 3 ,
97
97
"text" : [
98
98
" Successfully loaded ./nin_imagenet.caffemodel\n "
99
99
]
100
100
},
101
101
{
102
102
"metadata" : {},
103
103
"output_type" : " pyout" ,
104
- "prompt_number" : 2 ,
104
+ "prompt_number" : 3 ,
105
105
"text" : [
106
106
" MODULE data UNDEFINED\n " ,
107
- " module 'data' not found\n "
108
- ]
109
- },
110
- {
111
- "metadata" : {},
112
- "output_type" : " pyout" ,
113
- "prompt_number" : 2 ,
114
- "text" : [
115
- " conv1: 96 3 11 11\n "
107
+ " warning: module 'data [type 5]' not found\n "
116
108
]
117
109
},
118
110
{
119
111
"metadata" : {},
120
112
"output_type" : " pyout" ,
121
- "prompt_number" : 2 ,
113
+ "prompt_number" : 3 ,
122
114
"text" : [
115
+ " conv1: 96 3 11 11\n " ,
123
116
" cccp1: 96 96 1 1\n " ,
124
- " cccp2: 96 96 1 1\n "
125
- ]
126
- },
127
- {
128
- "metadata" : {},
129
- "output_type" : " pyout" ,
130
- "prompt_number" : 2 ,
131
- "text" : [
117
+ " cccp2: 96 96 1 1\n " ,
132
118
" conv2: 256 96 5 5\n "
133
119
]
134
120
},
135
121
{
136
122
"metadata" : {},
137
123
"output_type" : " pyout" ,
138
- "prompt_number" : 2 ,
139
- "text" : [
140
- " cccp3: 256 256 1 1\n "
141
- ]
142
- },
143
- {
144
- "metadata" : {},
145
- "output_type" : " pyout" ,
146
- "prompt_number" : 2 ,
147
- "text" : [
148
- " cccp4: 256 256 1 1\n "
149
- ]
150
- },
151
- {
152
- "metadata" : {},
153
- "output_type" : " pyout" ,
154
- "prompt_number" : 2 ,
124
+ "prompt_number" : 3 ,
155
125
"text" : [
126
+ " cccp3: 256 256 1 1\n " ,
127
+ " cccp4: 256 256 1 1\n " ,
156
128
" conv3: 384 256 3 3\n "
157
129
]
158
130
},
159
131
{
160
132
"metadata" : {},
161
133
"output_type" : " pyout" ,
162
- "prompt_number" : 2 ,
163
- "text" : [
164
- " cccp5: 384 384 1 1\n "
165
- ]
166
- },
167
- {
168
- "metadata" : {},
169
- "output_type" : " pyout" ,
170
- "prompt_number" : 2 ,
134
+ "prompt_number" : 3 ,
171
135
"text" : [
136
+ " cccp5: 384 384 1 1\n " ,
172
137
" cccp6: 384 384 1 1\n "
173
138
]
174
139
},
175
140
{
176
141
"metadata" : {},
177
142
"output_type" : " pyout" ,
178
- "prompt_number" : 2 ,
143
+ "prompt_number" : 3 ,
179
144
"text" : [
180
145
" conv4-1024: 1024 384 3 3\n "
181
146
]
182
147
},
183
148
{
184
149
"metadata" : {},
185
150
"output_type" : " pyout" ,
186
- "prompt_number" : 2 ,
151
+ "prompt_number" : 3 ,
187
152
"text" : [
188
153
" cccp7-1024: 1024 1024 1 1\n "
189
154
]
190
155
},
191
156
{
192
157
"metadata" : {},
193
158
"output_type" : " pyout" ,
194
- "prompt_number" : 2 ,
159
+ "prompt_number" : 3 ,
195
160
"text" : [
196
161
" cccp8-1024: 1000 1024 1 1\n "
197
162
]
198
163
}
199
164
],
200
- "prompt_number" : 2
165
+ "prompt_number" : 3
201
166
},
202
167
{
203
168
"cell_type" : " code" ,
204
169
"collapsed" : false ,
205
170
"input" : [
206
- " -- print net structure: \n " ,
171
+ " -- print net structure\n " ,
207
172
" print(tostring(net))\n " ,
208
173
" \n " ,
209
174
" -- visualize the weights of conv1\n " ,
210
- " itorch.image(net:get(1).weight:reshape(96,3,11,11) )"
175
+ " itorch.image(net:get(1).weight)"
211
176
],
212
177
"language" : " python" ,
213
178
"metadata" : {},
214
179
"outputs" : [
215
180
{
216
181
"metadata" : {},
217
182
"output_type" : " pyout" ,
218
- "prompt_number" : 3 ,
183
+ "prompt_number" : 6 ,
219
184
"text" : [
220
185
" nn.Sequential {\n " ,
221
- " [input -> (1) -> (2) -> (3) -> (4) -> (5) -> (6) -> (7) -> (8) -> (9) -> (10) -> (11) -> (12) -> (13) -> (14) -> (15) -> (16) -> (17) -> (18) -> (19) -> (20) -> (21) -> (22) -> (23) -> (24) -> (25) -> (26) -> (27) -> (28) -> (29) -> output]\n " ,
222
- " (1): nn.SpatialConvolutionMM (3 -> 96, 11x11, 4,4)\n " ,
186
+ " [input -> (1) -> (2) -> (3) -> (4) -> (5) -> (6) -> (7) -> (8) -> (9) -> (10) -> (11) -> (12) -> (13) -> (14) -> (15) -> (16) -> (17) -> (18) -> (19) -> (20) -> (21) -> (22) -> (23) -> (24) -> (25) -> (26) -> (27) -> (28) -> (29) -> (30) -> output]\n " ,
187
+ " (1): nn.SpatialConvolution (3 -> 96, 11x11, 4,4)\n " ,
223
188
" (2): nn.ReLU\n " ,
224
- " (3): nn.SpatialConvolutionMM (96 -> 96, 1x1)\n " ,
189
+ " (3): nn.SpatialConvolution (96 -> 96, 1x1)\n " ,
225
190
" (4): nn.ReLU\n " ,
226
- " (5): nn.SpatialConvolutionMM (96 -> 96, 1x1)\n " ,
191
+ " (5): nn.SpatialConvolution (96 -> 96, 1x1)\n " ,
227
192
" (6): nn.ReLU\n " ,
228
- " (7): inn .SpatialMaxPooling(3,3,2,2)\n " ,
229
- " (8): nn.SpatialConvolutionMM (96 -> 256, 5x5, 2,2)\n " ,
193
+ " (7): nn .SpatialMaxPooling(3,3,2,2)\n " ,
194
+ " (8): nn.SpatialConvolution (96 -> 256, 5x5, 1,1 , 2,2)\n " ,
230
195
" (9): nn.ReLU\n " ,
231
- " (10): nn.SpatialConvolutionMM (256 -> 256, 1x1)\n " ,
196
+ " (10): nn.SpatialConvolution (256 -> 256, 1x1)\n " ,
232
197
" (11): nn.ReLU\n " ,
233
- " (12): nn.SpatialConvolutionMM (256 -> 256, 1x1)\n " ,
198
+ " (12): nn.SpatialConvolution (256 -> 256, 1x1)\n " ,
234
199
" (13): nn.ReLU\n " ,
235
- " (14): inn .SpatialMaxPooling(3,3,2,2)\n " ,
236
- " (15): nn.SpatialConvolutionMM (256 -> 384, 3x3, 1,1)\n " ,
200
+ " (14): nn .SpatialMaxPooling(3,3,2,2)\n " ,
201
+ " (15): nn.SpatialConvolution (256 -> 384, 3x3, 1,1 , 1,1)\n " ,
237
202
" (16): nn.ReLU\n " ,
238
- " (17): nn.SpatialConvolutionMM (384 -> 384, 1x1)\n " ,
203
+ " (17): nn.SpatialConvolution (384 -> 384, 1x1)\n " ,
239
204
" (18): nn.ReLU\n " ,
240
- " (19): nn.SpatialConvolutionMM (384 -> 384, 1x1)\n " ,
205
+ " (19): nn.SpatialConvolution (384 -> 384, 1x1)\n " ,
241
206
" (20): nn.ReLU\n " ,
242
- " (21): inn .SpatialMaxPooling(3,3,2,2)\n " ,
207
+ " (21): nn .SpatialMaxPooling(3,3,2,2)\n " ,
243
208
" (22): nn.Dropout(0.500000)\n " ,
244
- " (23): nn.SpatialConvolutionMM (384 -> 1024, 3x3, 1,1)\n " ,
209
+ " (23): nn.SpatialConvolution (384 -> 1024, 3x3, 1,1 , 1,1)\n " ,
245
210
" (24): nn.ReLU\n " ,
246
- " (25): nn.SpatialConvolutionMM (1024 -> 1024, 1x1)\n " ,
211
+ " (25): nn.SpatialConvolution (1024 -> 1024, 1x1)\n " ,
247
212
" (26): nn.ReLU\n " ,
248
- " (27): nn.SpatialConvolutionMM (1024 -> 1000, 1x1)\n " ,
213
+ " (27): nn.SpatialConvolution (1024 -> 1000, 1x1)\n " ,
249
214
" (28): nn.ReLU\n " ,
250
- " (29): inn.SpatialAveragePooling(6,6,1,1)\n " ,
215
+ " (29): nn.SpatialAveragePooling(6,6,1,1)\n " ,
216
+ " (30): nn.SoftMax\n " ,
251
217
" }\t\n "
252
218
]
253
219
},
265
231
]
266
232
}
267
233
],
268
- "prompt_number" : 3
234
+ "prompt_number" : 6
269
235
},
270
236
{
271
237
"cell_type" : " code" ,
291
257
]
292
258
}
293
259
],
294
- "prompt_number" : 4
260
+ "prompt_number" : 7
295
261
},
296
262
{
297
263
"cell_type" : " code" ,
317
283
]
318
284
}
319
285
],
320
- "prompt_number" : 5
286
+ "prompt_number" : 8
321
287
},
322
288
{
323
289
"cell_type" : " code" ,
344
310
]
345
311
}
346
312
],
347
- "prompt_number" : 6
313
+ "prompt_number" : 9
348
314
},
349
315
{
350
316
"cell_type" : " code" ,
358
324
" synset_words = load_synset()\n " ,
359
325
" \n " ,
360
326
" -- sort outputs in decreasing order and show 5 best classes\n " ,
361
- " _,classes = net:forward(I:cuda()) :view(-1):float( ):sort(true)\n " ,
327
+ " _,classes = net:forward(I) :view(-1):sort(true)\n " ,
362
328
" for i=1,5 do\n " ,
363
329
" print('predicted class '..tostring(i)..': ', synset_words[classes[i]])\n " ,
364
330
" end"
369
335
{
370
336
"metadata" : {},
371
337
"output_type" : " pyout" ,
372
- "prompt_number" : 7 ,
338
+ "prompt_number" : 20 ,
373
339
"text" : [
374
340
" ==> Preprocessing\t\n " ,
375
341
" predicted class 1: \t goldfish, Carassius auratus\t\n " ,
376
342
" predicted class 2: \t macaw\t\n " ,
377
- " predicted class 3: \t lorikeet \t\n " ,
378
- " predicted class 4: \t flamingo \t\n " ,
379
- " predicted class 5: \t pinwheel \t\n "
343
+ " predicted class 3: \t moped \t\n " ,
344
+ " predicted class 4: \t monastery \t\n " ,
345
+ " predicted class 5: \t mosquito net \t\n "
380
346
]
381
347
}
382
348
],
383
- "prompt_number" : 7
349
+ "prompt_number" : 20
384
350
}
385
351
],
386
352
"metadata" : {}
387
353
}
388
354
]
389
- }
355
+ }
0 commit comments