forked from RomanKoshkin/EEG_classification
-
Notifications
You must be signed in to change notification settings - Fork 0
/
notebook.tex
executable file
·1917 lines (1461 loc) · 116 KB
/
notebook.tex
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
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
% Default to the notebook output style
% Inherit from the specified cell style.
\documentclass[11pt]{article}
\usepackage[T1]{fontenc}
% Nicer default font (+ math font) than Computer Modern for most use cases
\usepackage{mathpazo}
% Basic figure setup, for now with no caption control since it's done
% automatically by Pandoc (which extracts ![](path) syntax from Markdown).
\usepackage{graphicx}
% We will generate all images so they have a width \maxwidth. This means
% that they will get their normal width if they fit onto the page, but
% are scaled down if they would overflow the margins.
\makeatletter
\def\maxwidth{\ifdim\Gin@nat@width>\linewidth\linewidth
\else\Gin@nat@width\fi}
\makeatother
\let\Oldincludegraphics\includegraphics
% Set max figure width to be 80% of text width, for now hardcoded.
\renewcommand{\includegraphics}[1]{\Oldincludegraphics[width=.8\maxwidth]{#1}}
% Ensure that by default, figures have no caption (until we provide a
% proper Figure object with a Caption API and a way to capture that
% in the conversion process - todo).
\usepackage{caption}
\DeclareCaptionLabelFormat{nolabel}{}
\captionsetup{labelformat=nolabel}
\usepackage{adjustbox} % Used to constrain images to a maximum size
\usepackage{xcolor} % Allow colors to be defined
\usepackage{enumerate} % Needed for markdown enumerations to work
\usepackage{geometry} % Used to adjust the document margins
\usepackage{amsmath} % Equations
\usepackage{amssymb} % Equations
\usepackage{textcomp} % defines textquotesingle
% Hack from http://tex.stackexchange.com/a/47451/13684:
\AtBeginDocument{%
\def\PYZsq{\textquotesingle}% Upright quotes in Pygmentized code
}
\usepackage{upquote} % Upright quotes for verbatim code
\usepackage{eurosym} % defines \euro
\usepackage[mathletters]{ucs} % Extended unicode (utf-8) support
\usepackage[utf8x]{inputenc} % Allow utf-8 characters in the tex document
\usepackage{fancyvrb} % verbatim replacement that allows latex
\usepackage{grffile} % extends the file name processing of package graphics
% to support a larger range
% The hyperref package gives us a pdf with properly built
% internal navigation ('pdf bookmarks' for the table of contents,
% internal cross-reference links, web links for URLs, etc.)
\usepackage{hyperref}
\usepackage{longtable} % longtable support required by pandoc >1.10
\usepackage{booktabs} % table support for pandoc > 1.12.2
\usepackage[inline]{enumitem} % IRkernel/repr support (it uses the enumerate* environment)
\usepackage[normalem]{ulem} % ulem is needed to support strikethroughs (\sout)
% normalem makes italics be italics, not underlines
% Colors for the hyperref package
\definecolor{urlcolor}{rgb}{0,.145,.698}
\definecolor{linkcolor}{rgb}{.71,0.21,0.01}
\definecolor{citecolor}{rgb}{.12,.54,.11}
% ANSI colors
\definecolor{ansi-black}{HTML}{3E424D}
\definecolor{ansi-black-intense}{HTML}{282C36}
\definecolor{ansi-red}{HTML}{E75C58}
\definecolor{ansi-red-intense}{HTML}{B22B31}
\definecolor{ansi-green}{HTML}{00A250}
\definecolor{ansi-green-intense}{HTML}{007427}
\definecolor{ansi-yellow}{HTML}{DDB62B}
\definecolor{ansi-yellow-intense}{HTML}{B27D12}
\definecolor{ansi-blue}{HTML}{208FFB}
\definecolor{ansi-blue-intense}{HTML}{0065CA}
\definecolor{ansi-magenta}{HTML}{D160C4}
\definecolor{ansi-magenta-intense}{HTML}{A03196}
\definecolor{ansi-cyan}{HTML}{60C6C8}
\definecolor{ansi-cyan-intense}{HTML}{258F8F}
\definecolor{ansi-white}{HTML}{C5C1B4}
\definecolor{ansi-white-intense}{HTML}{A1A6B2}
% commands and environments needed by pandoc snippets
% extracted from the output of `pandoc -s`
\providecommand{\tightlist}{%
\setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}
\DefineVerbatimEnvironment{Highlighting}{Verbatim}{commandchars=\\\{\}}
% Add ',fontsize=\small' for more characters per line
\newenvironment{Shaded}{}{}
\newcommand{\KeywordTok}[1]{\textcolor[rgb]{0.00,0.44,0.13}{\textbf{{#1}}}}
\newcommand{\DataTypeTok}[1]{\textcolor[rgb]{0.56,0.13,0.00}{{#1}}}
\newcommand{\DecValTok}[1]{\textcolor[rgb]{0.25,0.63,0.44}{{#1}}}
\newcommand{\BaseNTok}[1]{\textcolor[rgb]{0.25,0.63,0.44}{{#1}}}
\newcommand{\FloatTok}[1]{\textcolor[rgb]{0.25,0.63,0.44}{{#1}}}
\newcommand{\CharTok}[1]{\textcolor[rgb]{0.25,0.44,0.63}{{#1}}}
\newcommand{\StringTok}[1]{\textcolor[rgb]{0.25,0.44,0.63}{{#1}}}
\newcommand{\CommentTok}[1]{\textcolor[rgb]{0.38,0.63,0.69}{\textit{{#1}}}}
\newcommand{\OtherTok}[1]{\textcolor[rgb]{0.00,0.44,0.13}{{#1}}}
\newcommand{\AlertTok}[1]{\textcolor[rgb]{1.00,0.00,0.00}{\textbf{{#1}}}}
\newcommand{\FunctionTok}[1]{\textcolor[rgb]{0.02,0.16,0.49}{{#1}}}
\newcommand{\RegionMarkerTok}[1]{{#1}}
\newcommand{\ErrorTok}[1]{\textcolor[rgb]{1.00,0.00,0.00}{\textbf{{#1}}}}
\newcommand{\NormalTok}[1]{{#1}}
% Additional commands for more recent versions of Pandoc
\newcommand{\ConstantTok}[1]{\textcolor[rgb]{0.53,0.00,0.00}{{#1}}}
\newcommand{\SpecialCharTok}[1]{\textcolor[rgb]{0.25,0.44,0.63}{{#1}}}
\newcommand{\VerbatimStringTok}[1]{\textcolor[rgb]{0.25,0.44,0.63}{{#1}}}
\newcommand{\SpecialStringTok}[1]{\textcolor[rgb]{0.73,0.40,0.53}{{#1}}}
\newcommand{\ImportTok}[1]{{#1}}
\newcommand{\DocumentationTok}[1]{\textcolor[rgb]{0.73,0.13,0.13}{\textit{{#1}}}}
\newcommand{\AnnotationTok}[1]{\textcolor[rgb]{0.38,0.63,0.69}{\textbf{\textit{{#1}}}}}
\newcommand{\CommentVarTok}[1]{\textcolor[rgb]{0.38,0.63,0.69}{\textbf{\textit{{#1}}}}}
\newcommand{\VariableTok}[1]{\textcolor[rgb]{0.10,0.09,0.49}{{#1}}}
\newcommand{\ControlFlowTok}[1]{\textcolor[rgb]{0.00,0.44,0.13}{\textbf{{#1}}}}
\newcommand{\OperatorTok}[1]{\textcolor[rgb]{0.40,0.40,0.40}{{#1}}}
\newcommand{\BuiltInTok}[1]{{#1}}
\newcommand{\ExtensionTok}[1]{{#1}}
\newcommand{\PreprocessorTok}[1]{\textcolor[rgb]{0.74,0.48,0.00}{{#1}}}
\newcommand{\AttributeTok}[1]{\textcolor[rgb]{0.49,0.56,0.16}{{#1}}}
\newcommand{\InformationTok}[1]{\textcolor[rgb]{0.38,0.63,0.69}{\textbf{\textit{{#1}}}}}
\newcommand{\WarningTok}[1]{\textcolor[rgb]{0.38,0.63,0.69}{\textbf{\textit{{#1}}}}}
% Define a nice break command that doesn't care if a line doesn't already
% exist.
\def\br{\hspace*{\fill} \\* }
% Math Jax compatability definitions
\def\gt{>}
\def\lt{<}
% Document parameters
\title{CapsNET-EEG}
% Pygments definitions
\makeatletter
\def\PY@reset{\let\PY@it=\relax \let\PY@bf=\relax%
\let\PY@ul=\relax \let\PY@tc=\relax%
\let\PY@bc=\relax \let\PY@ff=\relax}
\def\PY@tok#1{\csname PY@tok@#1\endcsname}
\def\PY@toks#1+{\ifx\relax#1\empty\else%
\PY@tok{#1}\expandafter\PY@toks\fi}
\def\PY@do#1{\PY@bc{\PY@tc{\PY@ul{%
\PY@it{\PY@bf{\PY@ff{#1}}}}}}}
\def\PY#1#2{\PY@reset\PY@toks#1+\relax+\PY@do{#2}}
\expandafter\def\csname PY@tok@w\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.73,0.73,0.73}{##1}}}
\expandafter\def\csname PY@tok@c\endcsname{\let\PY@it=\textit\def\PY@tc##1{\textcolor[rgb]{0.25,0.50,0.50}{##1}}}
\expandafter\def\csname PY@tok@cp\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.74,0.48,0.00}{##1}}}
\expandafter\def\csname PY@tok@k\endcsname{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.00,0.50,0.00}{##1}}}
\expandafter\def\csname PY@tok@kp\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.00,0.50,0.00}{##1}}}
\expandafter\def\csname PY@tok@kt\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.69,0.00,0.25}{##1}}}
\expandafter\def\csname PY@tok@o\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.40,0.40,0.40}{##1}}}
\expandafter\def\csname PY@tok@ow\endcsname{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.67,0.13,1.00}{##1}}}
\expandafter\def\csname PY@tok@nb\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.00,0.50,0.00}{##1}}}
\expandafter\def\csname PY@tok@nf\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.00,0.00,1.00}{##1}}}
\expandafter\def\csname PY@tok@nc\endcsname{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.00,0.00,1.00}{##1}}}
\expandafter\def\csname PY@tok@nn\endcsname{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.00,0.00,1.00}{##1}}}
\expandafter\def\csname PY@tok@ne\endcsname{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.82,0.25,0.23}{##1}}}
\expandafter\def\csname PY@tok@nv\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.10,0.09,0.49}{##1}}}
\expandafter\def\csname PY@tok@no\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.53,0.00,0.00}{##1}}}
\expandafter\def\csname PY@tok@nl\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.63,0.63,0.00}{##1}}}
\expandafter\def\csname PY@tok@ni\endcsname{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.60,0.60,0.60}{##1}}}
\expandafter\def\csname PY@tok@na\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.49,0.56,0.16}{##1}}}
\expandafter\def\csname PY@tok@nt\endcsname{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.00,0.50,0.00}{##1}}}
\expandafter\def\csname PY@tok@nd\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.67,0.13,1.00}{##1}}}
\expandafter\def\csname PY@tok@s\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.73,0.13,0.13}{##1}}}
\expandafter\def\csname PY@tok@sd\endcsname{\let\PY@it=\textit\def\PY@tc##1{\textcolor[rgb]{0.73,0.13,0.13}{##1}}}
\expandafter\def\csname PY@tok@si\endcsname{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.73,0.40,0.53}{##1}}}
\expandafter\def\csname PY@tok@se\endcsname{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.73,0.40,0.13}{##1}}}
\expandafter\def\csname PY@tok@sr\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.73,0.40,0.53}{##1}}}
\expandafter\def\csname PY@tok@ss\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.10,0.09,0.49}{##1}}}
\expandafter\def\csname PY@tok@sx\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.00,0.50,0.00}{##1}}}
\expandafter\def\csname PY@tok@m\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.40,0.40,0.40}{##1}}}
\expandafter\def\csname PY@tok@gh\endcsname{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.00,0.00,0.50}{##1}}}
\expandafter\def\csname PY@tok@gu\endcsname{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.50,0.00,0.50}{##1}}}
\expandafter\def\csname PY@tok@gd\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.63,0.00,0.00}{##1}}}
\expandafter\def\csname PY@tok@gi\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.00,0.63,0.00}{##1}}}
\expandafter\def\csname PY@tok@gr\endcsname{\def\PY@tc##1{\textcolor[rgb]{1.00,0.00,0.00}{##1}}}
\expandafter\def\csname PY@tok@ge\endcsname{\let\PY@it=\textit}
\expandafter\def\csname PY@tok@gs\endcsname{\let\PY@bf=\textbf}
\expandafter\def\csname PY@tok@gp\endcsname{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.00,0.00,0.50}{##1}}}
\expandafter\def\csname PY@tok@go\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.53,0.53,0.53}{##1}}}
\expandafter\def\csname PY@tok@gt\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.00,0.27,0.87}{##1}}}
\expandafter\def\csname PY@tok@err\endcsname{\def\PY@bc##1{\setlength{\fboxsep}{0pt}\fcolorbox[rgb]{1.00,0.00,0.00}{1,1,1}{\strut ##1}}}
\expandafter\def\csname PY@tok@kc\endcsname{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.00,0.50,0.00}{##1}}}
\expandafter\def\csname PY@tok@kd\endcsname{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.00,0.50,0.00}{##1}}}
\expandafter\def\csname PY@tok@kn\endcsname{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.00,0.50,0.00}{##1}}}
\expandafter\def\csname PY@tok@kr\endcsname{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.00,0.50,0.00}{##1}}}
\expandafter\def\csname PY@tok@bp\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.00,0.50,0.00}{##1}}}
\expandafter\def\csname PY@tok@fm\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.00,0.00,1.00}{##1}}}
\expandafter\def\csname PY@tok@vc\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.10,0.09,0.49}{##1}}}
\expandafter\def\csname PY@tok@vg\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.10,0.09,0.49}{##1}}}
\expandafter\def\csname PY@tok@vi\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.10,0.09,0.49}{##1}}}
\expandafter\def\csname PY@tok@vm\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.10,0.09,0.49}{##1}}}
\expandafter\def\csname PY@tok@sa\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.73,0.13,0.13}{##1}}}
\expandafter\def\csname PY@tok@sb\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.73,0.13,0.13}{##1}}}
\expandafter\def\csname PY@tok@sc\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.73,0.13,0.13}{##1}}}
\expandafter\def\csname PY@tok@dl\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.73,0.13,0.13}{##1}}}
\expandafter\def\csname PY@tok@s2\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.73,0.13,0.13}{##1}}}
\expandafter\def\csname PY@tok@sh\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.73,0.13,0.13}{##1}}}
\expandafter\def\csname PY@tok@s1\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.73,0.13,0.13}{##1}}}
\expandafter\def\csname PY@tok@mb\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.40,0.40,0.40}{##1}}}
\expandafter\def\csname PY@tok@mf\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.40,0.40,0.40}{##1}}}
\expandafter\def\csname PY@tok@mh\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.40,0.40,0.40}{##1}}}
\expandafter\def\csname PY@tok@mi\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.40,0.40,0.40}{##1}}}
\expandafter\def\csname PY@tok@il\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.40,0.40,0.40}{##1}}}
\expandafter\def\csname PY@tok@mo\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.40,0.40,0.40}{##1}}}
\expandafter\def\csname PY@tok@ch\endcsname{\let\PY@it=\textit\def\PY@tc##1{\textcolor[rgb]{0.25,0.50,0.50}{##1}}}
\expandafter\def\csname PY@tok@cm\endcsname{\let\PY@it=\textit\def\PY@tc##1{\textcolor[rgb]{0.25,0.50,0.50}{##1}}}
\expandafter\def\csname PY@tok@cpf\endcsname{\let\PY@it=\textit\def\PY@tc##1{\textcolor[rgb]{0.25,0.50,0.50}{##1}}}
\expandafter\def\csname PY@tok@c1\endcsname{\let\PY@it=\textit\def\PY@tc##1{\textcolor[rgb]{0.25,0.50,0.50}{##1}}}
\expandafter\def\csname PY@tok@cs\endcsname{\let\PY@it=\textit\def\PY@tc##1{\textcolor[rgb]{0.25,0.50,0.50}{##1}}}
\def\PYZbs{\char`\\}
\def\PYZus{\char`\_}
\def\PYZob{\char`\{}
\def\PYZcb{\char`\}}
\def\PYZca{\char`\^}
\def\PYZam{\char`\&}
\def\PYZlt{\char`\<}
\def\PYZgt{\char`\>}
\def\PYZsh{\char`\#}
\def\PYZpc{\char`\%}
\def\PYZdl{\char`\$}
\def\PYZhy{\char`\-}
\def\PYZsq{\char`\'}
\def\PYZdq{\char`\"}
\def\PYZti{\char`\~}
% for compatibility with earlier versions
\def\PYZat{@}
\def\PYZlb{[}
\def\PYZrb{]}
\makeatother
% Exact colors from NB
\definecolor{incolor}{rgb}{0.0, 0.0, 0.5}
\definecolor{outcolor}{rgb}{0.545, 0.0, 0.0}
% Prevent overflowing lines due to hard-to-break entities
\sloppy
% Setup hyperref package
\hypersetup{
breaklinks=true, % so long urls are correctly broken across lines
colorlinks=true,
urlcolor=urlcolor,
linkcolor=linkcolor,
citecolor=citecolor,
}
% Slightly bigger margins than the latex defaults
\geometry{verbose,tmargin=1in,bmargin=1in,lmargin=1in,rmargin=1in}
\begin{document}
\maketitle
\begin{Verbatim}[commandchars=\\\{\}]
{\color{incolor}In [{\color{incolor}1}]:} \PY{c+c1}{\PYZsh{} make sure you don\PYZsq{}t hog all the video memory}
\PY{k+kn}{import} \PY{n+nn}{tensorflow} \PY{k}{as} \PY{n+nn}{tf}
\PY{n}{config} \PY{o}{=} \PY{n}{tf}\PY{o}{.}\PY{n}{ConfigProto}\PY{p}{(}\PY{p}{)}
\PY{n}{config}\PY{o}{.}\PY{n}{gpu\PYZus{}options}\PY{o}{.}\PY{n}{allow\PYZus{}growth} \PY{o}{=} \PY{k+kc}{True}
\PY{n}{sess} \PY{o}{=} \PY{n}{tf}\PY{o}{.}\PY{n}{Session}\PY{p}{(}\PY{n}{config}\PY{o}{=}\PY{n}{config}\PY{p}{)}
\PY{k+kn}{from} \PY{n+nn}{keras} \PY{k}{import} \PY{n}{backend} \PY{k}{as} \PY{n}{K}
\PY{n}{K}\PY{o}{.}\PY{n}{set\PYZus{}session}\PY{p}{(}\PY{n}{sess}\PY{p}{)}
\PY{c+c1}{\PYZsh{}\PYZsh{}\PYZsh{}\PYZsh{}\PYZsh{}\PYZsh{}\PYZsh{}\PYZsh{}\PYZsh{}\PYZsh{}\PYZsh{}\PYZsh{}\PYZsh{}\PYZsh{}\PYZsh{}\PYZsh{}\PYZsh{}\PYZsh{}\PYZsh{}\PYZsh{}\PYZsh{}\PYZsh{}\PYZsh{}\PYZsh{}\PYZsh{}\PYZsh{}\PYZsh{}\PYZsh{}\PYZsh{}\PYZsh{}\PYZsh{}\PYZsh{}\PYZsh{}\PYZsh{}\PYZsh{}}
\PY{k+kn}{import} \PY{n+nn}{numpy} \PY{k}{as} \PY{n+nn}{np}
\PY{k+kn}{from} \PY{n+nn}{keras} \PY{k}{import} \PY{n}{layers}\PY{p}{,} \PY{n}{models}\PY{p}{,} \PY{n}{optimizers}
\PY{k+kn}{from} \PY{n+nn}{keras}\PY{n+nn}{.}\PY{n+nn}{utils} \PY{k}{import} \PY{n}{to\PYZus{}categorical}
\PY{k+kn}{import} \PY{n+nn}{matplotlib}\PY{n+nn}{.}\PY{n+nn}{pyplot} \PY{k}{as} \PY{n+nn}{plt}
\PY{o}{\PYZpc{}} \PY{n}{matplotlib} \PY{n}{inline}
\PY{k+kn}{from} \PY{n+nn}{PIL} \PY{k}{import} \PY{n}{Image}
\PY{k+kn}{from} \PY{n+nn}{capsulelayers} \PY{k}{import} \PY{n}{CapsuleLayer}\PY{p}{,} \PY{n}{PrimaryCap}\PY{p}{,} \PY{n}{Length}\PY{p}{,} \PY{n}{Mask}
\PY{k+kn}{from} \PY{n+nn}{keras}\PY{n+nn}{.}\PY{n+nn}{datasets} \PY{k}{import} \PY{n}{mnist}
\PY{k+kn}{from} \PY{n+nn}{sklearn}\PY{n+nn}{.}\PY{n+nn}{model\PYZus{}selection} \PY{k}{import} \PY{n}{train\PYZus{}test\PYZus{}split}
\PY{k+kn}{from} \PY{n+nn}{sklearn} \PY{k}{import} \PY{n}{preprocessing}
\PY{k+kn}{import} \PY{n+nn}{scipy}\PY{n+nn}{.}\PY{n+nn}{io} \PY{k}{as} \PY{n+nn}{sio}
\end{Verbatim}
\begin{Verbatim}[commandchars=\\\{\}]
Using TensorFlow backend.
\end{Verbatim}
\begin{Verbatim}[commandchars=\\\{\}]
{\color{incolor}In [{\color{incolor}54}]:} \PY{k}{def} \PY{n+nf}{group\PYZus{}frequency\PYZus{}bands}\PY{p}{(}\PY{n}{X}\PY{p}{)}\PY{p}{:}
\PY{n}{X\PYZus{}} \PY{o}{=} \PY{n}{np}\PY{o}{.}\PY{n}{zeros}\PY{p}{(}\PY{p}{[}\PY{n}{X}\PY{o}{.}\PY{n}{shape}\PY{p}{[}\PY{l+m+mi}{0}\PY{p}{]}\PY{p}{,}\PY{n}{X}\PY{o}{.}\PY{n}{shape}\PY{p}{[}\PY{l+m+mi}{1}\PY{p}{]}\PY{p}{,}\PY{n}{X}\PY{o}{.}\PY{n}{shape}\PY{p}{[}\PY{l+m+mi}{2}\PY{p}{]}\PY{p}{,} \PY{l+m+mi}{2}\PY{p}{]}\PY{p}{)}
\PY{c+c1}{\PYZsh{} X\PYZus{}[:,:,:,0] = np.mean(X[:,:,:,3:6],axis=3)}
\PY{c+c1}{\PYZsh{} X\PYZus{}[:,:,:,1] = np.mean(X[:,:,:,7:11],axis=3)}
\PY{c+c1}{\PYZsh{} X\PYZus{}[:,:,:,2] = np.mean(X[:,:,:,12:29],axis=3)}
\PY{c+c1}{\PYZsh{} processing frequencies: 0 16}
\PY{c+c1}{\PYZsh{} processing frequencies: 16 32}
\PY{c+c1}{\PYZsh{} processing frequencies: 32 49}
\PY{c+c1}{\PYZsh{} processing frequencies: 49 65}
\PY{c+c1}{\PYZsh{} X\PYZus{}[:,:,:,0] = np.mean(X[:,:,:,0:16],axis=3)}
\PY{c+c1}{\PYZsh{} X\PYZus{}[:,:,:,1] = np.mean(X[:,:,:,16:32],axis=3)}
\PY{n}{X\PYZus{}}\PY{p}{[}\PY{p}{:}\PY{p}{,}\PY{p}{:}\PY{p}{,}\PY{p}{:}\PY{p}{,}\PY{l+m+mi}{0}\PY{p}{]} \PY{o}{=} \PY{n}{np}\PY{o}{.}\PY{n}{mean}\PY{p}{(}\PY{n}{X}\PY{p}{[}\PY{p}{:}\PY{p}{,}\PY{p}{:}\PY{p}{,}\PY{p}{:}\PY{p}{,}\PY{l+m+mi}{32}\PY{p}{:}\PY{l+m+mi}{49}\PY{p}{]}\PY{p}{,}\PY{n}{axis}\PY{o}{=}\PY{l+m+mi}{3}\PY{p}{)}
\PY{n}{X\PYZus{}}\PY{p}{[}\PY{p}{:}\PY{p}{,}\PY{p}{:}\PY{p}{,}\PY{p}{:}\PY{p}{,}\PY{l+m+mi}{1}\PY{p}{]} \PY{o}{=} \PY{n}{np}\PY{o}{.}\PY{n}{mean}\PY{p}{(}\PY{n}{X}\PY{p}{[}\PY{p}{:}\PY{p}{,}\PY{p}{:}\PY{p}{,}\PY{p}{:}\PY{p}{,}\PY{l+m+mi}{49}\PY{p}{:}\PY{l+m+mi}{65}\PY{p}{]}\PY{p}{,}\PY{n}{axis}\PY{o}{=}\PY{l+m+mi}{3}\PY{p}{)}
\PY{n}{X\PYZus{}}\PY{o}{.}\PY{n}{shape}
\PY{c+c1}{\PYZsh{} subplot(1,3,1)}
\PY{c+c1}{\PYZsh{} imagesc(squeeze(mean(X(1,:,:,4:7), 4)))}
\PY{c+c1}{\PYZsh{} title(\PYZsq{}Theta\PYZsq{})}
\PY{c+c1}{\PYZsh{} subplot(1,3,2)}
\PY{c+c1}{\PYZsh{} imagesc(squeeze(mean(X(1,:,:,8:12), 4)))}
\PY{c+c1}{\PYZsh{} title(\PYZsq{}Alpha\PYZsq{})}
\PY{c+c1}{\PYZsh{} subplot(1,3,3)}
\PY{c+c1}{\PYZsh{} imagesc(squeeze(mean(X(1,:,:,13:30), 4)))}
\PY{c+c1}{\PYZsh{} title(\PYZsq{}Beta\PYZsq{})}
\PY{k}{return} \PY{n}{X\PYZus{}}
\PY{k}{def} \PY{n+nf}{im\PYZus{}resize}\PY{p}{(}\PY{n}{X\PYZus{}}\PY{p}{,} \PY{n}{height}\PY{p}{,} \PY{n}{width}\PY{p}{)}\PY{p}{:}
\PY{k}{if} \PY{n}{width}\PY{o}{\PYZgt{}}\PY{l+m+mi}{0} \PY{o+ow}{and} \PY{n}{height}\PY{o}{\PYZgt{}}\PY{l+m+mi}{0}\PY{p}{:}
\PY{n}{X\PYZus{}\PYZus{}} \PY{o}{=} \PY{n}{np}\PY{o}{.}\PY{n}{zeros}\PY{p}{(}\PY{p}{[}\PY{n}{X\PYZus{}}\PY{o}{.}\PY{n}{shape}\PY{p}{[}\PY{l+m+mi}{0}\PY{p}{]}\PY{p}{,} \PY{n}{height}\PY{p}{,} \PY{n}{width}\PY{p}{,} \PY{n}{X\PYZus{}}\PY{o}{.}\PY{n}{shape}\PY{p}{[}\PY{l+m+mi}{3}\PY{p}{]}\PY{p}{]}\PY{p}{)}
\PY{k}{for} \PY{n}{i} \PY{o+ow}{in} \PY{n+nb}{range}\PY{p}{(}\PY{n}{X\PYZus{}}\PY{o}{.}\PY{n}{shape}\PY{p}{[}\PY{l+m+mi}{0}\PY{p}{]}\PY{p}{)}\PY{p}{:}
\PY{k}{for} \PY{n}{j} \PY{o+ow}{in} \PY{n+nb}{range}\PY{p}{(}\PY{n}{X\PYZus{}}\PY{o}{.}\PY{n}{shape}\PY{p}{[}\PY{l+m+mi}{3}\PY{p}{]}\PY{p}{)}\PY{p}{:}
\PY{n}{im} \PY{o}{=} \PY{n}{Image}\PY{o}{.}\PY{n}{fromarray}\PY{p}{(}\PY{n}{X\PYZus{}}\PY{p}{[}\PY{n}{i}\PY{p}{,}\PY{p}{:}\PY{p}{,}\PY{p}{:}\PY{p}{,}\PY{n}{j}\PY{p}{]}\PY{p}{)}
\PY{n}{X\PYZus{}\PYZus{}}\PY{p}{[}\PY{n}{i}\PY{p}{,}\PY{p}{:}\PY{p}{,}\PY{p}{:}\PY{p}{,}\PY{n}{j}\PY{p}{]} \PY{o}{=} \PY{n}{im}\PY{o}{.}\PY{n}{resize}\PY{p}{(}\PY{p}{(}\PY{n}{height}\PY{p}{,} \PY{n}{width}\PY{p}{)}\PY{p}{,} \PY{n}{Image}\PY{o}{.}\PY{n}{ANTIALIAS}\PY{p}{)}
\PY{n+nb}{print} \PY{p}{(}\PY{n}{X\PYZus{}\PYZus{}}\PY{o}{.}\PY{n}{shape}\PY{p}{)}
\PY{n}{plt}\PY{o}{.}\PY{n}{subplot}\PY{p}{(}\PY{l+m+mi}{121}\PY{p}{)}
\PY{n}{plt}\PY{o}{.}\PY{n}{imshow}\PY{p}{(}\PY{n}{np}\PY{o}{.}\PY{n}{array}\PY{p}{(}\PY{n}{X\PYZus{}}\PY{p}{[}\PY{l+m+mi}{200}\PY{p}{,}\PY{p}{:}\PY{p}{,}\PY{p}{:}\PY{p}{,}\PY{l+m+mi}{1}\PY{p}{]}\PY{p}{)}\PY{p}{)}
\PY{n}{plt}\PY{o}{.}\PY{n}{subplot}\PY{p}{(}\PY{l+m+mi}{122}\PY{p}{)}
\PY{n}{plt}\PY{o}{.}\PY{n}{imshow}\PY{p}{(}\PY{n}{np}\PY{o}{.}\PY{n}{array}\PY{p}{(}\PY{n}{X\PYZus{}\PYZus{}}\PY{p}{[}\PY{l+m+mi}{200}\PY{p}{,}\PY{p}{:}\PY{p}{,}\PY{p}{:}\PY{p}{,}\PY{l+m+mi}{1}\PY{p}{]}\PY{p}{)}\PY{p}{)}
\PY{k}{else}\PY{p}{:}
\PY{n+nb}{print}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{IMAGES NOT RESIZED}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)}
\PY{k}{return} \PY{n}{X\PYZus{}\PYZus{}}
\PY{k}{def} \PY{n+nf}{downsample\PYZus{}frequency\PYZus{}domain}\PY{p}{(}\PY{n}{n\PYZus{}bins}\PY{p}{)}\PY{p}{:}
\PY{n+nb}{print}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Downsampling the frequency domain from}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,} \PY{n}{X}\PY{o}{.}\PY{n}{shape}\PY{p}{[}\PY{l+m+mi}{3}\PY{p}{]}\PY{p}{,}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{to}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,} \PY{n}{n\PYZus{}bins}\PY{p}{)}
\PY{n}{xx} \PY{o}{=} \PY{n}{np}\PY{o}{.}\PY{n}{zeros}\PY{p}{(}\PY{p}{[}\PY{n}{X}\PY{o}{.}\PY{n}{shape}\PY{p}{[}\PY{l+m+mi}{0}\PY{p}{]}\PY{p}{,}\PY{n}{X}\PY{o}{.}\PY{n}{shape}\PY{p}{[}\PY{l+m+mi}{1}\PY{p}{]}\PY{p}{,}\PY{n}{X}\PY{o}{.}\PY{n}{shape}\PY{p}{[}\PY{l+m+mi}{2}\PY{p}{]}\PY{p}{,}\PY{n}{n\PYZus{}bins}\PY{p}{]}\PY{p}{)}
\PY{n+nb}{print}\PY{p}{(}\PY{n}{xx}\PY{o}{.}\PY{n}{shape}\PY{p}{)}
\PY{n}{a} \PY{o}{=} \PY{n}{np}\PY{o}{.}\PY{n}{round}\PY{p}{(}\PY{n}{np}\PY{o}{.}\PY{n}{linspace}\PY{p}{(}\PY{l+m+mi}{0}\PY{p}{,}\PY{n}{X}\PY{o}{.}\PY{n}{shape}\PY{p}{[}\PY{l+m+mi}{3}\PY{p}{]}\PY{p}{,}\PY{n}{n\PYZus{}bins}\PY{o}{+}\PY{l+m+mi}{1}\PY{p}{)}\PY{p}{)}
\PY{n}{a} \PY{o}{=} \PY{n}{a}\PY{o}{.}\PY{n}{astype}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{uint8}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)}
\PY{n+nb}{print}\PY{p}{(}\PY{n}{a}\PY{p}{)}
\PY{k}{for} \PY{n}{i} \PY{o+ow}{in} \PY{n+nb}{range}\PY{p}{(}\PY{n}{n\PYZus{}bins}\PY{p}{)}\PY{p}{:}
\PY{n}{xx}\PY{p}{[}\PY{p}{:}\PY{p}{,}\PY{p}{:}\PY{p}{,}\PY{p}{:}\PY{p}{,}\PY{n}{i}\PY{p}{]} \PY{o}{=} \PY{n}{np}\PY{o}{.}\PY{n}{mean}\PY{p}{(}\PY{n}{X}\PY{p}{[}\PY{p}{:}\PY{p}{,}\PY{p}{:}\PY{p}{,}\PY{p}{:}\PY{p}{,}\PY{n}{a}\PY{p}{[}\PY{n}{i}\PY{p}{]}\PY{p}{:}\PY{n}{a}\PY{p}{[}\PY{n}{i}\PY{o}{+}\PY{l+m+mi}{1}\PY{p}{]}\PY{p}{]}\PY{p}{,} \PY{n}{axis}\PY{o}{=}\PY{l+m+mi}{3}\PY{p}{)}
\PY{n+nb}{print}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{processing frequencies:}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,} \PY{n}{a}\PY{p}{[}\PY{n}{i}\PY{p}{]}\PY{p}{,} \PY{n}{a}\PY{p}{[}\PY{n}{i}\PY{o}{+}\PY{l+m+mi}{1}\PY{p}{]}\PY{p}{)}
\PY{n+nb}{print}\PY{p}{(}\PY{n}{xx}\PY{o}{.}\PY{n}{shape}\PY{p}{)}
\PY{k}{return} \PY{n}{xx}
\PY{k}{def} \PY{n+nf}{parse\PYZus{}array}\PY{p}{(}\PY{n}{in\PYZus{}array}\PY{p}{)}\PY{p}{:}
\PY{n}{new\PYZus{}array} \PY{o}{=} \PY{p}{[}\PY{p}{]}
\PY{k}{for} \PY{n}{i} \PY{o+ow}{in} \PY{n+nb}{range}\PY{p}{(}\PY{n+nb}{len}\PY{p}{(}\PY{n}{in\PYZus{}array}\PY{p}{)}\PY{p}{)}\PY{p}{:}
\PY{k}{if} \PY{n+nb}{str}\PY{p}{(}\PY{n}{in\PYZus{}array}\PY{p}{[}\PY{n}{i}\PY{p}{]}\PY{p}{)}\PY{o}{.}\PY{n}{find}\PY{p}{(}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{left}\PY{l+s+s2}{\PYZdq{}}\PY{p}{)}\PY{o}{\PYZgt{}}\PY{l+m+mi}{0}\PY{p}{:}
\PY{n}{new\PYZus{}array}\PY{o}{.}\PY{n}{append}\PY{p}{(}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{left}\PY{l+s+s2}{\PYZdq{}}\PY{p}{)}
\PY{k}{if} \PY{n+nb}{str}\PY{p}{(}\PY{n}{in\PYZus{}array}\PY{p}{[}\PY{n}{i}\PY{p}{]}\PY{p}{)}\PY{o}{.}\PY{n}{find}\PY{p}{(}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{right}\PY{l+s+s2}{\PYZdq{}}\PY{p}{)}\PY{o}{\PYZgt{}}\PY{l+m+mi}{0}\PY{p}{:}
\PY{n}{new\PYZus{}array}\PY{o}{.}\PY{n}{append}\PY{p}{(}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{right}\PY{l+s+s2}{\PYZdq{}}\PY{p}{)}
\PY{k}{if} \PY{p}{(}\PY{n+nb}{str}\PY{p}{(}\PY{n}{in\PYZus{}array}\PY{p}{[}\PY{n}{i}\PY{p}{]}\PY{p}{)}\PY{o}{.}\PY{n}{find}\PY{p}{(}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{left}\PY{l+s+s2}{\PYZdq{}}\PY{p}{)}\PY{o}{\PYZlt{}}\PY{l+m+mi}{0} \PY{o+ow}{and}
\PY{n+nb}{str}\PY{p}{(}\PY{n}{in\PYZus{}array}\PY{p}{[}\PY{n}{i}\PY{p}{]}\PY{p}{)}\PY{o}{.}\PY{n}{find}\PY{p}{(}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{right}\PY{l+s+s2}{\PYZdq{}}\PY{p}{)}\PY{o}{\PYZlt{}}\PY{l+m+mi}{0}\PY{p}{)}\PY{p}{:}
\PY{n+nb}{print}\PY{p}{(}\PY{n}{i}\PY{p}{)}
\PY{n}{new\PYZus{}array}\PY{o}{.}\PY{n}{append}\PY{p}{(}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{unknown}\PY{l+s+s2}{\PYZdq{}}\PY{p}{)}
\PY{k}{return} \PY{n}{new\PYZus{}array}
\PY{k}{def} \PY{n+nf}{find\PYZus{}right}\PY{p}{(}\PY{n}{Q}\PY{p}{,} \PY{n}{label}\PY{p}{)}\PY{p}{:}
\PY{n}{idx} \PY{o}{=} \PY{p}{[}\PY{p}{]}
\PY{k}{for} \PY{n}{i} \PY{o+ow}{in} \PY{n+nb}{range}\PY{p}{(}\PY{n+nb}{len}\PY{p}{(}\PY{n}{Q}\PY{p}{)}\PY{p}{)}\PY{p}{:}
\PY{k}{if} \PY{n}{Q}\PY{p}{[}\PY{n}{i}\PY{p}{]} \PY{o}{==} \PY{n}{label}\PY{p}{:}
\PY{n}{idx}\PY{o}{.}\PY{n}{append}\PY{p}{(}\PY{n}{i}\PY{p}{)}
\PY{k}{return}\PY{p}{(}\PY{n}{idx}\PY{p}{)}
\PY{n}{file} \PY{o}{=} \PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Merged456\PYZhy{}197\PYZhy{}289\PYZus{}ICA(\PYZhy{}eyes)+AUDpreproc.mat, DS2=64Hz, FIR=1\PYZhy{}30Hz, centnorm=1, step=2, win=2, TOPO, .mat}\PY{l+s+s1}{\PYZsq{}} \PY{c+c1}{\PYZsh{}0.78 (CapsNet\PYZus{}EEG)}
\PY{c+c1}{\PYZsh{} file = \PYZsq{}Merged456\PYZhy{}197\PYZhy{}289\PYZus{}ICA(\PYZhy{}eyes)+AUDpreproc.mat, DS2=64Hz, FIR=1\PYZhy{}30Hz, centnorm=1, step=1, win=2, TOPO, .mat\PYZsq{} \PYZsh{}2\PYZsh{} \PYZsh{}0.77}
\PY{c+c1}{\PYZsh{} file = \PYZsq{}Merged456\PYZhy{}1\PYZhy{}94\PYZus{}ICA(\PYZhy{}2,3ICs)+AUDpreproc.mat, DS2=64Hz, FIR=1\PYZhy{}30Hz, centnorm=1, step=2, win=2, TOPO, .mat\PYZsq{} \PYZsh{}1\PYZsh{} \PYZsh{}0.76 \PYZsh{}0.79}
\PY{c+c1}{\PYZsh{} file = \PYZsq{}EEG\PYZus{}ICA(\PYZhy{}123\PYZus{}ICs)+proc\PYZus{}AUD\PYZus{}101\PYZus{}192\PYZus{}Merged456.mat, DS2=64Hz, FIR=1\PYZhy{}30Hz, centnorm=1, step=2, win=2, TOPO, .mat\PYZsq{} \PYZsh{} 0.60 (CapsNet\PYZus{}EEG)}
\PY{c+c1}{\PYZsh{} file = \PYZsq{}Merged123\PYZus{}1\PYZus{}64\PYZus{}ICA(\PYZhy{}eyes)AUDpreproc.mat, DS2=64Hz, FIR=1\PYZhy{}30Hz, centnorm=1, step=1, win=1, TOPO, .mat\PYZsq{} \PYZsh{} 0.60 CapsNET\PYZus{}EEG}
\PY{c+c1}{\PYZsh{} file = \PYZsq{}Merged123\PYZus{}75\PYZus{}134\PYZus{}ICA(\PYZhy{}eyes)AUDpreproc.mat, DS2=64Hz, FIR=1\PYZhy{}30Hz, centnorm=1, step=1, win=2, TOPO, .mat\PYZsq{}}
\PY{c+c1}{\PYZsh{} file = \PYZsq{}Merged123\PYZhy{}143\PYZhy{}202\PYZus{}ICA(\PYZhy{}Eyes)+AUDpreproc.mat, DS2=64Hz, FIR=1\PYZhy{}30Hz, centnorm=1, step=1, win=2, TOPO, .mat\PYZsq{} \PYZsh{}0.56}
\PY{n}{SHUFFLE} \PY{o}{=} \PY{k+kc}{False}
\PY{n}{TEST\PYZus{}TRAIN} \PY{o}{=} \PY{l+m+mf}{0.2}
\PY{n}{DS\PYZus{}FREQ} \PY{o}{=} \PY{l+m+mi}{1} \PY{c+c1}{\PYZsh{}(0 1 2)}
\PY{n}{n\PYZus{}bins} \PY{o}{=} \PY{l+m+mi}{8}
\PY{n}{RESIZE} \PY{o}{=} \PY{l+m+mi}{1}
\PY{n}{width} \PY{o}{=} \PY{l+m+mi}{15}
\PY{n}{height} \PY{o}{=} \PY{l+m+mi}{15}
\PY{n}{SENSITIVITY} \PY{o}{=} \PY{l+m+mi}{0}
\PY{n}{knockouts} \PY{o}{=} \PY{p}{[}\PY{l+m+mi}{0}\PY{p}{,} \PY{l+m+mi}{1}\PY{p}{,} \PY{l+m+mi}{2}\PY{p}{]}
\PY{n}{path} \PY{o}{=} \PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{/home/amplifier/home/DATASETS/}\PY{l+s+s1}{\PYZsq{}} \PY{o}{+} \PY{n}{file}
\PY{n}{mat\PYZus{}contents} \PY{o}{=} \PY{n}{sio}\PY{o}{.}\PY{n}{loadmat}\PY{p}{(}\PY{n}{path}\PY{p}{)}
\PY{n}{X} \PY{o}{=} \PY{n}{mat\PYZus{}contents}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{X}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}
\PY{n}{Y} \PY{o}{=} \PY{n}{mat\PYZus{}contents}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Z}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}
\PY{c+c1}{\PYZsh{} Z = mat\PYZus{}contents[\PYZsq{}Z\PYZsq{}]}
\PY{n}{Q} \PY{o}{=} \PY{n}{parse\PYZus{}array}\PY{p}{(}\PY{n}{mat\PYZus{}contents}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Q}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}\PY{p}{)}
\PY{k}{if} \PY{n}{DS\PYZus{}FREQ}\PY{o}{==}\PY{l+m+mi}{1}\PY{p}{:}
\PY{n}{X} \PY{o}{=} \PY{n}{downsample\PYZus{}frequency\PYZus{}domain}\PY{p}{(}\PY{n}{n\PYZus{}bins}\PY{p}{)}
\PY{n+nb}{print}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Downsampled Frequency Domain shape}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,} \PY{n}{X}\PY{o}{.}\PY{n}{shape}\PY{p}{)}
\PY{k}{if} \PY{n}{DS\PYZus{}FREQ}\PY{o}{==}\PY{l+m+mi}{2}\PY{p}{:}
\PY{n}{X} \PY{o}{=} \PY{n}{group\PYZus{}frequency\PYZus{}bands}\PY{p}{(}\PY{n}{X}\PY{p}{)}
\PY{n+nb}{print}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Grouped Frequency Bands shape}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,} \PY{n}{X}\PY{o}{.}\PY{n}{shape}\PY{p}{)}
\PY{k}{if} \PY{n}{RESIZE}\PY{o}{==}\PY{l+m+mi}{1}\PY{p}{:}
\PY{n}{X} \PY{o}{=} \PY{n}{im\PYZus{}resize}\PY{p}{(}\PY{n}{X}\PY{p}{,} \PY{n}{height}\PY{p}{,} \PY{n}{width}\PY{p}{)}
\PY{n+nb}{print}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Resized shape}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,} \PY{n}{X}\PY{o}{.}\PY{n}{shape}\PY{p}{)}
\PY{k}{if} \PY{n}{SENSITIVITY}\PY{o}{==}\PY{l+m+mi}{1}\PY{p}{:}
\PY{n}{X} \PY{o}{=} \PY{n}{np}\PY{o}{.}\PY{n}{delete}\PY{p}{(}\PY{n}{X}\PY{p}{,} \PY{n}{knockouts}\PY{p}{,} \PY{n}{axis}\PY{o}{=}\PY{l+m+mi}{3}\PY{p}{)}
\PY{n+nb}{print}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{sens}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,} \PY{n}{X}\PY{o}{.}\PY{n}{shape}\PY{p}{)}
\PY{k}{if} \PY{n}{X}\PY{o}{.}\PY{n}{shape}\PY{p}{[}\PY{l+m+mi}{1}\PY{p}{]}\PY{o}{\PYZlt{}}\PY{n}{X}\PY{o}{.}\PY{n}{shape}\PY{p}{[}\PY{l+m+mi}{2}\PY{p}{]}\PY{p}{:}
\PY{n}{X} \PY{o}{=} \PY{n}{np}\PY{o}{.}\PY{n}{transpose}\PY{p}{(}\PY{n}{X}\PY{p}{,}\PY{p}{[}\PY{l+m+mi}{0}\PY{p}{,}\PY{l+m+mi}{2}\PY{p}{,}\PY{l+m+mi}{1}\PY{p}{]}\PY{p}{)}
\PY{k}{if} \PY{n}{Y}\PY{o}{.}\PY{n}{shape}\PY{p}{[}\PY{l+m+mi}{1}\PY{p}{]} \PY{o}{\PYZgt{}} \PY{n}{Y}\PY{o}{.}\PY{n}{shape}\PY{p}{[}\PY{l+m+mi}{0}\PY{p}{]}\PY{p}{:}
\PY{n}{Y} \PY{o}{=} \PY{n}{Y}\PY{o}{.}\PY{n}{T}
\PY{c+c1}{\PYZsh{} verify that the model REALLY finds a mapping between the input and the labels. If we get}
\PY{c+c1}{\PYZsh{} our accuracy by chance, then we should get the same accuracy on a permuted dataset:}
\PY{c+c1}{\PYZsh{} Y = np.random.permutation(Y)}
\PY{n+nb}{print}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)}
\PY{n}{x\PYZus{}train}\PY{p}{,} \PY{n}{x\PYZus{}test}\PY{p}{,} \PY{n}{y\PYZus{}train}\PY{p}{,} \PY{n}{y\PYZus{}test}\PY{p}{,} \PY{n}{q\PYZus{}train}\PY{p}{,} \PY{n}{q\PYZus{}test} \PY{o}{=} \PY{n}{train\PYZus{}test\PYZus{}split}\PY{p}{(}\PY{n}{X}\PY{p}{,} \PY{n}{Y}\PY{p}{,} \PY{n}{Q}\PY{p}{,} \PY{n}{test\PYZus{}size}\PY{o}{=}\PY{n}{TEST\PYZus{}TRAIN}\PY{p}{,} \PY{n}{shuffle}\PY{o}{=}\PY{n}{SHUFFLE}\PY{p}{)}
\PY{n+nb}{print}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Original data type:}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,} \PY{n}{x\PYZus{}train}\PY{o}{.}\PY{n}{dtype}\PY{p}{)}
\PY{c+c1}{\PYZsh{} convert to float64 for numerical stability:}
\PY{n}{x\PYZus{}train} \PY{o}{=} \PY{n}{x\PYZus{}train}\PY{o}{.}\PY{n}{astype}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{float64}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)}
\PY{n}{y\PYZus{}train} \PY{o}{=} \PY{n}{y\PYZus{}train}\PY{o}{.}\PY{n}{astype}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{float64}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)}
\PY{n}{x\PYZus{}test} \PY{o}{=} \PY{n}{x\PYZus{}test}\PY{o}{.}\PY{n}{astype}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{float64}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)}
\PY{n}{y\PYZus{}test} \PY{o}{=} \PY{n}{y\PYZus{}test}\PY{o}{.}\PY{n}{astype}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{float64}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)}
\PY{n+nb}{print}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{y\PYZus{}test.shape before}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,} \PY{n}{y\PYZus{}test}\PY{o}{.}\PY{n}{shape}\PY{p}{)}
\PY{c+c1}{\PYZsh{} one hot encode the labels:}
\PY{n}{onehot\PYZus{}encoder} \PY{o}{=} \PY{n}{preprocessing}\PY{o}{.}\PY{n}{OneHotEncoder}\PY{p}{(}\PY{n}{sparse}\PY{o}{=}\PY{k+kc}{False}\PY{p}{)}
\PY{n}{y\PYZus{}train} \PY{o}{=} \PY{n}{onehot\PYZus{}encoder}\PY{o}{.}\PY{n}{fit\PYZus{}transform}\PY{p}{(}\PY{n}{y\PYZus{}train}\PY{p}{)}
\PY{n}{y\PYZus{}test} \PY{o}{=} \PY{n}{onehot\PYZus{}encoder}\PY{o}{.}\PY{n}{fit\PYZus{}transform}\PY{p}{(}\PY{n}{y\PYZus{}test}\PY{p}{)}
\PY{n+nb}{print}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{y\PYZus{}test.shape after}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,} \PY{n}{y\PYZus{}test}\PY{o}{.}\PY{n}{shape}\PY{p}{)}
\PY{c+c1}{\PYZsh{} convert to float16 to save space:}
\PY{n}{x\PYZus{}train} \PY{o}{=} \PY{n}{x\PYZus{}train}\PY{o}{.}\PY{n}{astype}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{float16}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)}
\PY{n}{y\PYZus{}train} \PY{o}{=} \PY{n}{y\PYZus{}train}\PY{o}{.}\PY{n}{astype}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{float16}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)}
\PY{n}{x\PYZus{}test} \PY{o}{=} \PY{n}{x\PYZus{}test}\PY{o}{.}\PY{n}{astype}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{float16}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)}
\PY{n}{y\PYZus{}test} \PY{o}{=} \PY{n}{y\PYZus{}test}\PY{o}{.}\PY{n}{astype}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{float16}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)}
\PY{n+nb}{print}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Normalized data type:}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,} \PY{n}{x\PYZus{}train}\PY{o}{.}\PY{n}{dtype}\PY{p}{)}
\PY{n}{leng} \PY{o}{=} \PY{n}{X}\PY{o}{.}\PY{n}{shape}\PY{p}{[}\PY{l+m+mi}{1}\PY{p}{]} \PY{c+c1}{\PYZsh{} if you work in the FD, this is the height of the sample time\PYZhy{}frequency image, othewise EEG channels}
\PY{n}{chan} \PY{o}{=} \PY{n}{X}\PY{o}{.}\PY{n}{shape}\PY{p}{[}\PY{l+m+mi}{2}\PY{p}{]} \PY{c+c1}{\PYZsh{} if you work in the FD, this is the width of the sample time\PYZhy{}frequency image, othewise time samples of EEG signal}
\PY{k}{if} \PY{n+nb}{len}\PY{p}{(}\PY{n}{X}\PY{o}{.}\PY{n}{shape}\PY{p}{)}\PY{o}{==}\PY{l+m+mi}{3}\PY{p}{:}
\PY{n}{streams} \PY{o}{=} \PY{l+m+mi}{1} \PY{c+c1}{\PYZsh{} this is EEG channels if you work with frequency domain, in the TD streams = 1}
\PY{k}{if} \PY{n+nb}{len}\PY{p}{(}\PY{n}{X}\PY{o}{.}\PY{n}{shape}\PY{p}{)}\PY{o}{==}\PY{l+m+mi}{4}\PY{p}{:}
\PY{n}{streams} \PY{o}{=} \PY{n}{X}\PY{o}{.}\PY{n}{shape}\PY{p}{[}\PY{l+m+mi}{3}\PY{p}{]} \PY{c+c1}{\PYZsh{} this is EEG channels if you work with frequency domain, in the TD streams = 1}
\PY{n}{Y} \PY{o}{=} \PY{n}{Y}\PY{o}{.}\PY{n}{flatten}\PY{p}{(}\PY{p}{)}
\PY{n+nb}{print}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Prepped test input shape}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,} \PY{n}{x\PYZus{}test}\PY{o}{.}\PY{n}{shape}\PY{p}{,} \PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{Noralized MEAN:}\PY{l+s+s2}{\PYZdq{}}\PY{p}{,} \PY{n}{np}\PY{o}{.}\PY{n}{mean}\PY{p}{(}\PY{n}{x\PYZus{}test}\PY{p}{)}\PY{p}{,} \PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{min}\PY{l+s+s2}{\PYZdq{}}\PY{p}{,} \PY{n}{np}\PY{o}{.}\PY{n}{min}\PY{p}{(}\PY{n}{x\PYZus{}test}\PY{p}{)}\PY{p}{,}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{max}\PY{l+s+s2}{\PYZdq{}}\PY{p}{,} \PY{n}{np}\PY{o}{.}\PY{n}{max}\PY{p}{(}\PY{n}{x\PYZus{}test}\PY{p}{)}\PY{p}{)}
\PY{n+nb}{print}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Prepped train input shape}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,} \PY{n}{x\PYZus{}train}\PY{o}{.}\PY{n}{shape}\PY{p}{,} \PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{Normalized MEAN:}\PY{l+s+s2}{\PYZdq{}}\PY{p}{,} \PY{n}{np}\PY{o}{.}\PY{n}{mean}\PY{p}{(}\PY{n}{x\PYZus{}train}\PY{p}{)}\PY{p}{,} \PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{min}\PY{l+s+s2}{\PYZdq{}}\PY{p}{,} \PY{n}{np}\PY{o}{.}\PY{n}{min}\PY{p}{(}\PY{n}{x\PYZus{}train}\PY{p}{)}\PY{p}{,}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{max}\PY{l+s+s2}{\PYZdq{}}\PY{p}{,} \PY{n}{np}\PY{o}{.}\PY{n}{max}\PY{p}{(}\PY{n}{x\PYZus{}train}\PY{p}{)}\PY{p}{)}
\PY{n+nb}{print}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Prepped test labels shape}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,} \PY{n}{y\PYZus{}test}\PY{o}{.}\PY{n}{shape}\PY{p}{,} \PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{Normalized MEAN:}\PY{l+s+s2}{\PYZdq{}}\PY{p}{,} \PY{n}{np}\PY{o}{.}\PY{n}{mean}\PY{p}{(}\PY{n}{y\PYZus{}test}\PY{p}{)}\PY{p}{,} \PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{min}\PY{l+s+s2}{\PYZdq{}}\PY{p}{,} \PY{n}{np}\PY{o}{.}\PY{n}{min}\PY{p}{(}\PY{n}{y\PYZus{}test}\PY{p}{)}\PY{p}{,}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{max}\PY{l+s+s2}{\PYZdq{}}\PY{p}{,} \PY{n}{np}\PY{o}{.}\PY{n}{max}\PY{p}{(}\PY{n}{y\PYZus{}test}\PY{p}{)}\PY{p}{)}
\PY{n+nb}{print}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Prepped train labels shape}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,} \PY{n}{y\PYZus{}train}\PY{o}{.}\PY{n}{shape}\PY{p}{,} \PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{Normalized MEAN:}\PY{l+s+s2}{\PYZdq{}}\PY{p}{,} \PY{n}{np}\PY{o}{.}\PY{n}{mean}\PY{p}{(}\PY{n}{y\PYZus{}train}\PY{p}{)}\PY{p}{,} \PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{min}\PY{l+s+s2}{\PYZdq{}}\PY{p}{,} \PY{n}{np}\PY{o}{.}\PY{n}{min}\PY{p}{(}\PY{n}{y\PYZus{}train}\PY{p}{)}\PY{p}{,}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{max}\PY{l+s+s2}{\PYZdq{}}\PY{p}{,} \PY{n}{np}\PY{o}{.}\PY{n}{max}\PY{p}{(}\PY{n}{y\PYZus{}train}\PY{p}{)}\PY{p}{)}
\PY{c+c1}{\PYZsh{} print(\PYZsq{}Window length\PYZsq{}, winsize)}
\PY{c+c1}{\PYZsh{} print(\PYZsq{}Step size:\PYZsq{}, stepsize)}
\PY{c+c1}{\PYZsh{} print(\PYZsq{}Trial length:\PYZsq{}, trial\PYZus{}len)}
\PY{n+nb}{print}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{EEG in dataset:}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,} \PY{n}{X}\PY{o}{.}\PY{n}{shape}\PY{p}{)}
\PY{n+nb}{print}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Labels in dataset:}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,} \PY{n}{Y}\PY{o}{.}\PY{n}{shape}\PY{p}{)}
\PY{n+nb}{print}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Length of textual labels:}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,} \PY{n+nb}{len}\PY{p}{(}\PY{n}{Q}\PY{p}{)}\PY{p}{)}
\end{Verbatim}
\begin{Verbatim}[commandchars=\\\{\}]
Downsampling the frequency domain from 65 to 8
(450, 67, 67, 8)
[ 0 8 16 24 32 41 49 57 65]
processing frequencies: 0 8
processing frequencies: 8 16
processing frequencies: 16 24
processing frequencies: 24 32
processing frequencies: 32 41
processing frequencies: 41 49
processing frequencies: 49 57
processing frequencies: 57 65
(450, 67, 67, 8)
Downsampled Frequency Domain shape (450, 67, 67, 8)
(450, 15, 15, 8)
Resized shape (450, 15, 15, 8)
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Original data type: float64
y\_test.shape before (90, 1)
y\_test.shape after (90, 2)
Normalized data type: float16
Prepped test input shape (90, 15, 15, 8) Noralized MEAN: 0.09375 min -0.02908 max 1.109
Prepped train input shape (360, 15, 15, 8) Normalized MEAN: 0.0941 min -0.0571 max 2.4
Prepped test labels shape (90, 2) Normalized MEAN: 0.5 min 0.0 max 1.0
Prepped train labels shape (360, 2) Normalized MEAN: 0.5 min 0.0 max 1.0
EEG in dataset: (450, 15, 15, 8)
Labels in dataset: (450,)
Length of textual labels: 450
\end{Verbatim}
\begin{center}
\adjustimage{max size={0.9\linewidth}{0.9\paperheight}}{output_1_1.png}
\end{center}
{ \hspace*{\fill} \\}
\begin{Verbatim}[commandchars=\\\{\}]
{\color{incolor}In [{\color{incolor}55}]:} \PY{n}{plt}\PY{o}{.}\PY{n}{imshow}\PY{p}{(}\PY{n}{x\PYZus{}train}\PY{p}{[}\PY{l+m+mi}{1}\PY{p}{,}\PY{p}{:}\PY{p}{,}\PY{p}{:}\PY{p}{,}\PY{l+m+mi}{1}\PY{p}{]}\PY{o}{.}\PY{n}{astype}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{float32}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)}\PY{p}{)}
\end{Verbatim}
\begin{Verbatim}[commandchars=\\\{\}]
{\color{outcolor}Out[{\color{outcolor}55}]:} <matplotlib.image.AxesImage at 0x7fae7a566198>
\end{Verbatim}
\begin{center}
\adjustimage{max size={0.9\linewidth}{0.9\paperheight}}{output_2_1.png}
\end{center}
{ \hspace*{\fill} \\}
\begin{Verbatim}[commandchars=\\\{\}]
{\color{incolor}In [{\color{incolor}56}]:} \PY{n}{input\PYZus{}shape} \PY{o}{=} \PY{n}{x\PYZus{}train}\PY{p}{[}\PY{o}{\PYZhy{}}\PY{l+m+mi}{1}\PY{p}{,}\PY{p}{:}\PY{p}{,}\PY{p}{:}\PY{p}{,}\PY{p}{:}\PY{p}{]}\PY{o}{.}\PY{n}{shape}
\PY{n}{routings} \PY{o}{=} \PY{l+m+mi}{3}
\PY{n}{padding}\PY{o}{=}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{same}\PY{l+s+s1}{\PYZsq{}} \PY{c+c1}{\PYZsh{} was \PYZsq{}valid\PYZsq{} in the original code on github}
\PY{n}{n\PYZus{}class} \PY{o}{=} \PY{l+m+mi}{2}
\PY{n}{x} \PY{o}{=} \PY{n}{layers}\PY{o}{.}\PY{n}{Input}\PY{p}{(}\PY{n}{shape}\PY{o}{=}\PY{n}{input\PYZus{}shape}\PY{p}{)}
\PY{c+c1}{\PYZsh{} Layer 1: Just a conventional Conv2D layer}
\PY{n}{conv1} \PY{o}{=} \PY{n}{layers}\PY{o}{.}\PY{n}{Conv2D}\PY{p}{(}\PY{n}{filters}\PY{o}{=}\PY{l+m+mi}{256}\PY{p}{,} \PY{n}{kernel\PYZus{}size}\PY{o}{=}\PY{l+m+mi}{9}\PY{p}{,} \PY{n}{strides}\PY{o}{=}\PY{l+m+mi}{1}\PY{p}{,} \PY{n}{padding}\PY{o}{=}\PY{n}{padding}\PY{p}{,} \PY{n}{activation}\PY{o}{=}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{relu}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,} \PY{n}{name}\PY{o}{=}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{conv1}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)}\PY{p}{(}\PY{n}{x}\PY{p}{)}
\PY{c+c1}{\PYZsh{} Layer 2: Conv2D layer with `squash` activation, then reshape to [None, num\PYZus{}capsule, dim\PYZus{}capsule]}
\PY{n}{primarycaps} \PY{o}{=} \PY{n}{PrimaryCap}\PY{p}{(}\PY{n}{conv1}\PY{p}{,} \PY{n}{dim\PYZus{}capsule}\PY{o}{=}\PY{l+m+mi}{8}\PY{p}{,} \PY{n}{n\PYZus{}channels}\PY{o}{=}\PY{l+m+mi}{32}\PY{p}{,} \PY{n}{kernel\PYZus{}size}\PY{o}{=}\PY{l+m+mi}{9}\PY{p}{,} \PY{n}{strides}\PY{o}{=}\PY{l+m+mi}{2}\PY{p}{,} \PY{n}{padding}\PY{o}{=}\PY{n}{padding}\PY{p}{)}
\PY{c+c1}{\PYZsh{} Layer 3: Capsule layer. Routing algorithm works here.}
\PY{n}{digitcaps} \PY{o}{=} \PY{n}{CapsuleLayer}\PY{p}{(}\PY{n}{num\PYZus{}capsule}\PY{o}{=}\PY{n}{n\PYZus{}class}\PY{p}{,} \PY{n}{dim\PYZus{}capsule}\PY{o}{=}\PY{l+m+mi}{16}\PY{p}{,} \PY{n}{routings}\PY{o}{=}\PY{n}{routings}\PY{p}{,}
\PY{n}{name}\PY{o}{=}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{digitcaps}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)}\PY{p}{(}\PY{n}{primarycaps}\PY{p}{)}
\PY{c+c1}{\PYZsh{} Layer 4: This is an auxiliary layer to replace each capsule with its length. Just to match the true label\PYZsq{}s shape.}
\PY{c+c1}{\PYZsh{} If using tensorflow, this will not be necessary. :)}
\PY{n}{out\PYZus{}caps} \PY{o}{=} \PY{n}{Length}\PY{p}{(}\PY{n}{name}\PY{o}{=}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{capsnet}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)}\PY{p}{(}\PY{n}{digitcaps}\PY{p}{)}
\PY{c+c1}{\PYZsh{} Decoder network.}
\PY{n}{y} \PY{o}{=} \PY{n}{layers}\PY{o}{.}\PY{n}{Input}\PY{p}{(}\PY{n}{shape}\PY{o}{=}\PY{p}{(}\PY{n}{n\PYZus{}class}\PY{p}{,}\PY{p}{)}\PY{p}{)}
\PY{n}{masked\PYZus{}by\PYZus{}y} \PY{o}{=} \PY{n}{Mask}\PY{p}{(}\PY{p}{)}\PY{p}{(}\PY{p}{[}\PY{n}{digitcaps}\PY{p}{,} \PY{n}{y}\PY{p}{]}\PY{p}{)} \PY{c+c1}{\PYZsh{} The true label is used to mask the output of capsule layer. For training}
\PY{n}{masked} \PY{o}{=} \PY{n}{Mask}\PY{p}{(}\PY{p}{)}\PY{p}{(}\PY{n}{digitcaps}\PY{p}{)} \PY{c+c1}{\PYZsh{} Mask using the capsule with maximal length. For prediction}
\PY{c+c1}{\PYZsh{} Shared Decoder model in training and prediction}
\PY{n}{decoder} \PY{o}{=} \PY{n}{models}\PY{o}{.}\PY{n}{Sequential}\PY{p}{(}\PY{n}{name}\PY{o}{=}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{decoder}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)}
\PY{n}{decoder}\PY{o}{.}\PY{n}{add}\PY{p}{(}\PY{n}{layers}\PY{o}{.}\PY{n}{Dense}\PY{p}{(}\PY{l+m+mi}{512}\PY{p}{,} \PY{n}{activation}\PY{o}{=}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{relu}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,} \PY{n}{input\PYZus{}dim}\PY{o}{=}\PY{l+m+mi}{16}\PY{o}{*}\PY{n}{n\PYZus{}class}\PY{p}{)}\PY{p}{)}
\PY{n}{decoder}\PY{o}{.}\PY{n}{add}\PY{p}{(}\PY{n}{layers}\PY{o}{.}\PY{n}{Dense}\PY{p}{(}\PY{l+m+mi}{1024}\PY{p}{,} \PY{n}{activation}\PY{o}{=}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{relu}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)}\PY{p}{)}
\PY{n}{decoder}\PY{o}{.}\PY{n}{add}\PY{p}{(}\PY{n}{layers}\PY{o}{.}\PY{n}{Dense}\PY{p}{(}\PY{n}{np}\PY{o}{.}\PY{n}{prod}\PY{p}{(}\PY{n}{input\PYZus{}shape}\PY{p}{)}\PY{p}{,} \PY{n}{activation}\PY{o}{=}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{sigmoid}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)}\PY{p}{)}
\PY{n}{decoder}\PY{o}{.}\PY{n}{add}\PY{p}{(}\PY{n}{layers}\PY{o}{.}\PY{n}{Reshape}\PY{p}{(}\PY{n}{target\PYZus{}shape}\PY{o}{=}\PY{n}{input\PYZus{}shape}\PY{p}{,} \PY{n}{name}\PY{o}{=}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{out\PYZus{}recon}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)}\PY{p}{)}
\PY{c+c1}{\PYZsh{} Models for training and evaluation (prediction)}
\PY{n}{train\PYZus{}model} \PY{o}{=} \PY{n}{models}\PY{o}{.}\PY{n}{Model}\PY{p}{(}\PY{p}{[}\PY{n}{x}\PY{p}{,} \PY{n}{y}\PY{p}{]}\PY{p}{,} \PY{p}{[}\PY{n}{out\PYZus{}caps}\PY{p}{,} \PY{n}{decoder}\PY{p}{(}\PY{n}{masked\PYZus{}by\PYZus{}y}\PY{p}{)}\PY{p}{]}\PY{p}{)}
\PY{k}{def} \PY{n+nf}{margin\PYZus{}loss}\PY{p}{(}\PY{n}{y\PYZus{}true}\PY{p}{,} \PY{n}{y\PYZus{}pred}\PY{p}{)}\PY{p}{:}
\PY{l+s+sd}{\PYZdq{}\PYZdq{}\PYZdq{}}
\PY{l+s+sd}{ Margin loss for Eq.(4). When y\PYZus{}true[i, :] contains not just one `1`, this loss should work too. Not test it.}
\PY{l+s+sd}{ :param y\PYZus{}true: [None, n\PYZus{}classes]}
\PY{l+s+sd}{ :param y\PYZus{}pred: [None, num\PYZus{}capsule]}
\PY{l+s+sd}{ :return: a scalar loss value.}
\PY{l+s+sd}{ \PYZdq{}\PYZdq{}\PYZdq{}}
\PY{n}{L} \PY{o}{=} \PY{n}{y\PYZus{}true} \PY{o}{*} \PY{n}{K}\PY{o}{.}\PY{n}{square}\PY{p}{(}\PY{n}{K}\PY{o}{.}\PY{n}{maximum}\PY{p}{(}\PY{l+m+mf}{0.}\PY{p}{,} \PY{l+m+mf}{0.9} \PY{o}{\PYZhy{}} \PY{n}{y\PYZus{}pred}\PY{p}{)}\PY{p}{)} \PY{o}{+} \PYZbs{}
\PY{l+m+mf}{0.5} \PY{o}{*} \PY{p}{(}\PY{l+m+mi}{1} \PY{o}{\PYZhy{}} \PY{n}{y\PYZus{}true}\PY{p}{)} \PY{o}{*} \PY{n}{K}\PY{o}{.}\PY{n}{square}\PY{p}{(}\PY{n}{K}\PY{o}{.}\PY{n}{maximum}\PY{p}{(}\PY{l+m+mf}{0.}\PY{p}{,} \PY{n}{y\PYZus{}pred} \PY{o}{\PYZhy{}} \PY{l+m+mf}{0.1}\PY{p}{)}\PY{p}{)}
\PY{k}{return} \PY{n}{K}\PY{o}{.}\PY{n}{mean}\PY{p}{(}\PY{n}{K}\PY{o}{.}\PY{n}{sum}\PY{p}{(}\PY{n}{L}\PY{p}{,} \PY{l+m+mi}{1}\PY{p}{)}\PY{p}{)}
\PY{c+c1}{\PYZsh{} compile the model}
\PY{n}{train\PYZus{}model}\PY{o}{.}\PY{n}{compile}\PY{p}{(}\PY{n}{optimizer}\PY{o}{=}\PY{n}{optimizers}\PY{o}{.}\PY{n}{Adam}\PY{p}{(}\PY{p}{)}\PY{p}{,}
\PY{n}{loss}\PY{o}{=}\PY{p}{[}\PY{n}{margin\PYZus{}loss}\PY{p}{,} \PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{mse}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}\PY{p}{,}
\PY{n}{loss\PYZus{}weights}\PY{o}{=}\PY{p}{[}\PY{l+m+mf}{1.}\PY{p}{,} \PY{l+m+mf}{0.392}\PY{p}{]}\PY{p}{,}
\PY{n}{metrics}\PY{o}{=}\PY{p}{\PYZob{}}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{capsnet}\PY{l+s+s1}{\PYZsq{}}\PY{p}{:} \PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{accuracy}\PY{l+s+s1}{\PYZsq{}}\PY{p}{\PYZcb{}}\PY{p}{)}
\PY{n}{train\PYZus{}model}\PY{o}{.}\PY{n}{summary}\PY{p}{(}\PY{p}{)}
\end{Verbatim}
\begin{Verbatim}[commandchars=\\\{\}]
\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_
Layer (type) Output Shape Param \# Connected to
==================================================================================================
input\_17 (InputLayer) (None, 15, 15, 8) 0
\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_
conv1 (Conv2D) (None, 15, 15, 256) 166144 input\_17[0][0]
\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_
primarycap\_conv2d (Conv2D) (None, 8, 8, 256) 5308672 conv1[0][0]
\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_
primarycap\_reshape (Reshape) (None, 2048, 8) 0 primarycap\_conv2d[0][0]
\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_
primarycap\_squash (Lambda) (None, 2048, 8) 0 primarycap\_reshape[0][0]
\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_
digitcaps (CapsuleLayer) (None, 2, 16) 524288 primarycap\_squash[0][0]
\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_
input\_18 (InputLayer) (None, 2) 0
\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_
mask\_17 (Mask) (None, 32) 0 digitcaps[0][0]
input\_18[0][0]
\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_
capsnet (Length) (None, 2) 0 digitcaps[0][0]
\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_
decoder (Sequential) (None, 15, 15, 8) 2387208 mask\_17[0][0]
==================================================================================================
Total params: 8,386,312
Trainable params: 8,386,312
Non-trainable params: 0
\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_
\end{Verbatim}
\begin{Verbatim}[commandchars=\\\{\}]
{\color{incolor}In [{\color{incolor}57}]:} \PY{k+kn}{from} \PY{n+nn}{keras}\PY{n+nn}{.}\PY{n+nn}{callbacks} \PY{k}{import} \PY{n}{EarlyStopping}\PY{p}{,} \PY{n}{ModelCheckpoint}\PY{p}{,} \PY{n}{CSVLogger}\PY{p}{,} \PY{n}{LearningRateScheduler}\PY{p}{,} \PY{n}{Callback}
\PY{n}{EPOCHS} \PY{o}{=} \PY{l+m+mi}{100}
\PY{n}{init\PYZus{}lr} \PY{o}{=} \PY{l+m+mf}{0.0001}
\PY{n}{lr\PYZus{}drop\PYZus{}by} \PY{o}{=} \PY{l+m+mf}{0.995}
\PY{n}{drop\PYZus{}every} \PY{o}{=} \PY{l+m+mi}{5}
\PY{n}{BATCH\PYZus{}SIZE} \PY{o}{=} \PY{l+m+mi}{10}
\PY{n}{log} \PY{o}{=} \PY{n}{CSVLogger}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{/home/amplifier/home/NEW\PYZus{}DL/logs/CapsNET\PYZus{}log.csv}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)}
\PY{n}{checkpointer} \PY{o}{=} \PY{n}{ModelCheckpoint}\PY{p}{(}\PY{n}{filepath}\PY{o}{=}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{/home/amplifier/home/NEW\PYZus{}DL/weights/CapsNET.h5}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,}
\PY{n}{verbose}\PY{o}{=}\PY{l+m+mi}{1}\PY{p}{,}
\PY{n}{monitor}\PY{o}{=}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{val\PYZus{}capsnet\PYZus{}acc}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,}
\PY{n}{save\PYZus{}best\PYZus{}only}\PY{o}{=}\PY{k+kc}{True}\PY{p}{)}
\PY{n}{K}\PY{o}{.}\PY{n}{set\PYZus{}value}\PY{p}{(}\PY{n}{train\PYZus{}model}\PY{o}{.}\PY{n}{optimizer}\PY{o}{.}\PY{n}{lr}\PY{p}{,} \PY{n}{init\PYZus{}lr}\PY{p}{)}
\PY{k}{def} \PY{n+nf}{step\PYZus{}decay}\PY{p}{(}\PY{n}{epoch}\PY{p}{,} \PY{n}{init\PYZus{}lr}\PY{o}{=}\PY{n}{init\PYZus{}lr}\PY{p}{,} \PY{n}{lr\PYZus{}drop}\PY{o}{=}\PY{n}{lr\PYZus{}drop\PYZus{}by}\PY{p}{,} \PY{n}{drop\PYZus{}every}\PY{o}{=}\PY{n}{drop\PYZus{}every}\PY{p}{)}\PY{p}{:}
\PY{k}{if} \PY{n}{epoch}\PY{o}{\PYZpc{}}\PY{k}{drop\PYZus{}every}==0:
\PY{n}{lrate} \PY{o}{=} \PY{n}{init\PYZus{}lr} \PY{o}{*} \PY{p}{(}\PY{n}{lr\PYZus{}drop\PYZus{}by} \PY{o}{*}\PY{o}{*} \PY{n}{np}\PY{o}{.}\PY{n}{floor}\PY{p}{(}\PY{p}{(}\PY{l+m+mi}{1}\PY{o}{+}\PY{n}{epoch}\PY{p}{)}\PY{o}{/}\PY{n}{drop\PYZus{}every}\PY{p}{)}\PY{p}{)}
\PY{k}{else}\PY{p}{:}
\PY{n}{lrate} \PY{o}{=} \PY{n}{K}\PY{o}{.}\PY{n}{get\PYZus{}value}\PY{p}{(}\PY{n}{train\PYZus{}model}\PY{o}{.}\PY{n}{optimizer}\PY{o}{.}\PY{n}{lr}\PY{p}{)}
\PY{n+nb}{print}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{CHECK}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,} \PY{n}{epoch}\PY{o}{\PYZpc{}}\PY{k}{drop\PYZus{}every})
\PY{k}{return} \PY{n}{lrate}
\PY{c+c1}{\PYZsh{} def categorical\PYZus{}accuracy(y\PYZus{}true, y\PYZus{}pred):}
\PY{c+c1}{\PYZsh{} return K.cast(K.equal(K.argmax(y\PYZus{}true, axis=\PYZhy{}1),}
\PY{c+c1}{\PYZsh{} K.argmax(y\PYZus{}pred, axis=\PYZhy{}1)),}
\PY{c+c1}{\PYZsh{} K.floatx())}
\PY{k}{class} \PY{n+nc}{LossHistory}\PY{p}{(}\PY{n}{Callback}\PY{p}{)}\PY{p}{:}
\PY{k}{def} \PY{n+nf}{on\PYZus{}train\PYZus{}begin}\PY{p}{(}\PY{n+nb+bp}{self}\PY{p}{,} \PY{n}{logs}\PY{o}{=}\PY{p}{\PYZob{}}\PY{p}{\PYZcb{}}\PY{p}{)}\PY{p}{:}
\PY{n+nb+bp}{self}\PY{o}{.}\PY{n}{losses} \PY{o}{=} \PY{p}{[}\PY{p}{]}
\PY{n+nb+bp}{self}\PY{o}{.}\PY{n}{lr} \PY{o}{=} \PY{p}{[}\PY{p}{]}
\PY{n+nb+bp}{self}\PY{o}{.}\PY{n}{batch\PYZus{}loss} \PY{o}{=} \PY{p}{[}\PY{p}{]}
\PY{n+nb+bp}{self}\PY{o}{.}\PY{n}{val\PYZus{}capsnet\PYZus{}acc} \PY{o}{=} \PY{p}{[}\PY{p}{]}
\PY{k}{def} \PY{n+nf}{on\PYZus{}epoch\PYZus{}end}\PY{p}{(}\PY{n+nb+bp}{self}\PY{p}{,} \PY{n}{epoch}\PY{p}{,} \PY{n}{batch}\PY{p}{,} \PY{n}{logs}\PY{o}{=}\PY{p}{\PYZob{}}\PY{p}{\PYZcb{}}\PY{p}{)}\PY{p}{:}
\PY{n}{lrate} \PY{o}{=} \PY{n}{step\PYZus{}decay}\PY{p}{(}\PY{n}{epoch}\PY{p}{)}
\PY{n}{txt} \PY{o}{=} \PY{n}{K}\PY{o}{.}\PY{n}{get\PYZus{}value}\PY{p}{(}\PY{n}{train\PYZus{}model}\PY{o}{.}\PY{n}{optimizer}\PY{o}{.}\PY{n}{lr}\PY{p}{)}
\PY{n+nb+bp}{self}\PY{o}{.}\PY{n}{lr}\PY{o}{.}\PY{n}{append}\PY{p}{(}\PY{n}{txt}\PY{p}{)}
\PY{c+c1}{\PYZsh{} self.lr.append(lrate)}
\PY{c+c1}{\PYZsh{} txt = K.eval(self.model.optimizer.lr)}
\PY{n+nb}{print}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{OPTIMIZERS lrate AT EPOCH END = }\PY{l+s+s1}{\PYZsq{}}\PY{p}{,} \PY{n}{txt}\PY{p}{,} \PY{l+s+s1}{\PYZsq{}}\PY{l+s+se}{\PYZbs{}n}\PY{l+s+se}{\PYZbs{}n}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)}
\PY{k}{def} \PY{n+nf}{on\PYZus{}epoch\PYZus{}begin}\PY{p}{(}\PY{n+nb+bp}{self}\PY{p}{,} \PY{n}{epoch}\PY{p}{,} \PY{n}{batch}\PY{p}{,} \PY{n}{logs}\PY{o}{=}\PY{p}{\PYZob{}}\PY{p}{\PYZcb{}}\PY{p}{)}\PY{p}{:}
\PY{n}{txt} \PY{o}{=} \PY{n}{K}\PY{o}{.}\PY{n}{get\PYZus{}value}\PY{p}{(}\PY{n}{train\PYZus{}model}\PY{o}{.}\PY{n}{optimizer}\PY{o}{.}\PY{n}{lr}\PY{p}{)}
\PY{n+nb}{print}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{OPTIMIZERS lrate AT EPOCH START = }\PY{l+s+s1}{\PYZsq{}}\PY{p}{,} \PY{n}{txt}\PY{p}{)}
\PY{k}{def} \PY{n+nf}{on\PYZus{}batch\PYZus{}end}\PY{p}{(}\PY{n+nb+bp}{self}\PY{p}{,} \PY{n}{batch}\PY{p}{,} \PY{n}{logs}\PY{o}{=}\PY{p}{\PYZob{}}\PY{p}{\PYZcb{}}\PY{p}{)}\PY{p}{:}
\PY{n+nb+bp}{self}\PY{o}{.}\PY{n}{batch\PYZus{}loss}\PY{o}{.}\PY{n}{append}\PY{p}{(}\PY{n}{logs}\PY{o}{.}\PY{n}{get}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{loss}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)}\PY{p}{)}
\PY{n}{lr\PYZus{}decay} \PY{o}{=} \PY{n}{LearningRateScheduler}\PY{p}{(}\PY{n}{schedule}\PY{o}{=}\PY{n}{step\PYZus{}decay}\PY{p}{)}
\PY{n}{loss\PYZus{}history} \PY{o}{=} \PY{n}{LossHistory}\PY{p}{(}\PY{p}{)}
\PY{n}{train\PYZus{}history} \PY{o}{=} \PY{n}{train\PYZus{}model}\PY{o}{.}\PY{n}{fit}\PY{p}{(}
\PY{p}{[}\PY{n}{x\PYZus{}train}\PY{p}{,} \PY{n}{y\PYZus{}train}\PY{p}{]}\PY{p}{,}
\PY{p}{[}\PY{n}{y\PYZus{}train}\PY{p}{,} \PY{n}{x\PYZus{}train}\PY{p}{]}\PY{p}{,}
\PY{n}{batch\PYZus{}size}\PY{o}{=}\PY{n}{BATCH\PYZus{}SIZE}\PY{p}{,}
\PY{n}{epochs}\PY{o}{=}\PY{n}{EPOCHS}\PY{p}{,}
\PY{n}{validation\PYZus{}data}\PY{o}{=}\PY{p}{[}\PY{p}{[}\PY{n}{x\PYZus{}test}\PY{p}{,} \PY{n}{y\PYZus{}test}\PY{p}{]}\PY{p}{,} \PY{p}{[}\PY{n}{y\PYZus{}test}\PY{p}{,} \PY{n}{x\PYZus{}test}\PY{p}{]}\PY{p}{]}\PY{p}{,}
\PY{n}{callbacks}\PY{o}{=}\PY{p}{[}\PY{n}{log}\PY{p}{,} \PY{n}{checkpointer}\PY{p}{,} \PY{n}{lr\PYZus{}decay}\PY{p}{,} \PY{n}{loss\PYZus{}history}\PY{p}{]}\PY{p}{)} \PY{c+c1}{\PYZsh{} }
\end{Verbatim}
\begin{Verbatim}[commandchars=\\\{\}]
Train on 360 samples, validate on 90 samples
Epoch 1/100
CHECK 0
OPTIMIZERS lrate AT EPOCH START = 1e-04
360/360 [==============================] - 4s 11ms/step - loss: 0.5068 - capsnet\_loss: 0.4408 - decoder\_loss: 0.1685 - capsnet\_acc: 0.4917 - val\_loss: 0.2962 - val\_capsnet\_loss: 0.2315 - val\_decoder\_loss: 0.1648 - val\_capsnet\_acc: 0.4778
Epoch 00001: val\_capsnet\_acc improved from -inf to 0.47778, saving model to /home/amplifier/home/NEW\_DL/weights/CapsNET.h5
CHECK 0
OPTIMIZERS lrate AT EPOCH END = 1e-04
Epoch 2/100
CHECK 1
OPTIMIZERS lrate AT EPOCH START = 1e-04
360/360 [==============================] - 1s 4ms/step - loss: 0.2930 - capsnet\_loss: 0.2330 - decoder\_loss: 0.1531 - capsnet\_acc: 0.5250 - val\_loss: 0.3004 - val\_capsnet\_loss: 0.2490 - val\_decoder\_loss: 0.1311 - val\_capsnet\_acc: 0.5000
Epoch 00002: val\_capsnet\_acc improved from 0.47778 to 0.50000, saving model to /home/amplifier/home/NEW\_DL/weights/CapsNET.h5
CHECK 1
OPTIMIZERS lrate AT EPOCH END = 1e-04
Epoch 3/100
CHECK 2
OPTIMIZERS lrate AT EPOCH START = 1e-04
360/360 [==============================] - 1s 4ms/step - loss: 0.2617 - capsnet\_loss: 0.2324 - decoder\_loss: 0.0746 - capsnet\_acc: 0.4833 - val\_loss: 0.2321 - val\_capsnet\_loss: 0.2235 - val\_decoder\_loss: 0.0219 - val\_capsnet\_acc: 0.5000
Epoch 00003: val\_capsnet\_acc did not improve from 0.50000
CHECK 2
OPTIMIZERS lrate AT EPOCH END = 1e-04
Epoch 4/100
CHECK 3
OPTIMIZERS lrate AT EPOCH START = 1e-04
360/360 [==============================] - 2s 4ms/step - loss: 0.2229 - capsnet\_loss: 0.2197 - decoder\_loss: 0.0082 - capsnet\_acc: 0.4944 - val\_loss: 0.2177 - val\_capsnet\_loss: 0.2164 - val\_decoder\_loss: 0.0034 - val\_capsnet\_acc: 0.5000
Epoch 00004: val\_capsnet\_acc did not improve from 0.50000
CHECK 3
OPTIMIZERS lrate AT EPOCH END = 1e-04
Epoch 5/100
CHECK 4
OPTIMIZERS lrate AT EPOCH START = 1e-04
360/360 [==============================] - 2s 4ms/step - loss: 0.2218 - capsnet\_loss: 0.2207 - decoder\_loss: 0.0028 - capsnet\_acc: 0.4889 - val\_loss: 0.2170 - val\_capsnet\_loss: 0.2162 - val\_decoder\_loss: 0.0020 - val\_capsnet\_acc: 0.5000
Epoch 00005: val\_capsnet\_acc did not improve from 0.50000
CHECK 4
OPTIMIZERS lrate AT EPOCH END = 1e-04
Epoch 6/100
CHECK 0
OPTIMIZERS lrate AT EPOCH START = 9.95e-05
360/360 [==============================] - 2s 4ms/step - loss: 0.2191 - capsnet\_loss: 0.2183 - decoder\_loss: 0.0020 - capsnet\_acc: 0.4972 - val\_loss: 0.2154 - val\_capsnet\_loss: 0.2148 - val\_decoder\_loss: 0.0017 - val\_capsnet\_acc: 0.5000
Epoch 00006: val\_capsnet\_acc did not improve from 0.50000
CHECK 0
OPTIMIZERS lrate AT EPOCH END = 9.95e-05
Epoch 7/100
CHECK 1
OPTIMIZERS lrate AT EPOCH START = 9.95e-05
360/360 [==============================] - 2s 4ms/step - loss: 0.2194 - capsnet\_loss: 0.2186 - decoder\_loss: 0.0019 - capsnet\_acc: 0.5250 - val\_loss: 0.2231 - val\_capsnet\_loss: 0.2225 - val\_decoder\_loss: 0.0017 - val\_capsnet\_acc: 0.5000
Epoch 00007: val\_capsnet\_acc did not improve from 0.50000
CHECK 1
OPTIMIZERS lrate AT EPOCH END = 9.95e-05
Epoch 8/100
CHECK 2
OPTIMIZERS lrate AT EPOCH START = 9.95e-05
360/360 [==============================] - 2s 4ms/step - loss: 0.2200 - capsnet\_loss: 0.2194 - decoder\_loss: 0.0017 - capsnet\_acc: 0.4889 - val\_loss: 0.2158 - val\_capsnet\_loss: 0.2153 - val\_decoder\_loss: 0.0014 - val\_capsnet\_acc: 0.5000
Epoch 00008: val\_capsnet\_acc did not improve from 0.50000
CHECK 2
OPTIMIZERS lrate AT EPOCH END = 9.95e-05
Epoch 9/100
CHECK 3
OPTIMIZERS lrate AT EPOCH START = 9.95e-05
360/360 [==============================] - 2s 4ms/step - loss: 0.2166 - capsnet\_loss: 0.2160 - decoder\_loss: 0.0015 - capsnet\_acc: 0.5028 - val\_loss: 0.2129 - val\_capsnet\_loss: 0.2125 - val\_decoder\_loss: 0.0012 - val\_capsnet\_acc: 0.6889
Epoch 00009: val\_capsnet\_acc improved from 0.50000 to 0.68889, saving model to /home/amplifier/home/NEW\_DL/weights/CapsNET.h5
CHECK 3
OPTIMIZERS lrate AT EPOCH END = 9.95e-05
Epoch 10/100
CHECK 4
OPTIMIZERS lrate AT EPOCH START = 9.95e-05
360/360 [==============================] - 2s 4ms/step - loss: 0.2175 - capsnet\_loss: 0.2169 - decoder\_loss: 0.0014 - capsnet\_acc: 0.5028 - val\_loss: 0.2127 - val\_capsnet\_loss: 0.2122 - val\_decoder\_loss: 0.0011 - val\_capsnet\_acc: 0.6556
Epoch 00010: val\_capsnet\_acc did not improve from 0.68889
CHECK 4
OPTIMIZERS lrate AT EPOCH END = 9.95e-05
Epoch 11/100
CHECK 0
OPTIMIZERS lrate AT EPOCH START = 9.850749e-05
360/360 [==============================] - 2s 4ms/step - loss: 0.2141 - capsnet\_loss: 0.2136 - decoder\_loss: 0.0013 - capsnet\_acc: 0.5389 - val\_loss: 0.2170 - val\_capsnet\_loss: 0.2164 - val\_decoder\_loss: 0.0016 - val\_capsnet\_acc: 0.5000
Epoch 00011: val\_capsnet\_acc did not improve from 0.68889
CHECK 0
OPTIMIZERS lrate AT EPOCH END = 9.850749e-05
Epoch 12/100
CHECK 1
OPTIMIZERS lrate AT EPOCH START = 9.850749e-05
360/360 [==============================] - 2s 4ms/step - loss: 0.2154 - capsnet\_loss: 0.2149 - decoder\_loss: 0.0013 - capsnet\_acc: 0.5444 - val\_loss: 0.2108 - val\_capsnet\_loss: 0.2104 - val\_decoder\_loss: 0.0011 - val\_capsnet\_acc: 0.5000
Epoch 00012: val\_capsnet\_acc did not improve from 0.68889
CHECK 1
OPTIMIZERS lrate AT EPOCH END = 9.850749e-05
Epoch 13/100
CHECK 2
OPTIMIZERS lrate AT EPOCH START = 9.850749e-05
360/360 [==============================] - 2s 4ms/step - loss: 0.2130 - capsnet\_loss: 0.2125 - decoder\_loss: 0.0013 - capsnet\_acc: 0.5444 - val\_loss: 0.2086 - val\_capsnet\_loss: 0.2081 - val\_decoder\_loss: 0.0012 - val\_capsnet\_acc: 0.5000
Epoch 00013: val\_capsnet\_acc did not improve from 0.68889
CHECK 2
OPTIMIZERS lrate AT EPOCH END = 9.850749e-05
Epoch 14/100
CHECK 3
OPTIMIZERS lrate AT EPOCH START = 9.850749e-05
360/360 [==============================] - 2s 4ms/step - loss: 0.2117 - capsnet\_loss: 0.2112 - decoder\_loss: 0.0013 - capsnet\_acc: 0.5528 - val\_loss: 0.2042 - val\_capsnet\_loss: 0.2038 - val\_decoder\_loss: 0.0011 - val\_capsnet\_acc: 0.7889
Epoch 00014: val\_capsnet\_acc improved from 0.68889 to 0.78889, saving model to /home/amplifier/home/NEW\_DL/weights/CapsNET.h5
CHECK 3
OPTIMIZERS lrate AT EPOCH END = 9.850749e-05
Epoch 15/100
CHECK 4
OPTIMIZERS lrate AT EPOCH START = 9.850749e-05
360/360 [==============================] - 2s 4ms/step - loss: 0.2071 - capsnet\_loss: 0.2066 - decoder\_loss: 0.0012 - capsnet\_acc: 0.5750 - val\_loss: 0.1825 - val\_capsnet\_loss: 0.1821 - val\_decoder\_loss: 0.0010 - val\_capsnet\_acc: 0.7444
Epoch 00015: val\_capsnet\_acc did not improve from 0.78889
CHECK 4
OPTIMIZERS lrate AT EPOCH END = 9.850749e-05
Epoch 16/100
CHECK 0
OPTIMIZERS lrate AT EPOCH START = 9.703725e-05
360/360 [==============================] - 2s 4ms/step - loss: 0.1982 - capsnet\_loss: 0.1976 - decoder\_loss: 0.0014 - capsnet\_acc: 0.6417 - val\_loss: 0.1641 - val\_capsnet\_loss: 0.1636 - val\_decoder\_loss: 0.0012 - val\_capsnet\_acc: 0.7556
Epoch 00016: val\_capsnet\_acc did not improve from 0.78889
CHECK 0
OPTIMIZERS lrate AT EPOCH END = 9.703725e-05
Epoch 17/100
CHECK 1
OPTIMIZERS lrate AT EPOCH START = 9.703725e-05
360/360 [==============================] - 2s 4ms/step - loss: 0.1793 - capsnet\_loss: 0.1786 - decoder\_loss: 0.0016 - capsnet\_acc: 0.7167 - val\_loss: 0.1448 - val\_capsnet\_loss: 0.1443 - val\_decoder\_loss: 0.0013 - val\_capsnet\_acc: 0.7667
Epoch 00017: val\_capsnet\_acc did not improve from 0.78889
CHECK 1
OPTIMIZERS lrate AT EPOCH END = 9.703725e-05
Epoch 18/100
CHECK 2
OPTIMIZERS lrate AT EPOCH START = 9.703725e-05
360/360 [==============================] - 2s 4ms/step - loss: 0.1665 - capsnet\_loss: 0.1659 - decoder\_loss: 0.0017 - capsnet\_acc: 0.7139 - val\_loss: 0.1318 - val\_capsnet\_loss: 0.1311 - val\_decoder\_loss: 0.0016 - val\_capsnet\_acc: 0.7778
Epoch 00018: val\_capsnet\_acc did not improve from 0.78889
CHECK 2
OPTIMIZERS lrate AT EPOCH END = 9.703725e-05
Epoch 19/100
CHECK 3
OPTIMIZERS lrate AT EPOCH START = 9.703725e-05
360/360 [==============================] - 1s 4ms/step - loss: 0.1620 - capsnet\_loss: 0.1612 - decoder\_loss: 0.0018 - capsnet\_acc: 0.7222 - val\_loss: 0.1234 - val\_capsnet\_loss: 0.1227 - val\_decoder\_loss: 0.0018 - val\_capsnet\_acc: 0.8000
Epoch 00019: val\_capsnet\_acc improved from 0.78889 to 0.80000, saving model to /home/amplifier/home/NEW\_DL/weights/CapsNET.h5
CHECK 3
OPTIMIZERS lrate AT EPOCH END = 9.703725e-05
Epoch 20/100
CHECK 4
OPTIMIZERS lrate AT EPOCH START = 9.703725e-05
360/360 [==============================] - 2s 4ms/step - loss: 0.1495 - capsnet\_loss: 0.1488 - decoder\_loss: 0.0019 - capsnet\_acc: 0.7500 - val\_loss: 0.1688 - val\_capsnet\_loss: 0.1675 - val\_decoder\_loss: 0.0032 - val\_capsnet\_acc: 0.7333
Epoch 00020: val\_capsnet\_acc did not improve from 0.80000
CHECK 4
OPTIMIZERS lrate AT EPOCH END = 9.703725e-05
Epoch 21/100
CHECK 0
OPTIMIZERS lrate AT EPOCH START = 9.511101e-05
360/360 [==============================] - 1s 4ms/step - loss: 0.1483 - capsnet\_loss: 0.1476 - decoder\_loss: 0.0019 - capsnet\_acc: 0.7333 - val\_loss: 0.1269 - val\_capsnet\_loss: 0.1260 - val\_decoder\_loss: 0.0021 - val\_capsnet\_acc: 0.8111
Epoch 00021: val\_capsnet\_acc improved from 0.80000 to 0.81111, saving model to /home/amplifier/home/NEW\_DL/weights/CapsNET.h5
CHECK 0
OPTIMIZERS lrate AT EPOCH END = 9.511101e-05
Epoch 22/100
CHECK 1
OPTIMIZERS lrate AT EPOCH START = 9.511101e-05
360/360 [==============================] - 1s 4ms/step - loss: 0.1579 - capsnet\_loss: 0.1571 - decoder\_loss: 0.0019 - capsnet\_acc: 0.7389 - val\_loss: 0.1428 - val\_capsnet\_loss: 0.1420 - val\_decoder\_loss: 0.0019 - val\_capsnet\_acc: 0.7333
Epoch 00022: val\_capsnet\_acc did not improve from 0.81111
CHECK 1
OPTIMIZERS lrate AT EPOCH END = 9.511101e-05
Epoch 23/100
CHECK 2
OPTIMIZERS lrate AT EPOCH START = 9.511101e-05
360/360 [==============================] - 1s 4ms/step - loss: 0.1445 - capsnet\_loss: 0.1438 - decoder\_loss: 0.0018 - capsnet\_acc: 0.7361 - val\_loss: 0.1314 - val\_capsnet\_loss: 0.1306 - val\_decoder\_loss: 0.0020 - val\_capsnet\_acc: 0.7444
Epoch 00023: val\_capsnet\_acc did not improve from 0.81111
CHECK 2
OPTIMIZERS lrate AT EPOCH END = 9.511101e-05
Epoch 24/100
CHECK 3
OPTIMIZERS lrate AT EPOCH START = 9.511101e-05
360/360 [==============================] - 1s 4ms/step - loss: 0.1446 - capsnet\_loss: 0.1438 - decoder\_loss: 0.0020 - capsnet\_acc: 0.7778 - val\_loss: 0.1285 - val\_capsnet\_loss: 0.1278 - val\_decoder\_loss: 0.0020 - val\_capsnet\_acc: 0.7778
Epoch 00024: val\_capsnet\_acc did not improve from 0.81111
CHECK 3
OPTIMIZERS lrate AT EPOCH END = 9.511101e-05
Epoch 25/100
CHECK 4
OPTIMIZERS lrate AT EPOCH START = 9.511101e-05
360/360 [==============================] - 1s 4ms/step - loss: 0.1365 - capsnet\_loss: 0.1358 - decoder\_loss: 0.0017 - capsnet\_acc: 0.7889 - val\_loss: 0.1851 - val\_capsnet\_loss: 0.1840 - val\_decoder\_loss: 0.0027 - val\_capsnet\_acc: 0.6778
Epoch 00025: val\_capsnet\_acc did not improve from 0.81111
CHECK 4
OPTIMIZERS lrate AT EPOCH END = 9.511101e-05
Epoch 26/100
CHECK 0
OPTIMIZERS lrate AT EPOCH START = 9.27569e-05
360/360 [==============================] - 1s 4ms/step - loss: 0.1384 - capsnet\_loss: 0.1378 - decoder\_loss: 0.0015 - capsnet\_acc: 0.7500 - val\_loss: 0.1511 - val\_capsnet\_loss: 0.1502 - val\_decoder\_loss: 0.0022 - val\_capsnet\_acc: 0.7222
Epoch 00026: val\_capsnet\_acc did not improve from 0.81111
CHECK 0
OPTIMIZERS lrate AT EPOCH END = 9.27569e-05
Epoch 27/100
CHECK 1
OPTIMIZERS lrate AT EPOCH START = 9.27569e-05
360/360 [==============================] - 1s 4ms/step - loss: 0.1304 - capsnet\_loss: 0.1298 - decoder\_loss: 0.0016 - capsnet\_acc: 0.7861 - val\_loss: 0.1410 - val\_capsnet\_loss: 0.1404 - val\_decoder\_loss: 0.0016 - val\_capsnet\_acc: 0.7333
Epoch 00027: val\_capsnet\_acc did not improve from 0.81111
CHECK 1
OPTIMIZERS lrate AT EPOCH END = 9.27569e-05
Epoch 28/100
CHECK 2
OPTIMIZERS lrate AT EPOCH START = 9.27569e-05
360/360 [==============================] - 1s 4ms/step - loss: 0.1331 - capsnet\_loss: 0.1324 - decoder\_loss: 0.0017 - capsnet\_acc: 0.7806 - val\_loss: 0.1336 - val\_capsnet\_loss: 0.1329 - val\_decoder\_loss: 0.0018 - val\_capsnet\_acc: 0.8111
Epoch 00028: val\_capsnet\_acc did not improve from 0.81111
CHECK 2
OPTIMIZERS lrate AT EPOCH END = 9.27569e-05
Epoch 29/100
CHECK 3
OPTIMIZERS lrate AT EPOCH START = 9.27569e-05
360/360 [==============================] - 1s 4ms/step - loss: 0.1259 - capsnet\_loss: 0.1253 - decoder\_loss: 0.0014 - capsnet\_acc: 0.7889 - val\_loss: 0.1423 - val\_capsnet\_loss: 0.1416 - val\_decoder\_loss: 0.0019 - val\_capsnet\_acc: 0.7667
Epoch 00029: val\_capsnet\_acc did not improve from 0.81111
CHECK 3
OPTIMIZERS lrate AT EPOCH END = 9.27569e-05
Epoch 30/100
CHECK 4
OPTIMIZERS lrate AT EPOCH START = 9.27569e-05