Created
April 3, 2019 08:57
-
-
Save crcrpar/a4c28705a4e84d9e7d5bdc219a702711 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.nn as nn | |
from torch.nn.utils import spectral_norm | |
if __name__ == '__main__': | |
layer = nn.Conv2d(3, 15, 3, 1, 1) | |
layer = spectral_norm(layer) | |
torch.save(layer.state_dict(), 'tmp.pth') | |
layer1 = nn.Conv2d(3, 15, 3, 1, 1) | |
layer1 = spectral_norm(layer1) | |
sd = torch.load('tmp.pth') | |
print(list(sd.keys())) | |
layer1.load_state_dict(sd) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment