Skip to content

Commit c141e7d

Browse files
committed
check notebooks, first version of docs
1 parent 34b468a commit c141e7d

File tree

14 files changed

+5213
-863
lines changed

14 files changed

+5213
-863
lines changed

Nbs/00_ModelConstructor.ipynb

Lines changed: 11 additions & 265 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,7 @@
1313
"cell_type": "code",
1414
"execution_count": null,
1515
"metadata": {},
16-
"outputs": [
17-
{
18-
"name": "stdout",
19-
"output_type": "stream",
20-
"text": [
21-
"The autoreload extension is already loaded. To reload it, use:\n",
22-
" %reload_ext autoreload\n"
23-
]
24-
}
25-
],
16+
"outputs": [],
2617
"source": [
2718
"#hide\n",
2819
"%load_ext autoreload\n",
@@ -37,10 +28,7 @@
3728
"source": [
3829
"#hide\n",
3930
"import torch\n",
40-
"import torch.nn as nn\n",
41-
"\n",
42-
"from nbdev.showdoc import show_doc\n",
43-
"from IPython.display import Markdown, display"
31+
"import torch.nn as nn"
4432
]
4533
},
4634
{
@@ -76,27 +64,10 @@
7664
"cell_type": "code",
7765
"execution_count": null,
7866
"metadata": {},
79-
"outputs": [
80-
{
81-
"data": {
82-
"text/markdown": [
83-
"<h4 id=\"ResBlock\" class=\"doc_header\"><code>class</code> <code>ResBlock</code><a href=\"model_constructor/model_constructor.py#L26\" class=\"source_link\" style=\"float:right\">[source]</a></h4>\n",
84-
"\n",
85-
"> <code>ResBlock</code>(**`expansion`**, **`in_channels`**, **`mid_channels`**, **`stride`**=*`1`*, **`conv_layer`**=*`ConvBnAct`*, **`act_fn`**=*`ReLU(inplace=True)`*, **`zero_bn`**=*`True`*, **`bn_1st`**=*`True`*, **`groups`**=*`1`*, **`dw`**=*`False`*, **`div_groups`**=*`None`*, **`pool`**=*`None`*, **`se`**=*`None`*, **`sa`**=*`None`*) :: `Module`\n",
86-
"\n",
87-
"Resnet block"
88-
],
89-
"text/plain": [
90-
"<IPython.core.display.Markdown object>"
91-
]
92-
},
93-
"metadata": {},
94-
"output_type": "display_data"
95-
}
96-
],
67+
"outputs": [],
9768
"source": [
9869
"#hide_input\n",
99-
"print_doc(ResBlock)"
70+
"# print_doc(ResBlock)"
10071
]
10172
},
10273
{
@@ -474,127 +445,6 @@
474445
"block"
475446
]
476447
},
477-
{
478-
"cell_type": "markdown",
479-
"metadata": {},
480-
"source": [
481-
"## Stem, Body, Head"
482-
]
483-
},
484-
{
485-
"cell_type": "code",
486-
"execution_count": null,
487-
"metadata": {},
488-
"outputs": [],
489-
"source": [
490-
"#hide\n",
491-
"from model_constructor.model_constructor import _make_body, _make_head, _make_layer, _make_stem"
492-
]
493-
},
494-
{
495-
"cell_type": "code",
496-
"execution_count": null,
497-
"metadata": {},
498-
"outputs": [
499-
{
500-
"data": {
501-
"text/markdown": [
502-
"<h4 id=\"_make_layer\" class=\"doc_header\"><code>_make_layer</code><a href=\"model_constructor/model_constructor.py#L88\" class=\"source_link\" style=\"float:right\">[source]</a></h4>\n",
503-
"\n",
504-
"> <code>_make_layer</code>(**`expansion`**, **`in_channels`**, **`out_channels`**, **`blocks`**, **`stride`**, **`sa`**)\n",
505-
"\n"
506-
],
507-
"text/plain": [
508-
"<IPython.core.display.Markdown object>"
509-
]
510-
},
511-
"metadata": {},
512-
"output_type": "display_data"
513-
}
514-
],
515-
"source": [
516-
"#hide_input\n",
517-
"print_doc(_make_layer)"
518-
]
519-
},
520-
{
521-
"cell_type": "code",
522-
"execution_count": null,
523-
"metadata": {},
524-
"outputs": [
525-
{
526-
"data": {
527-
"text/markdown": [
528-
"<h4 id=\"_make_stem\" class=\"doc_header\"><code>_make_stem</code><a href=\"model_constructor/model_constructor.py#L75\" class=\"source_link\" style=\"float:right\">[source]</a></h4>\n",
529-
"\n",
530-
"> <code>_make_stem</code>()\n",
531-
"\n"
532-
],
533-
"text/plain": [
534-
"<IPython.core.display.Markdown object>"
535-
]
536-
},
537-
"metadata": {},
538-
"output_type": "display_data"
539-
}
540-
],
541-
"source": [
542-
"#hide_input\n",
543-
"print_doc(_make_stem)"
544-
]
545-
},
546-
{
547-
"cell_type": "code",
548-
"execution_count": null,
549-
"metadata": {},
550-
"outputs": [
551-
{
552-
"data": {
553-
"text/markdown": [
554-
"<h4 id=\"_make_body\" class=\"doc_header\"><code>_make_body</code><a href=\"model_constructor/model_constructor.py#L99\" class=\"source_link\" style=\"float:right\">[source]</a></h4>\n",
555-
"\n",
556-
"> <code>_make_body</code>()\n",
557-
"\n"
558-
],
559-
"text/plain": [
560-
"<IPython.core.display.Markdown object>"
561-
]
562-
},
563-
"metadata": {},
564-
"output_type": "display_data"
565-
}
566-
],
567-
"source": [
568-
"#hide_input\n",
569-
"print_doc(_make_body)"
570-
]
571-
},
572-
{
573-
"cell_type": "code",
574-
"execution_count": null,
575-
"metadata": {},
576-
"outputs": [
577-
{
578-
"data": {
579-
"text/markdown": [
580-
"<h4 id=\"_make_head\" class=\"doc_header\"><code>_make_head</code><a href=\"model_constructor/model_constructor.py#L109\" class=\"source_link\" style=\"float:right\">[source]</a></h4>\n",
581-
"\n",
582-
"> <code>_make_head</code>()\n",
583-
"\n"
584-
],
585-
"text/plain": [
586-
"<IPython.core.display.Markdown object>"
587-
]
588-
},
589-
"metadata": {},
590-
"output_type": "display_data"
591-
}
592-
],
593-
"source": [
594-
"#hide_input\n",
595-
"print_doc(_make_head)"
596-
]
597-
},
598448
{
599449
"cell_type": "markdown",
600450
"metadata": {},
@@ -616,27 +466,10 @@
616466
"cell_type": "code",
617467
"execution_count": null,
618468
"metadata": {},
619-
"outputs": [
620-
{
621-
"data": {
622-
"text/markdown": [
623-
"<h4 id=\"ModelConstructor\" class=\"doc_header\"><code>class</code> <code>ModelConstructor</code><a href=\"model_constructor/model_constructor.py#L117\" class=\"source_link\" style=\"float:right\">[source]</a></h4>\n",
624-
"\n",
625-
"> <code>ModelConstructor</code>(**`name`**=*`'MC'`*, **`in_chans`**=*`3`*, **`num_classes`**=*`1000`*, **`block`**=*`ResBlock`*, **`conv_layer`**=*`ConvBnAct`*, **`block_sizes`**=*`[64, 128, 256, 512]`*, **`layers`**=*`[2, 2, 2, 2]`*, **`norm`**=*`BatchNorm2d`*, **`act_fn`**=*`ReLU(inplace=True)`*, **`pool`**=*`AvgPool2d(kernel_size=2, stride=2, padding=0)`*, **`expansion`**=*`1`*, **`groups`**=*`1`*, **`dw`**=*`False`*, **`div_groups`**=*`None`*, **`sa`**:`Union`\\[`bool`, `int`, `typing.Callable`\\]=*`False`*, **`se`**:`Union`\\[`bool`, `int`, `typing.Callable`\\]=*`False`*, **`se_module`**=*`None`*, **`se_reduction`**=*`None`*, **`bn_1st`**=*`True`*, **`zero_bn`**=*`True`*, **`stem_stride_on`**=*`0`*, **`stem_sizes`**=*`[32, 32, 64]`*, **`stem_pool`**=*`MaxPool2d(kernel_size=3, stride=2, padding=1, dilation=1, ceil_mode=False)`*, **`stem_bn_end`**=*`False`*, **`_init_cnn`**=*`init_cnn`*, **`_make_stem`**=*`_make_stem`*, **`_make_layer`**=*`_make_layer`*, **`_make_body`**=*`_make_body`*, **`_make_head`**=*`_make_head`*)\n",
626-
"\n",
627-
"Model constructor. As default - xresnet18"
628-
],
629-
"text/plain": [
630-
"<IPython.core.display.Markdown object>"
631-
]
632-
},
633-
"metadata": {},
634-
"output_type": "display_data"
635-
}
636-
],
469+
"outputs": [],
637470
"source": [
638471
"#hide_input\n",
639-
"print_doc(ModelConstructor)"
472+
"# print_doc(ModelConstructor)"
640473
]
641474
},
642475
{
@@ -666,93 +499,6 @@
666499
"mc"
667500
]
668501
},
669-
{
670-
"cell_type": "code",
671-
"execution_count": null,
672-
"metadata": {},
673-
"outputs": [
674-
{
675-
"data": {
676-
"text/plain": [
677-
"[64, 128, 256, 512]"
678-
]
679-
},
680-
"execution_count": null,
681-
"metadata": {},
682-
"output_type": "execute_result"
683-
}
684-
],
685-
"source": [
686-
"mc._block_sizes"
687-
]
688-
},
689-
{
690-
"cell_type": "code",
691-
"execution_count": null,
692-
"metadata": {},
693-
"outputs": [
694-
{
695-
"data": {
696-
"text/plain": [
697-
"[64, 64, 128, 256, 512]"
698-
]
699-
},
700-
"execution_count": null,
701-
"metadata": {},
702-
"output_type": "execute_result"
703-
}
704-
],
705-
"source": [
706-
"mc.block_sizes"
707-
]
708-
},
709-
{
710-
"cell_type": "code",
711-
"execution_count": null,
712-
"metadata": {},
713-
"outputs": [
714-
{
715-
"data": {
716-
"text/plain": [
717-
"MC constructor\n",
718-
" in_chans: 3, num_classes: 1000\n",
719-
" expansion: 1, groups: 1, dw: False, div_groups: None\n",
720-
" sa: False, se: False\n",
721-
" stem sizes: [3, 32, 32, 64], stride on 0\n",
722-
" body sizes [128, 256, 512, 1024]\n",
723-
" layers: [2, 2, 2, 2]"
724-
]
725-
},
726-
"execution_count": null,
727-
"metadata": {},
728-
"output_type": "execute_result"
729-
}
730-
],
731-
"source": [
732-
"mc._block_sizes = [128, 256, 512, 1024]\n",
733-
"mc"
734-
]
735-
},
736-
{
737-
"cell_type": "code",
738-
"execution_count": null,
739-
"metadata": {},
740-
"outputs": [
741-
{
742-
"data": {
743-
"text/plain": [
744-
"[64, 128, 256, 512, 1024]"
745-
]
746-
},
747-
"execution_count": null,
748-
"metadata": {},
749-
"output_type": "execute_result"
750-
}
751-
],
752-
"source": [
753-
"mc.block_sizes"
754-
]
755-
},
756502
{
757503
"cell_type": "code",
758504
"execution_count": null,
@@ -855,7 +601,7 @@
855601
"metadata": {},
856602
"outputs": [],
857603
"source": [
858-
"mc.act_fn =nn.LeakyReLU(inplace=True)"
604+
"mc.act_fn = nn.LeakyReLU(inplace=True)"
859605
]
860606
},
861607
{
@@ -891,9 +637,9 @@
891637
" (se): SEModule(\n",
892638
" (squeeze): AdaptiveAvgPool2d(output_size=1)\n",
893639
" (excitation): Sequential(\n",
894-
" (fc_reduce): Linear(in_features=64, out_features=4, bias=True)\n",
640+
" (reduce): Linear(in_features=64, out_features=4, bias=True)\n",
895641
" (se_act): ReLU(inplace=True)\n",
896-
" (fc_expand): Linear(in_features=4, out_features=64, bias=True)\n",
642+
" (expand): Linear(in_features=4, out_features=64, bias=True)\n",
897643
" (se_gate): Sigmoid()\n",
898644
" )\n",
899645
" )\n",
@@ -914,9 +660,9 @@
914660
" (se): SEModule(\n",
915661
" (squeeze): AdaptiveAvgPool2d(output_size=1)\n",
916662
" (excitation): Sequential(\n",
917-
" (fc_reduce): Linear(in_features=64, out_features=4, bias=True)\n",
663+
" (reduce): Linear(in_features=64, out_features=4, bias=True)\n",
918664
" (se_act): ReLU(inplace=True)\n",
919-
" (fc_expand): Linear(in_features=4, out_features=64, bias=True)\n",
665+
" (expand): Linear(in_features=4, out_features=64, bias=True)\n",
920666
" (se_gate): Sigmoid()\n",
921667
" )\n",
922668
" )\n",

0 commit comments

Comments
 (0)