-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
distributed save&load, imagenette, new kd.sh, fix validation error
- Loading branch information
Showing
6 changed files
with
74 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# https://github.com/tanglang96/DataLoaders_DALI/blob/master/base.py | ||
|
||
from nvidia.dali.plugin.pytorch import DALIGenericIterator | ||
|
||
class DALIDataloader(DALIGenericIterator): | ||
def __init__(self, pipeline, size, batch_size, output_map=["data", "label"], auto_reset=True, onehot_label=False): | ||
self.size = size | ||
self.batch_size = batch_size | ||
self.onehot_label = onehot_label | ||
self.output_map = output_map | ||
super().__init__(pipelines=pipeline, size=size, auto_reset=auto_reset, output_map=output_map) | ||
|
||
def __next__(self): | ||
if self._first_batch is not None: | ||
batch = self._first_batch | ||
self._first_batch = None | ||
return batch | ||
data = super().__next__()[0] | ||
if self.onehot_label: | ||
return [data[self.output_map[0]], data[self.output_map[1]].squeeze().long()] | ||
else: | ||
return [data[self.output_map[0]], data[self.output_map[1]]] | ||
|
||
def __len__(self): | ||
if self.size%self.batch_size==0: | ||
return self.size//self.batch_size | ||
else: | ||
return self.size//self.batch_size+1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
python train_student.py --path-t ./save/models/ResNet34_vanilla/resnet34_transformed.pth \ | ||
--batch_size 256 --epochs 90 --dataset imagenet --gpu_id 4,5,6,7 --dist-url tcp:https://127.0.0.1:23333 \ | ||
--print-freq 100 --num_workers 16 --distill kd --model_s ResNet18 -r 1 -a 1 -b 0 --trial 0 \ | ||
--batch_size 256 --epochs 90 --dataset imagenet --gpu_id 0,1,2,3,4,5,6,7 --dist-url tcp:https://127.0.0.1:23333 \ | ||
--print-freq 100 --num_workers 32 --distill kd --model_s ResNet18 -r 1 -a 1 -b 0 --trial test \ | ||
--multiprocessing-distributed --learning_rate 0.1 --lr_decay_epochs 30,60 --weight_decay 1e-4 --dali gpu |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters