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
def print_nonzeros(model): | |
nonzero = total = 0 | |
for name, p in model.named_parameters(): | |
tensor = p.data.cpu().numpy() | |
nz_count = np.count_nonzero(tensor) | |
total_params = np.prod(tensor.shape) | |
nonzero += nz_count | |
total += total_params | |
print(f'{name:20} | nonzeros = {nz_count:7} / {total_params:7} ({100 * nz_count / total_params:6.2f}%) | total_pruned = {total_params - nz_count :7} | shape = {tensor.shape}') | |
print(f'alive: {nonzero}, pruned : {total - nonzero}, total: {total}, Compression rate : {total/nonzero:10.2f}x ({100 * (total-nonzero) / total:6.2f}% pruned)') |
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
import os | |
parser = argparse.ArgumentParser() | |
parser.add_argument("--gpu", default="0", type=str) | |
args = parser.parse_args() | |
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
Check this repo : | |
https://github.com/mseitzer/gpu-monitor |
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
import os | |
import numpy as np | |
from scipy.stats import wasserstein_distance, energy_distance | |
from matplotlib import pyplot as plt | |
epoch_name = "epoch_1_" | |
epoch = 1 | |
a = os.getcwd() | |
root, dirs, files = next(os.walk(a)) |
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
import os | |
import numpy as np | |
from scipy.stats import wasserstein_distance, energy_distance | |
from matplotlib import pyplot as plt | |
epoch_name = "epoch_1_" | |
epoch = 1 | |
a = os.getcwd() | |
root, dirs, files = next(os.walk(a)) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
def save_latest(epoch, model_dir, model, optimizer, scheduler=None, wandb_id=None): | |
"""Saves latest epoch's weights and other necessary things to resume | |
""" | |
model_states = { | |
"epoch": epoch, | |
"state_dict": model.state_dict(), | |
"opt_state_dict": optimizer.state_dict(), | |
"sch_state_dict": scheduler.state_dict() if scheduler != None else None, | |
"wandb_id_save": wandb_id, #----> Remove this if you don't use wandb for logging | |
} |
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
# First run the following things | |
echo "Downloading..." | |
wget -c http://dl.caffe.berkeleyvision.org/caffe_ilsvrc12.tar.gz | |
echo "Unzipping..." | |
tar -xf caffe_ilsvrc12.tar.gz && rm -f caffe_ilsvrc12.tar.gz | |
echo "Done." |
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
#!/bin/bash | |
# | |
# script to download and extract ImageNet dataset | |
# ILSVRC2012_img_train.tar (about 138 GB) | |
# ILSVRC2012_img_val.tar (about 6.3 GB) | |
# | |
# make sure ILSVRC2012_img_train.tar & ILSVRC2012_img_val.tar in your current directory | |
# | |
# https://github.com/facebook/fb.resnet.torch/blob/master/INSTALL.md | |
# |
OlderNewer