commit files to HF hub
Browse files
README.md
ADDED
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# resnext50_32x4d
|
2 |
+
Implementation of ResNetXt proposed in [\"Aggregated Residual
|
3 |
+
Transformation for Deep Neural
|
4 |
+
Networks\"](https://arxiv.org/pdf/1611.05431.pdf)
|
5 |
+
|
6 |
+
Create a default model
|
7 |
+
|
8 |
+
``` python
|
9 |
+
ResNetXt.resnext50_32x4d()
|
10 |
+
ResNetXt.resnext101_32x8d()
|
11 |
+
# create a resnetxt18_32x4d
|
12 |
+
ResNetXt.resnet18(block=ResNetXtBottleNeckBlock, groups=32, base_width=4)
|
13 |
+
```
|
14 |
+
|
15 |
+
Examples:
|
16 |
+
|
17 |
+
: ``` python
|
18 |
+
# change activation
|
19 |
+
ResNetXt.resnext50_32x4d(activation = nn.SELU)
|
20 |
+
# change number of classes (default is 1000 )
|
21 |
+
ResNetXt.resnext50_32x4d(n_classes=100)
|
22 |
+
# pass a different block
|
23 |
+
ResNetXt.resnext50_32x4d(block=SENetBasicBlock)
|
24 |
+
# change the initial convolution
|
25 |
+
model = ResNetXt.resnext50_32x4d
|
26 |
+
model.encoder.gate.conv1 = nn.Conv2d(3, 64, kernel_size=3)
|
27 |
+
# store each feature
|
28 |
+
x = torch.rand((1, 3, 224, 224))
|
29 |
+
model = ResNetXt.resnext50_32x4d()
|
30 |
+
# first call .features, this will activate the forward hooks and tells the model you'll like to get the features
|
31 |
+
model.encoder.features
|
32 |
+
model(torch.randn((1,3,224,224)))
|
33 |
+
# get the features from the encoder
|
34 |
+
features = model.encoder.features
|
35 |
+
print([x.shape for x in features])
|
36 |
+
#[torch.Size([1, 64, 112, 112]), torch.Size([1, 64, 56, 56]), torch.Size([1, 128, 28, 28]), torch.Size([1, 256, 14, 14])]
|
37 |
+
```
|
38 |
+
|
39 |
+
|