commit files to HF hub
Browse files
README.md
ADDED
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# wide_resnet101_2
|
2 |
+
Implementation of Wide ResNet proposed in [\"Wide Residual
|
3 |
+
Networks\"](https://arxiv.org/pdf/1605.07146.pdf)
|
4 |
+
|
5 |
+
Create a default model
|
6 |
+
|
7 |
+
``` python
|
8 |
+
WideResNet.wide_resnet50_2()
|
9 |
+
WideResNet.wide_resnet101_2()
|
10 |
+
# create a wide_resnet18_4
|
11 |
+
WideResNet.resnet18(block=WideResNetBottleNeckBlock, width_factor=4)
|
12 |
+
```
|
13 |
+
|
14 |
+
Examples:
|
15 |
+
|
16 |
+
``` python
|
17 |
+
# change activation
|
18 |
+
WideResNet.resnext50_32x4d(activation = nn.SELU)
|
19 |
+
# change number of classes (default is 1000 )
|
20 |
+
WideResNet.resnext50_32x4d(n_classes=100)
|
21 |
+
# pass a different block
|
22 |
+
WideResNet.resnext50_32x4d(block=SENetBasicBlock)
|
23 |
+
# change the initial convolution
|
24 |
+
model = WideResNet.resnext50_32x4d
|
25 |
+
model.encoder.gate.conv1 = nn.Conv2d(3, 64, kernel_size=3)
|
26 |
+
# store each feature
|
27 |
+
x = torch.rand((1, 3, 224, 224))
|
28 |
+
model = WideResNet.wide_resnet50_2()
|
29 |
+
features = []
|
30 |
+
x = model.encoder.gate(x)
|
31 |
+
for block in model.encoder.layers:
|
32 |
+
x = block(x)
|
33 |
+
features.append(x)
|
34 |
+
print([x.shape for x in features])
|
35 |
+
# [torch.Size([1, 64, 56, 56]), torch.Size([1, 128, 28, 28]), torch.Size([1, 256, 14, 14]), torch.Size([1, 512, 7, 7])]
|
36 |
+
```
|
37 |
+
|
38 |
+
|