From 3f16dea4b0dc27f42d7d234873ea7eec2b7fe9b6 Mon Sep 17 00:00:00 2001 From: Abhishekvats1997 <34895307+Abhishekvats1997@users.noreply.github.com> Date: Thu, 17 Jun 2021 22:16:57 +0530 Subject: [PATCH 1/3] Update README.md --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 35b13b6..7949719 100644 --- a/README.md +++ b/README.md @@ -53,15 +53,15 @@ We train each model from scratch by default. If you wish to train the model with Run Pruning Training ResNet (depth 152,101,50,34,18) on Imagenet: ```bash -python pruning_imagenet.py -a resnet152 --save_path ./snapshots/resnet152-rate-0.7 --rate_norm 1 --rate_dist 0.4 --layer_begin 0 --layer_end 462 --layer_inter 3 /path/to/Imagenet2012 +python pruning_imagenet.py -a resnet152 --save_dir ./snapshots/resnet152-rate-0.7 --rate_norm 1 --rate_dist 0.4 --layer_begin 0 --layer_end 462 --layer_inter 3 /path/to/Imagenet2012 -python pruning_imagenet.py -a resnet101 --save_path ./snapshots/resnet101-rate-0.7 --rate_norm 1 --rate_dist 0.4 --layer_begin 0 --layer_end 309 --layer_inter 3 /path/to/Imagenet2012 +python pruning_imagenet.py -a resnet101 --save_dir ./snapshots/resnet101-rate-0.7 --rate_norm 1 --rate_dist 0.4 --layer_begin 0 --layer_end 309 --layer_inter 3 /path/to/Imagenet2012 -python pruning_imagenet.py -a resnet50 --save_path ./snapshots/resnet50-rate-0.7 --rate_norm 1 --rate_dist 0.4 --layer_begin 0 --layer_end 156 --layer_inter 3 /path/to/Imagenet2012 +python pruning_imagenet.py -a resnet50 --save_dir ./snapshots/resnet50-rate-0.7 --rate_norm 1 --rate_dist 0.4 --layer_begin 0 --layer_end 156 --layer_inter 3 /path/to/Imagenet2012 -python pruning_imagenet.py -a resnet34 --save_path ./snapshots/resnet34-rate-0.7 --rate_norm 1 --rate_dist 0.4 --layer_begin 0 --layer_end 105 --layer_inter 3 /path/to/Imagenet2012 +python pruning_imagenet.py -a resnet34 --save_dir ./snapshots/resnet34-rate-0.7 --rate_norm 1 --rate_dist 0.4 --layer_begin 0 --layer_end 105 --layer_inter 3 /path/to/Imagenet2012 -python pruning_imagenet.py -a resnet18 --save_path ./snapshots/resnet18-rate-0.7 --rate_norm 1 --rate_dist 0.4 --layer_begin 0 --layer_end 57 --layer_inter 3 /path/to/Imagenet2012 +python pruning_imagenet.py -a resnet18 --save_dir ./snapshots/resnet18-rate-0.7 --rate_norm 1 --rate_dist 0.4 --layer_begin 0 --layer_end 57 --layer_inter 3 /path/to/Imagenet2012 ``` Explanation: From 59735bf6fbd70a6540910535272a6e740703755b Mon Sep 17 00:00:00 2001 From: Abhishekvats1997 <34895307+Abhishekvats1997@users.noreply.github.com> Date: Thu, 17 Jun 2021 22:20:20 +0530 Subject: [PATCH 2/3] Update pruning_imagenet.py Fixes an issue where the unnecessary calculation of gradients leads to GPU memory running out in some cases. --- pruning_imagenet.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/pruning_imagenet.py b/pruning_imagenet.py index dcd4ea3..5cac978 100644 --- a/pruning_imagenet.py +++ b/pruning_imagenet.py @@ -312,14 +312,15 @@ def validate(val_loader, model, criterion, log): target_var = torch.autograd.Variable(target, volatile=True) # compute output - output = model(input_var) - loss = criterion(output, target_var) - - # measure accuracy and record loss - prec1, prec5 = accuracy(output.data, target, topk=(1, 5)) - losses.update(loss.data[0], input.size(0)) - top1.update(prec1[0], input.size(0)) - top5.update(prec5[0], input.size(0)) + with torch.no_graad(): + output = model(input_var) + loss = criterion(output, target_var) + + # measure accuracy and record loss + prec1, prec5 = accuracy(output.data, target, topk=(1, 5)) + losses.update(loss.data[0], input.size(0)) + top1.update(prec1[0], input.size(0)) + top5.update(prec5[0], input.size(0)) # measure elapsed time batch_time.update(time.time() - end) From ccc989f544d67d25ff0b332eda597331977dcb18 Mon Sep 17 00:00:00 2001 From: Abhishekvats1997 <34895307+Abhishekvats1997@users.noreply.github.com> Date: Thu, 17 Jun 2021 22:21:22 +0530 Subject: [PATCH 3/3] Update pruning_imagenet.py --- pruning_imagenet.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pruning_imagenet.py b/pruning_imagenet.py index 5cac978..8bae857 100644 --- a/pruning_imagenet.py +++ b/pruning_imagenet.py @@ -312,7 +312,7 @@ def validate(val_loader, model, criterion, log): target_var = torch.autograd.Variable(target, volatile=True) # compute output - with torch.no_graad(): + with torch.no_grad(): output = model(input_var) loss = criterion(output, target_var)