summaryrefslogtreecommitdiff
path: root/src/notebooks/00-testing-stuff-out.ipynb
blob: 02943945eb0c16360add0d965b4878f50537096a (plain)
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "%load_ext autoreload\n",
    "%autoreload 2\n",
    "\n",
    "%matplotlib inline\n",
    "import matplotlib.pyplot as plt\n",
    "import numpy as np\n",
    "from PIL import Image\n",
    "import torch\n",
    "from importlib.util import find_spec\n",
    "if find_spec(\"text_recognizer\") is None:\n",
    "    import sys\n",
    "    sys.path.append('..')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "from text_recognizer.networks.residual_network import IdentityBlock, ResidualBlock, BasicBlock, BottleNeckBlock, ResidualLayer, ResidualNetwork"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "IdentityBlock(\n",
       "  (blocks): Identity()\n",
       "  (activation_fn): ReLU(inplace=True)\n",
       "  (shortcut): Identity()\n",
       ")"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "IdentityBlock(32, 64)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "ResidualBlock(\n",
       "  (blocks): Identity()\n",
       "  (activation_fn): ReLU(inplace=True)\n",
       "  (shortcut): Sequential(\n",
       "    (0): Conv2d(32, 64, kernel_size=(1, 1), stride=(1, 1), bias=False)\n",
       "    (1): BatchNorm2d(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)\n",
       "  )\n",
       ")"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ResidualBlock(32, 64)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "BasicBlock(\n",
      "  (blocks): Sequential(\n",
      "    (0): Sequential(\n",
      "      (0): Conv2dAuto(32, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)\n",
      "      (1): BatchNorm2d(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)\n",
      "    )\n",
      "    (1): ReLU(inplace=True)\n",
      "    (2): Sequential(\n",
      "      (0): Conv2dAuto(64, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)\n",
      "      (1): BatchNorm2d(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)\n",
      "    )\n",
      "  )\n",
      "  (activation_fn): ReLU(inplace=True)\n",
      "  (shortcut): Sequential(\n",
      "    (0): Conv2d(32, 64, kernel_size=(1, 1), stride=(1, 1), bias=False)\n",
      "    (1): BatchNorm2d(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)\n",
      "  )\n",
      ")\n"
     ]
    }
   ],
   "source": [
    "dummy = torch.ones((1, 32, 224, 224))\n",
    "\n",
    "block = BasicBlock(32, 64)\n",
    "block(dummy).shape\n",
    "print(block)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "BottleNeckBlock(\n",
      "  (blocks): Sequential(\n",
      "    (0): Sequential(\n",
      "      (0): Conv2dAuto(32, 64, kernel_size=(1, 1), stride=(1, 1), bias=False)\n",
      "      (1): BatchNorm2d(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)\n",
      "    )\n",
      "    (1): ReLU(inplace=True)\n",
      "    (2): Sequential(\n",
      "      (0): Conv2dAuto(64, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)\n",
      "      (1): BatchNorm2d(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)\n",
      "    )\n",
      "    (3): ReLU(inplace=True)\n",
      "    (4): Sequential(\n",
      "      (0): Conv2dAuto(64, 64, kernel_size=(1, 1), stride=(1, 1), bias=False)\n",
      "      (1): BatchNorm2d(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)\n",
      "    )\n",
      "  )\n",
      "  (activation_fn): ReLU(inplace=True)\n",
      "  (shortcut): Sequential(\n",
      "    (0): Conv2d(32, 64, kernel_size=(1, 1), stride=(1, 1), bias=False)\n",
      "    (1): BatchNorm2d(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)\n",
      "  )\n",
      ")\n"
     ]
    }
   ],
   "source": [
    "dummy = torch.ones((1, 32, 10, 10))\n",
    "\n",
    "block = BottleNeckBlock(32, 64)\n",
    "block(dummy).shape\n",
    "print(block)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "dummy = torch.ones((1, 64, 48, 48))\n",
    "\n",
    "layer = ResidualLayer(64, 128, block=BasicBlock, num_blocks=3)\n",
    "layer(dummy).shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "blocks_sizes=[64, 128, 256, 512]\n",
    "list(zip(blocks_sizes, blocks_sizes[1:]))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 69,
   "metadata": {},
   "outputs": [],
   "source": [
    "e = Encoder(depths=[2, 1], block_sizes= [96, 128])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 75,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Encoder(\n",
       "  (gate): Sequential(\n",
       "    (0): Conv2d(1, 96, kernel_size=(3, 3), stride=(2, 2), padding=(3, 3), bias=False)\n",
       "    (1): BatchNorm2d(96, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)\n",
       "    (2): ReLU(inplace=True)\n",
       "    (3): MaxPool2d(kernel_size=3, stride=2, padding=1, dilation=1, ceil_mode=False)\n",
       "  )\n",
       "  (blocks): Sequential(\n",
       "    (0): ResidualLayer(\n",
       "      (blocks): Sequential(\n",
       "        (0): BasicBlock(\n",
       "          (blocks): Sequential(\n",
       "            (0): Sequential(\n",
       "              (0): Conv2dAuto(96, 96, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)\n",
       "              (1): BatchNorm2d(96, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)\n",
       "            )\n",
       "            (1): ReLU(inplace=True)\n",
       "            (2): Sequential(\n",
       "              (0): Conv2dAuto(96, 96, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)\n",
       "              (1): BatchNorm2d(96, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)\n",
       "            )\n",
       "          )\n",
       "          (activation_fn): ReLU(inplace=True)\n",
       "          (shortcut): None\n",
       "        )\n",
       "        (1): BasicBlock(\n",
       "          (blocks): Sequential(\n",
       "            (0): Sequential(\n",
       "              (0): Conv2dAuto(96, 96, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)\n",
       "              (1): BatchNorm2d(96, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)\n",
       "            )\n",
       "            (1): ReLU(inplace=True)\n",
       "            (2): Sequential(\n",
       "              (0): Conv2dAuto(96, 96, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)\n",
       "              (1): BatchNorm2d(96, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)\n",
       "            )\n",
       "          )\n",
       "          (activation_fn): ReLU(inplace=True)\n",
       "          (shortcut): None\n",
       "        )\n",
       "      )\n",
       "    )\n",
       "    (1): ResidualLayer(\n",
       "      (blocks): Sequential(\n",
       "        (0): BasicBlock(\n",
       "          (blocks): Sequential(\n",
       "            (0): Sequential(\n",
       "              (0): Conv2dAuto(96, 128, kernel_size=(3, 3), stride=(2, 2), padding=(1, 1), bias=False)\n",
       "              (1): BatchNorm2d(128, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)\n",
       "            )\n",
       "            (1): ReLU(inplace=True)\n",
       "            (2): Sequential(\n",
       "              (0): Conv2dAuto(128, 128, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)\n",
       "              (1): BatchNorm2d(128, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)\n",
       "            )\n",
       "          )\n",
       "          (activation_fn): ReLU(inplace=True)\n",
       "          (shortcut): Sequential(\n",
       "            (0): Conv2d(96, 128, kernel_size=(1, 1), stride=(2, 2), bias=False)\n",
       "            (1): BatchNorm2d(128, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)\n",
       "          )\n",
       "        )\n",
       "      )\n",
       "    )\n",
       "  )\n",
       ")"
      ]
     },
     "execution_count": 75,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "Encoder(**{\"depths\": [2, 1], \"block_sizes\": [96, 128]})"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [],
   "source": [
    "from text_recognizer.networks import WideResidualNetwork"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [],
   "source": [
    "wr = WideResidualNetwork(\n",
    "            in_channels= 1,\n",
    "            num_classes= 80,\n",
    "            depth= 16,\n",
    "            num_layers= 4,\n",
    "            width_factor= 2,\n",
    "            dropout_rate= 0.2,\n",
    "            activation= \"SELU\",\n",
    "            use_decoder= False,\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [],
   "source": [
    "from torchsummary import summary"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "===============================================================================================\n",
      "Layer (type:depth-idx)                        Output Shape              Param #\n",
      "===============================================================================================\n",
      "├─Sequential: 1-1                             [-1, 256, 4, 2]           --\n",
      "|    └─Conv2d: 2-1                            [-1, 16, 28, 14]          144\n",
      "|    └─Sequential: 2-2                        [-1, 32, 28, 14]          --\n",
      "|    |    └─WideBlock: 3-1                    [-1, 32, 28, 14]          --\n",
      "|    |    |    └─Sequential: 4-1              [-1, 32, 28, 14]          --\n",
      "|    |    |    |    └─Conv2d: 5-1             [-1, 32, 28, 14]          512\n",
      "|    |    |    └─Sequential: 4-2              [-1, 32, 28, 14]          --\n",
      "|    |    |    |    └─BatchNorm2d: 5-2        [-1, 16, 28, 14]          32\n",
      "|    |    |    └─SELU: 4-3                    [-1, 16, 28, 14]          --\n",
      "|    |    |    └─Sequential: 4                []                        --\n",
      "|    |    |    |    └─SELU: 5-3               [-1, 16, 28, 14]          --\n",
      "|    |    |    |    └─Conv2d: 5-4             [-1, 32, 28, 14]          4,608\n",
      "|    |    |    |    └─Dropout: 5-5            [-1, 32, 28, 14]          --\n",
      "|    |    |    |    └─BatchNorm2d: 5-6        [-1, 32, 28, 14]          64\n",
      "|    |    |    └─SELU: 4-4                    [-1, 32, 28, 14]          --\n",
      "|    |    |    └─Sequential: 4                []                        --\n",
      "|    |    |    |    └─SELU: 5-7               [-1, 32, 28, 14]          --\n",
      "|    |    |    |    └─Conv2d: 5-8             [-1, 32, 28, 14]          9,216\n",
      "|    |    └─WideBlock: 3-2                    [-1, 32, 28, 14]          --\n",
      "|    |    |    └─Sequential: 4-5              [-1, 32, 28, 14]          --\n",
      "|    |    |    |    └─BatchNorm2d: 5-9        [-1, 32, 28, 14]          64\n",
      "|    |    |    └─SELU: 4-6                    [-1, 32, 28, 14]          --\n",
      "|    |    |    └─Sequential: 4                []                        --\n",
      "|    |    |    |    └─SELU: 5-10              [-1, 32, 28, 14]          --\n",
      "|    |    |    |    └─Conv2d: 5-11            [-1, 32, 28, 14]          9,216\n",
      "|    |    |    |    └─Dropout: 5-12           [-1, 32, 28, 14]          --\n",
      "|    |    |    |    └─BatchNorm2d: 5-13       [-1, 32, 28, 14]          64\n",
      "|    |    |    └─SELU: 4-7                    [-1, 32, 28, 14]          --\n",
      "|    |    |    └─Sequential: 4                []                        --\n",
      "|    |    |    |    └─SELU: 5-14              [-1, 32, 28, 14]          --\n",
      "|    |    |    |    └─Conv2d: 5-15            [-1, 32, 28, 14]          9,216\n",
      "|    └─Sequential: 2-3                        [-1, 64, 14, 7]           --\n",
      "|    |    └─WideBlock: 3-3                    [-1, 64, 14, 7]           --\n",
      "|    |    |    └─Sequential: 4-8              [-1, 64, 14, 7]           --\n",
      "|    |    |    |    └─Conv2d: 5-16            [-1, 64, 14, 7]           2,048\n",
      "|    |    |    └─Sequential: 4-9              [-1, 64, 14, 7]           --\n",
      "|    |    |    |    └─BatchNorm2d: 5-17       [-1, 32, 28, 14]          64\n",
      "|    |    |    └─SELU: 4-10                   [-1, 32, 28, 14]          --\n",
      "|    |    |    └─Sequential: 4                []                        --\n",
      "|    |    |    |    └─SELU: 5-18              [-1, 32, 28, 14]          --\n",
      "|    |    |    |    └─Conv2d: 5-19            [-1, 64, 28, 14]          18,432\n",
      "|    |    |    |    └─Dropout: 5-20           [-1, 64, 28, 14]          --\n",
      "|    |    |    |    └─BatchNorm2d: 5-21       [-1, 64, 28, 14]          128\n",
      "|    |    |    └─SELU: 4-11                   [-1, 64, 28, 14]          --\n",
      "|    |    |    └─Sequential: 4                []                        --\n",
      "|    |    |    |    └─SELU: 5-22              [-1, 64, 28, 14]          --\n",
      "|    |    |    |    └─Conv2d: 5-23            [-1, 64, 14, 7]           36,864\n",
      "|    |    └─WideBlock: 3-4                    [-1, 64, 14, 7]           --\n",
      "|    |    |    └─Sequential: 4-12             [-1, 64, 14, 7]           --\n",
      "|    |    |    |    └─BatchNorm2d: 5-24       [-1, 64, 14, 7]           128\n",
      "|    |    |    └─SELU: 4-13                   [-1, 64, 14, 7]           --\n",
      "|    |    |    └─Sequential: 4                []                        --\n",
      "|    |    |    |    └─SELU: 5-25              [-1, 64, 14, 7]           --\n",
      "|    |    |    |    └─Conv2d: 5-26            [-1, 64, 14, 7]           36,864\n",
      "|    |    |    |    └─Dropout: 5-27           [-1, 64, 14, 7]           --\n",
      "|    |    |    |    └─BatchNorm2d: 5-28       [-1, 64, 14, 7]           128\n",
      "|    |    |    └─SELU: 4-14                   [-1, 64, 14, 7]           --\n",
      "|    |    |    └─Sequential: 4                []                        --\n",
      "|    |    |    |    └─SELU: 5-29              [-1, 64, 14, 7]           --\n",
      "|    |    |    |    └─Conv2d: 5-30            [-1, 64, 14, 7]           36,864\n",
      "|    └─Sequential: 2-4                        [-1, 128, 7, 4]           --\n",
      "|    |    └─WideBlock: 3-5                    [-1, 128, 7, 4]           --\n",
      "|    |    |    └─Sequential: 4-15             [-1, 128, 7, 4]           --\n",
      "|    |    |    |    └─Conv2d: 5-31            [-1, 128, 7, 4]           8,192\n",
      "|    |    |    └─Sequential: 4-16             [-1, 128, 7, 4]           --\n",
      "|    |    |    |    └─BatchNorm2d: 5-32       [-1, 64, 14, 7]           128\n",
      "|    |    |    └─SELU: 4-17                   [-1, 64, 14, 7]           --\n",
      "|    |    |    └─Sequential: 4                []                        --\n",
      "|    |    |    |    └─SELU: 5-33              [-1, 64, 14, 7]           --\n",
      "|    |    |    |    └─Conv2d: 5-34            [-1, 128, 14, 7]          73,728\n",
      "|    |    |    |    └─Dropout: 5-35           [-1, 128, 14, 7]          --\n",
      "|    |    |    |    └─BatchNorm2d: 5-36       [-1, 128, 14, 7]          256\n",
      "|    |    |    └─SELU: 4-18                   [-1, 128, 14, 7]          --\n",
      "|    |    |    └─Sequential: 4                []                        --\n",
      "|    |    |    |    └─SELU: 5-37              [-1, 128, 14, 7]          --\n",
      "|    |    |    |    └─Conv2d: 5-38            [-1, 128, 7, 4]           147,456\n",
      "|    |    └─WideBlock: 3-6                    [-1, 128, 7, 4]           --\n",
      "|    |    |    └─Sequential: 4-19             [-1, 128, 7, 4]           --\n",
      "|    |    |    |    └─BatchNorm2d: 5-39       [-1, 128, 7, 4]           256\n",
      "|    |    |    └─SELU: 4-20                   [-1, 128, 7, 4]           --\n",
      "|    |    |    └─Sequential: 4                []                        --\n",
      "|    |    |    |    └─SELU: 5-40              [-1, 128, 7, 4]           --\n",
      "|    |    |    |    └─Conv2d: 5-41            [-1, 128, 7, 4]           147,456\n",
      "|    |    |    |    └─Dropout: 5-42           [-1, 128, 7, 4]           --\n",
      "|    |    |    |    └─BatchNorm2d: 5-43       [-1, 128, 7, 4]           256\n",
      "|    |    |    └─SELU: 4-21                   [-1, 128, 7, 4]           --\n",
      "|    |    |    └─Sequential: 4                []                        --\n",
      "|    |    |    |    └─SELU: 5-44              [-1, 128, 7, 4]           --\n",
      "|    |    |    |    └─Conv2d: 5-45            [-1, 128, 7, 4]           147,456\n",
      "|    └─Sequential: 2-5                        [-1, 256, 4, 2]           --\n",
      "|    |    └─WideBlock: 3-7                    [-1, 256, 4, 2]           --\n",
      "|    |    |    └─Sequential: 4-22             [-1, 256, 4, 2]           --\n",
      "|    |    |    |    └─Conv2d: 5-46            [-1, 256, 4, 2]           32,768\n",
      "|    |    |    └─Sequential: 4-23             [-1, 256, 4, 2]           --\n",
      "|    |    |    |    └─BatchNorm2d: 5-47       [-1, 128, 7, 4]           256\n",
      "|    |    |    └─SELU: 4-24                   [-1, 128, 7, 4]           --\n",
      "|    |    |    └─Sequential: 4                []                        --\n",
      "|    |    |    |    └─SELU: 5-48              [-1, 128, 7, 4]           --\n",
      "|    |    |    |    └─Conv2d: 5-49            [-1, 256, 7, 4]           294,912\n",
      "|    |    |    |    └─Dropout: 5-50           [-1, 256, 7, 4]           --\n",
      "|    |    |    |    └─BatchNorm2d: 5-51       [-1, 256, 7, 4]           512\n",
      "|    |    |    └─SELU: 4-25                   [-1, 256, 7, 4]           --\n",
      "|    |    |    └─Sequential: 4                []                        --\n",
      "|    |    |    |    └─SELU: 5-52              [-1, 256, 7, 4]           --\n",
      "|    |    |    |    └─Conv2d: 5-53            [-1, 256, 4, 2]           589,824\n",
      "|    |    └─WideBlock: 3-8                    [-1, 256, 4, 2]           --\n",
      "|    |    |    └─Sequential: 4-26             [-1, 256, 4, 2]           --\n",
      "|    |    |    |    └─BatchNorm2d: 5-54       [-1, 256, 4, 2]           512\n",
      "|    |    |    └─SELU: 4-27                   [-1, 256, 4, 2]           --\n",
      "|    |    |    └─Sequential: 4                []                        --\n",
      "|    |    |    |    └─SELU: 5-55              [-1, 256, 4, 2]           --\n",
      "|    |    |    |    └─Conv2d: 5-56            [-1, 256, 4, 2]           589,824\n",
      "|    |    |    |    └─Dropout: 5-57           [-1, 256, 4, 2]           --\n",
      "|    |    |    |    └─BatchNorm2d: 5-58       [-1, 256, 4, 2]           512\n",
      "|    |    |    └─SELU: 4-28                   [-1, 256, 4, 2]           --\n",
      "|    |    |    └─Sequential: 4                []                        --\n",
      "|    |    |    |    └─SELU: 5-59              [-1, 256, 4, 2]           --\n",
      "|    |    |    |    └─Conv2d: 5-60            [-1, 256, 4, 2]           589,824\n",
      "===============================================================================================\n",
      "Total params: 2,788,784\n",
      "Trainable params: 2,788,784\n",
      "Non-trainable params: 0\n",
      "Total mult-adds (M): 84.83\n",
      "===============================================================================================\n",
      "Input size (MB): 0.00\n",
      "Forward/backward pass size (MB): 2.26\n",
      "Params size (MB): 10.64\n",
      "Estimated Total Size (MB): 12.90\n",
      "===============================================================================================\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "===============================================================================================\n",
       "Layer (type:depth-idx)                        Output Shape              Param #\n",
       "===============================================================================================\n",
       "├─Sequential: 1-1                             [-1, 256, 4, 2]           --\n",
       "|    └─Conv2d: 2-1                            [-1, 16, 28, 14]          144\n",
       "|    └─Sequential: 2-2                        [-1, 32, 28, 14]          --\n",
       "|    |    └─WideBlock: 3-1                    [-1, 32, 28, 14]          --\n",
       "|    |    |    └─Sequential: 4-1              [-1, 32, 28, 14]          --\n",
       "|    |    |    |    └─Conv2d: 5-1             [-1, 32, 28, 14]          512\n",
       "|    |    |    └─Sequential: 4-2              [-1, 32, 28, 14]          --\n",
       "|    |    |    |    └─BatchNorm2d: 5-2        [-1, 16, 28, 14]          32\n",
       "|    |    |    └─SELU: 4-3                    [-1, 16, 28, 14]          --\n",
       "|    |    |    └─Sequential: 4                []                        --\n",
       "|    |    |    |    └─SELU: 5-3               [-1, 16, 28, 14]          --\n",
       "|    |    |    |    └─Conv2d: 5-4             [-1, 32, 28, 14]          4,608\n",
       "|    |    |    |    └─Dropout: 5-5            [-1, 32, 28, 14]          --\n",
       "|    |    |    |    └─BatchNorm2d: 5-6        [-1, 32, 28, 14]          64\n",
       "|    |    |    └─SELU: 4-4                    [-1, 32, 28, 14]          --\n",
       "|    |    |    └─Sequential: 4                []                        --\n",
       "|    |    |    |    └─SELU: 5-7               [-1, 32, 28, 14]          --\n",
       "|    |    |    |    └─Conv2d: 5-8             [-1, 32, 28, 14]          9,216\n",
       "|    |    └─WideBlock: 3-2                    [-1, 32, 28, 14]          --\n",
       "|    |    |    └─Sequential: 4-5              [-1, 32, 28, 14]          --\n",
       "|    |    |    |    └─BatchNorm2d: 5-9        [-1, 32, 28, 14]          64\n",
       "|    |    |    └─SELU: 4-6                    [-1, 32, 28, 14]          --\n",
       "|    |    |    └─Sequential: 4                []                        --\n",
       "|    |    |    |    └─SELU: 5-10              [-1, 32, 28, 14]          --\n",
       "|    |    |    |    └─Conv2d: 5-11            [-1, 32, 28, 14]          9,216\n",
       "|    |    |    |    └─Dropout: 5-12           [-1, 32, 28, 14]          --\n",
       "|    |    |    |    └─BatchNorm2d: 5-13       [-1, 32, 28, 14]          64\n",
       "|    |    |    └─SELU: 4-7                    [-1, 32, 28, 14]          --\n",
       "|    |    |    └─Sequential: 4                []                        --\n",
       "|    |    |    |    └─SELU: 5-14              [-1, 32, 28, 14]          --\n",
       "|    |    |    |    └─Conv2d: 5-15            [-1, 32, 28, 14]          9,216\n",
       "|    └─Sequential: 2-3                        [-1, 64, 14, 7]           --\n",
       "|    |    └─WideBlock: 3-3                    [-1, 64, 14, 7]           --\n",
       "|    |    |    └─Sequential: 4-8              [-1, 64, 14, 7]           --\n",
       "|    |    |    |    └─Conv2d: 5-16            [-1, 64, 14, 7]           2,048\n",
       "|    |    |    └─Sequential: 4-9              [-1, 64, 14, 7]           --\n",
       "|    |    |    |    └─BatchNorm2d: 5-17       [-1, 32, 28, 14]          64\n",
       "|    |    |    └─SELU: 4-10                   [-1, 32, 28, 14]          --\n",
       "|    |    |    └─Sequential: 4                []                        --\n",
       "|    |    |    |    └─SELU: 5-18              [-1, 32, 28, 14]          --\n",
       "|    |    |    |    └─Conv2d: 5-19            [-1, 64, 28, 14]          18,432\n",
       "|    |    |    |    └─Dropout: 5-20           [-1, 64, 28, 14]          --\n",
       "|    |    |    |    └─BatchNorm2d: 5-21       [-1, 64, 28, 14]          128\n",
       "|    |    |    └─SELU: 4-11                   [-1, 64, 28, 14]          --\n",
       "|    |    |    └─Sequential: 4                []                        --\n",
       "|    |    |    |    └─SELU: 5-22              [-1, 64, 28, 14]          --\n",
       "|    |    |    |    └─Conv2d: 5-23            [-1, 64, 14, 7]           36,864\n",
       "|    |    └─WideBlock: 3-4                    [-1, 64, 14, 7]           --\n",
       "|    |    |    └─Sequential: 4-12             [-1, 64, 14, 7]           --\n",
       "|    |    |    |    └─BatchNorm2d: 5-24       [-1, 64, 14, 7]           128\n",
       "|    |    |    └─SELU: 4-13                   [-1, 64, 14, 7]           --\n",
       "|    |    |    └─Sequential: 4                []                        --\n",
       "|    |    |    |    └─SELU: 5-25              [-1, 64, 14, 7]           --\n",
       "|    |    |    |    └─Conv2d: 5-26            [-1, 64, 14, 7]           36,864\n",
       "|    |    |    |    └─Dropout: 5-27           [-1, 64, 14, 7]           --\n",
       "|    |    |    |    └─BatchNorm2d: 5-28       [-1, 64, 14, 7]           128\n",
       "|    |    |    └─SELU: 4-14                   [-1, 64, 14, 7]           --\n",
       "|    |    |    └─Sequential: 4                []                        --\n",
       "|    |    |    |    └─SELU: 5-29              [-1, 64, 14, 7]           --\n",
       "|    |    |    |    └─Conv2d: 5-30            [-1, 64, 14, 7]           36,864\n",
       "|    └─Sequential: 2-4                        [-1, 128, 7, 4]           --\n",
       "|    |    └─WideBlock: 3-5                    [-1, 128, 7, 4]           --\n",
       "|    |    |    └─Sequential: 4-15             [-1, 128, 7, 4]           --\n",
       "|    |    |    |    └─Conv2d: 5-31            [-1, 128, 7, 4]           8,192\n",
       "|    |    |    └─Sequential: 4-16             [-1, 128, 7, 4]           --\n",
       "|    |    |    |    └─BatchNorm2d: 5-32       [-1, 64, 14, 7]           128\n",
       "|    |    |    └─SELU: 4-17                   [-1, 64, 14, 7]           --\n",
       "|    |    |    └─Sequential: 4                []                        --\n",
       "|    |    |    |    └─SELU: 5-33              [-1, 64, 14, 7]           --\n",
       "|    |    |    |    └─Conv2d: 5-34            [-1, 128, 14, 7]          73,728\n",
       "|    |    |    |    └─Dropout: 5-35           [-1, 128, 14, 7]          --\n",
       "|    |    |    |    └─BatchNorm2d: 5-36       [-1, 128, 14, 7]          256\n",
       "|    |    |    └─SELU: 4-18                   [-1, 128, 14, 7]          --\n",
       "|    |    |    └─Sequential: 4                []                        --\n",
       "|    |    |    |    └─SELU: 5-37              [-1, 128, 14, 7]          --\n",
       "|    |    |    |    └─Conv2d: 5-38            [-1, 128, 7, 4]           147,456\n",
       "|    |    └─WideBlock: 3-6                    [-1, 128, 7, 4]           --\n",
       "|    |    |    └─Sequential: 4-19             [-1, 128, 7, 4]           --\n",
       "|    |    |    |    └─BatchNorm2d: 5-39       [-1, 128, 7, 4]           256\n",
       "|    |    |    └─SELU: 4-20                   [-1, 128, 7, 4]           --\n",
       "|    |    |    └─Sequential: 4                []                        --\n",
       "|    |    |    |    └─SELU: 5-40              [-1, 128, 7, 4]           --\n",
       "|    |    |    |    └─Conv2d: 5-41            [-1, 128, 7, 4]           147,456\n",
       "|    |    |    |    └─Dropout: 5-42           [-1, 128, 7, 4]           --\n",
       "|    |    |    |    └─BatchNorm2d: 5-43       [-1, 128, 7, 4]           256\n",
       "|    |    |    └─SELU: 4-21                   [-1, 128, 7, 4]           --\n",
       "|    |    |    └─Sequential: 4                []                        --\n",
       "|    |    |    |    └─SELU: 5-44              [-1, 128, 7, 4]           --\n",
       "|    |    |    |    └─Conv2d: 5-45            [-1, 128, 7, 4]           147,456\n",
       "|    └─Sequential: 2-5                        [-1, 256, 4, 2]           --\n",
       "|    |    └─WideBlock: 3-7                    [-1, 256, 4, 2]           --\n",
       "|    |    |    └─Sequential: 4-22             [-1, 256, 4, 2]           --\n",
       "|    |    |    |    └─Conv2d: 5-46            [-1, 256, 4, 2]           32,768\n",
       "|    |    |    └─Sequential: 4-23             [-1, 256, 4, 2]           --\n",
       "|    |    |    |    └─BatchNorm2d: 5-47       [-1, 128, 7, 4]           256\n",
       "|    |    |    └─SELU: 4-24                   [-1, 128, 7, 4]           --\n",
       "|    |    |    └─Sequential: 4                []                        --\n",
       "|    |    |    |    └─SELU: 5-48              [-1, 128, 7, 4]           --\n",
       "|    |    |    |    └─Conv2d: 5-49            [-1, 256, 7, 4]           294,912\n",
       "|    |    |    |    └─Dropout: 5-50           [-1, 256, 7, 4]           --\n",
       "|    |    |    |    └─BatchNorm2d: 5-51       [-1, 256, 7, 4]           512\n",
       "|    |    |    └─SELU: 4-25                   [-1, 256, 7, 4]           --\n",
       "|    |    |    └─Sequential: 4                []                        --\n",
       "|    |    |    |    └─SELU: 5-52              [-1, 256, 7, 4]           --\n",
       "|    |    |    |    └─Conv2d: 5-53            [-1, 256, 4, 2]           589,824\n",
       "|    |    └─WideBlock: 3-8                    [-1, 256, 4, 2]           --\n",
       "|    |    |    └─Sequential: 4-26             [-1, 256, 4, 2]           --\n",
       "|    |    |    |    └─BatchNorm2d: 5-54       [-1, 256, 4, 2]           512\n",
       "|    |    |    └─SELU: 4-27                   [-1, 256, 4, 2]           --\n",
       "|    |    |    └─Sequential: 4                []                        --\n",
       "|    |    |    |    └─SELU: 5-55              [-1, 256, 4, 2]           --\n",
       "|    |    |    |    └─Conv2d: 5-56            [-1, 256, 4, 2]           589,824\n",
       "|    |    |    |    └─Dropout: 5-57           [-1, 256, 4, 2]           --\n",
       "|    |    |    |    └─BatchNorm2d: 5-58       [-1, 256, 4, 2]           512\n",
       "|    |    |    └─SELU: 4-28                   [-1, 256, 4, 2]           --\n",
       "|    |    |    └─Sequential: 4                []                        --\n",
       "|    |    |    |    └─SELU: 5-59              [-1, 256, 4, 2]           --\n",
       "|    |    |    |    └─Conv2d: 5-60            [-1, 256, 4, 2]           589,824\n",
       "===============================================================================================\n",
       "Total params: 2,788,784\n",
       "Trainable params: 2,788,784\n",
       "Non-trainable params: 0\n",
       "Total mult-adds (M): 84.83\n",
       "===============================================================================================\n",
       "Input size (MB): 0.00\n",
       "Forward/backward pass size (MB): 2.26\n",
       "Params size (MB): 10.64\n",
       "Estimated Total Size (MB): 12.90\n",
       "==============================================================================================="
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "summary(wr, (1, 28, 14), device=\"cpu\", depth=10)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}