Skip to content

Commit 5c5ef00

Browse files
author
ayasyrev
committed
nbs moved to nbs folder. Added xresnet
1 parent 2e92f31 commit 5c5ef00

21 files changed

+6571
-3552
lines changed

00_constructor.ipynb

Lines changed: 0 additions & 1887 deletions
This file was deleted.

README.md

Lines changed: 95 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ resnet34 = Net(block=BasicBlock, blocks=[3, 4, 6, 3])
5757

5858
</div>
5959

60-
Predefined Resnet18 and Resnet34.
60+
# Predefined Resnet models - 18, 34, 50.
6161
<div class="codecell" markdown="1">
6262
<div class="input_area" markdown="1">
6363

@@ -77,13 +77,47 @@ model = resnet34(num_classes=10)
7777

7878
</div>
7979

80+
</div>
81+
<div class="codecell" markdown="1">
82+
<div class="input_area" markdown="1">
83+
84+
```python
85+
model = resnet50(num_classes=10)
86+
```
87+
88+
</div>
89+
90+
</div>
91+
92+
# Predefined Xresnet from fastai 1.
93+
94+
This ie simplified version from fastai v1. I did refactoring for better understand and experime with models. For example, change activation funtions, different stems, batchnorm and activation order etc. In v2 much powerfull realisation.
95+
<div class="codecell" markdown="1">
96+
<div class="input_area" markdown="1">
97+
98+
```python
99+
from model_constructor.xresnet import *
100+
```
101+
102+
</div>
103+
104+
</div>
105+
<div class="codecell" markdown="1">
106+
<div class="input_area" markdown="1">
107+
108+
```python
109+
model = xresnet50()
110+
```
111+
112+
</div>
113+
80114
</div>
81115

82116
# Some examples
83117

84118
We can experiment with models by changing some parts of model. Here only base functionality, but it can be easily extanded.
85119

86-
Here some examples:
120+
Here is some examples:
87121

88122

89123
## Custom stem
@@ -93,7 +127,7 @@ Stem with 3 conv layers
93127
<div class="input_area" markdown="1">
94128

95129
```python
96-
model = Net(stem=partial(Stem, sizes=[32, 32]))
130+
model = Net(stem=partial(Stem, stem_sizes=[32, 32]))
97131
```
98132

99133
</div>
@@ -115,19 +149,67 @@ model.stem
115149
Stem(
116150
sizes: [3, 32, 32, 64]
117151
(conv0): ConvLayer(
118-
(conv): Conv2d(3, 32, kernel_size=(3, 3), stride=(2, 2), padding=(1, 1))
119-
(act_fn): ReLU(inplace=True)
152+
(conv): Conv2d(3, 32, kernel_size=(3, 3), stride=(2, 2), padding=(1, 1), bias=False)
120153
(bn): BatchNorm2d(32, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
154+
(act_fn): ReLU(inplace=True)
121155
)
122156
(conv1): ConvLayer(
123-
(conv): Conv2d(32, 32, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
124-
(act_fn): ReLU(inplace=True)
157+
(conv): Conv2d(32, 32, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
125158
(bn): BatchNorm2d(32, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
159+
(act_fn): ReLU(inplace=True)
126160
)
127161
(conv2): ConvLayer(
128-
(conv): Conv2d(32, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
162+
(conv): Conv2d(32, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
163+
(bn): BatchNorm2d(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
164+
(act_fn): ReLU(inplace=True)
165+
)
166+
(pool): MaxPool2d(kernel_size=3, stride=2, padding=1, dilation=1, ceil_mode=False)
167+
)
168+
169+
170+
171+
</div>
172+
173+
</div>
174+
<div class="codecell" markdown="1">
175+
<div class="input_area" markdown="1">
176+
177+
```python
178+
model = Net(stem_sizes=[32, 64])
179+
```
180+
181+
</div>
182+
183+
</div>
184+
<div class="codecell" markdown="1">
185+
<div class="input_area" markdown="1">
186+
187+
```python
188+
model.stem
189+
```
190+
191+
</div>
192+
<div class="output_area" markdown="1">
193+
194+
195+
196+
197+
Stem(
198+
sizes: [3, 32, 64, 64]
199+
(conv0): ConvLayer(
200+
(conv): Conv2d(3, 32, kernel_size=(3, 3), stride=(2, 2), padding=(1, 1), bias=False)
201+
(bn): BatchNorm2d(32, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
202+
(act_fn): ReLU(inplace=True)
203+
)
204+
(conv1): ConvLayer(
205+
(conv): Conv2d(32, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
206+
(bn): BatchNorm2d(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
129207
(act_fn): ReLU(inplace=True)
208+
)
209+
(conv2): ConvLayer(
210+
(conv): Conv2d(64, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
130211
(bn): BatchNorm2d(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
212+
(act_fn): ReLU(inplace=True)
131213
)
132214
(pool): MaxPool2d(kernel_size=3, stride=2, padding=1, dilation=1, ceil_mode=False)
133215
)
@@ -165,9 +247,9 @@ model.stem
165247
Stem(
166248
sizes: [3, 64]
167249
(conv0): ConvLayer(
168-
(conv): Conv2d(3, 64, kernel_size=(3, 3), stride=(2, 2), padding=(1, 1))
169-
(act_fn): ReLU(inplace=True)
250+
(conv): Conv2d(3, 64, kernel_size=(3, 3), stride=(2, 2), padding=(1, 1), bias=False)
170251
(bn): BatchNorm2d(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
252+
(act_fn): ReLU(inplace=True)
171253
)
172254
(pool): MaxPool2d(kernel_size=3, stride=2, padding=1, dilation=1, ceil_mode=False)
173255
)
@@ -216,9 +298,9 @@ model.stem
216298
Stem(
217299
sizes: [3, 64]
218300
(conv0): ConvLayer(
219-
(conv): Conv2d(3, 64, kernel_size=(3, 3), stride=(2, 2), padding=(1, 1))
220-
(act_fn): LeakyReLU(negative_slope=0.01, inplace=True)
301+
(conv): Conv2d(3, 64, kernel_size=(3, 3), stride=(2, 2), padding=(1, 1), bias=False)
221302
(bn): BatchNorm2d(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
303+
(act_fn): LeakyReLU(negative_slope=0.01, inplace=True)
222304
)
223305
(pool): MaxPool2d(kernel_size=3, stride=2, padding=1, dilation=1, ceil_mode=False)
224306
)
@@ -242,7 +324,7 @@ model.body.layer_0.block_0.conv.conv_0
242324

243325

244326
ConvLayer(
245-
(conv): Conv2d(64, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
327+
(conv): Conv2d(64, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
246328
(act_fn): LeakyReLU(negative_slope=0.01, inplace=True)
247329
(bn): BatchNorm2d(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
248330
)

docs/_data/sidebars/home_sidebar.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ entries:
1818
- output: web,pdf
1919
title: resnet
2020
url: /resnet
21+
- output: web,pdf
22+
title: xresnet
23+
url: /xresnet
2124
output: web
2225
title: model_constructor
2326
output: web

0 commit comments

Comments
 (0)