Skip to content

Commit 1b2a1ca

Browse files
author
ayasyrev
committed
add NewResBlock
1 parent 88c63c0 commit 1b2a1ca

File tree

15 files changed

+1101
-363
lines changed

15 files changed

+1101
-363
lines changed

README.md

Lines changed: 72 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ model.layers
8484

8585

8686

87-
[64, 64, 128, 256, 512]
87+
[2, 2, 2, 2]
8888

8989

9090

@@ -621,10 +621,21 @@ model.body
621621

622622

623623

624+
```python
625+
model.block_szs
626+
```
627+
628+
629+
630+
631+
[16, 64, 128, 256, 512]
632+
633+
634+
624635
## More modification.
625636

626637
Main purpose of this module - fast and easy modify model.
627-
And here is the link to more modification to beat Imagenette leaderboard with addin MaxBlurPool and modification to ResBlock https://github.com/ayasyrev/imagenette_experiments/blob/master/ResnetTrick_create_model_fit.ipynb
638+
And here is the link to more modification to beat Imagenette leaderboard with add MaxBlurPool and modification to ResBlock https://github.com/ayasyrev/imagenette_experiments/blob/master/ResnetTrick_create_model_fit.ipynb
628639

629640
But now lets create model as mxresnet50 from fastai forums tread https://forums.fast.ai/t/how-we-beat-the-5-epoch-imagewoof-leaderboard-score-some-new-techniques-to-consider
630641

@@ -657,12 +668,24 @@ class Mish(nn.Module):
657668
mxresnet.expansion = 4
658669
mxresnet.layers = [3,4,6,3]
659670
mxresnet.act_fn = Mish()
671+
mxresnet.name = 'mxresnet50'
660672
```
661673

662674
Now we have mxresnet50 constructor.
663675
We can inspect some parts of it.
664676
And after call it we got model.
665677

678+
```python
679+
mxresnet
680+
```
681+
682+
683+
684+
685+
constr mxresnet50
686+
687+
688+
666689
```python
667690
mxresnet.stem.conv_1
668691
```
@@ -688,7 +711,7 @@ mxresnet.body.l_0.bl_0
688711
ResBlock(
689712
(convs): Sequential(
690713
(conv_0): ConvLayer(
691-
(conv): Conv2d(256, 64, kernel_size=(1, 1), stride=(1, 1), bias=False)
714+
(conv): Conv2d(64, 64, kernel_size=(1, 1), stride=(1, 1), bias=False)
692715
(bn): BatchNorm2d(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
693716
(act_fn): Mish()
694717
)
@@ -702,11 +725,57 @@ mxresnet.body.l_0.bl_0
702725
(bn): BatchNorm2d(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
703726
)
704727
)
728+
(idconv): ConvLayer(
729+
(conv): Conv2d(64, 256, kernel_size=(1, 1), stride=(1, 1), bias=False)
730+
(bn): BatchNorm2d(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
731+
)
705732
(act_fn): Mish()
706733
)
707734

708735

709736

737+
Now lets change Resblock. NewResBlock (stiil not own name yet) is in lib from version 0.1.0
738+
739+
```python
740+
mxresnet.block = NewResBlock
741+
```
742+
743+
That all. Let see what we have.
744+
745+
```python
746+
mxresnet.body.l_1.bl_0
747+
```
748+
749+
750+
751+
752+
NewResBlock(
753+
(reduce): AvgPool2d(kernel_size=2, stride=2, padding=0)
754+
(convs): Sequential(
755+
(conv_0): ConvLayer(
756+
(conv): Conv2d(256, 128, kernel_size=(1, 1), stride=(1, 1), bias=False)
757+
(bn): BatchNorm2d(128, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
758+
(act_fn): Mish()
759+
)
760+
(conv_1): ConvLayer(
761+
(conv): Conv2d(128, 128, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
762+
(bn): BatchNorm2d(128, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
763+
(act_fn): Mish()
764+
)
765+
(conv_2): ConvLayer(
766+
(conv): Conv2d(128, 512, kernel_size=(1, 1), stride=(1, 1), bias=False)
767+
(bn): BatchNorm2d(512, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
768+
)
769+
)
770+
(idconv): ConvLayer(
771+
(conv): Conv2d(256, 512, kernel_size=(1, 1), stride=(1, 1), bias=False)
772+
(bn): BatchNorm2d(512, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
773+
)
774+
(merge): Mish()
775+
)
776+
777+
778+
710779
# Classic way
711780

712781
Usual way to get model - call constructor with parametrs.

0 commit comments

Comments
 (0)