Created
February 13, 2019 06:15
-
-
Save ryujaehun/523f583a0d798e70b1fccf1fabaa3ade to your computer and use it in GitHub Desktop.
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 torch | |
import torchvision | |
import numpy as np | |
model=torchvision.models.vgg19(pretrained=True) | |
input=torch.rand(1,3,224,224) | |
def get_features_hook(self, input, output): | |
_max = output.data.cpu().numpy().max() | |
_min = output.data.cpu().numpy().min() | |
np.save(str(self),output.data.cpu().numpy()) | |
print("self: ",str(self),'max: ',_max,'\nmin: ',_min) | |
model=torchvision.models.vgg19(pretrained=True) | |
for i,_ in model.named_children(): | |
for k in range(len(model._modules.get(i))): | |
model._modules.get(i)[k].register_forward_hook(get_features_hook) | |
model(input) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment