Skip to content

Commit a02f1ba

Browse files
Merge pull request #353 from yoshitomo-matsubara/dev
Fix a typo and replace pretrained with weights
2 parents 4f6e31f + 4dbdbd0 commit a02f1ba

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

configs/official/ilsvrc2012/yoshitomo-matsubara/rrpr2020/README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -79,15 +79,15 @@ python3 examples/torchvision/image_classification.py \
7979
-test_only
8080
```
8181

82-
#### L2 (CSE + L2)
82+
#### L2 (CE + L2)
8383
```
8484
python3 examples/torchvision/image_classification.py \
85-
--config configs/official/ilsvrc2012/yoshitomo-matsubara/rrpr2020/cse_l2-resnet18_from_resnet34.yaml \
85+
--config configs/official/ilsvrc2012/yoshitomo-matsubara/rrpr2020/ce_l2-resnet18_from_resnet34.yaml \
8686
-test_only
8787
```
8888

8989
#### PAD-L2 (2nd stage)
90-
Note that you first need to train a model with L2 (CSE + L2), and load the ckpt file designated in the following yaml file.
90+
Note that you first need to train a model with L2 (CE + L2), and load the ckpt file designated in the following yaml file.
9191
i.e., PAD-L2 is a two-stage training method.
9292

9393
```
@@ -159,19 +159,19 @@ torchrun --nproc_per_node=${NUM_GPUS} examples/torchvision/image_classification
159159
--world_size ${NUM_GPUS}
160160
```
161161

162-
#### L2 (CSE + L2)
162+
#### L2 (CE + L2)
163163
If you use fewer or more GPUs for distributed training, you should update `batch_size: 171` in `train_data_loader` entry
164164
so that (batch size) * ${NUM_GPUS} = 512. (e.g., `batch_size: 64` if you use 8 GPUs for distributed training.)
165165

166166
```
167167
torchrun --nproc_per_node=${NUM_GPUS} examples/torchvision/image_classification.py \
168-
--config configs/official/ilsvrc2012/yoshitomo-matsubara/rrpr2020/cse_l2-resnet18_from_resnet34.yaml \
169-
--run_log log/ilsvrc2012/cse_l2-resnet18_from_resnet34.log \
168+
--config configs/official/ilsvrc2012/yoshitomo-matsubara/rrpr2020/ce_l2-resnet18_from_resnet34.yaml \
169+
--run_log log/ilsvrc2012/ce_l2-resnet18_from_resnet34.log \
170170
--world_size ${NUM_GPUS}
171171
```
172172

173173
#### PAD-L2 (2nd stage)
174-
Note that you first need to train a model with L2 (CSE + L2), and load the ckpt file designated in the following yaml file.
174+
Note that you first need to train a model with L2 (CE + L2), and load the ckpt file designated in the following yaml file.
175175
i.e., PAD-L2 is a two-stage training method.
176176

177177
If you use fewer or more GPUs for distributed training, you should update `batch_size: 171` in `train_data_loader` entry

torchdistill/models/custom/bottleneck/detection/resnet_backbone.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,18 +96,18 @@ def custom_resnet_fpn_backbone(backbone_key, backbone_params_config,
9696
prefix = 'custom_'
9797
start_idx = backbone_key.find(prefix) + len(prefix)
9898
org_backbone_key = backbone_key[start_idx:] if backbone_key.startswith(prefix) else backbone_key
99+
weights = backbone_params_config.get('weights', None)
99100
backbone = resnet.__dict__[org_backbone_key](
100-
pretrained=backbone_params_config.get('pretrained', False),
101+
weights=weights,
101102
norm_layer=norm_layer
102103
)
103104
if layer1 is not None:
104105
backbone.layer1 = layer1
105106

106107
trainable_layers = backbone_params_config.get('trainable_backbone_layers', 4)
107-
# select layers that wont be frozen
108+
# select layers that won't be frozen
108109
assert 0 <= trainable_layers <= 6
109110
layers_to_train = ['layer4', 'layer3', 'layer2', 'layer1', 'bn1', 'conv1'][:trainable_layers]
110-
# freeze layers only if pretrained backbone is used
111111
for name, parameter in backbone.named_parameters():
112112
if all([not name.startswith(layer) for layer in layers_to_train]):
113113
parameter.requires_grad_(False)

0 commit comments

Comments
 (0)