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
''' | |
As with NLLLoss , the input given is expected to contain log-probabilities… | |
The targets are given as probabilities (i.e. without taking the logarithm). | |
https://discuss.pytorch.org/t/kldivloss-returns-negative-value/62148 | |
https://discuss.pytorch.org/t/kl-divergence-produces-negative-values/16791/16 | |
https://discuss.pytorch.org/t/kullback-leibler-divergence-loss-function-giving-negative-values/763/16 | |
''' | |
import torch |
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 torch.nn as nn | |
from lsq import Conv2dLSQ, LinearLSQ, ActLSQ | |
__all__ = ['ResNet', 'resnet18', 'resnet34', 'resnet50', 'resnet101', | |
'resnet152', 'resnext50_32x4d', 'resnext101_32x8d', | |
'wide_resnet50_2', 'wide_resnet101_2'] | |
def conv3x3(in_planes, out_planes, stride=1, groups=1, dilation=1): | |
"""3x3 convolution with padding""" |
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 torch.nn as nn | |
import torch.optim as optim | |
from torch.autograd import Variable | |
import torch.nn.functional as F | |
import matplotlib.pyplot as plt | |
import numpy as np |
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 numpy as np | |
torch.backends.cudnn.deterministic = True | |
torch.backends.cudnn.benchmark = False | |
np.random.seed(0) | |
torch.manual_seed(0) | |
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 numpy as np | |
torch.backends.cudnn.deterministic = True | |
torch.backends.cudnn.benchmark = False | |
np.random.seed(0) | |
torch.manual_seed(0) | |
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 numpy as np | |
torch.backends.cudnn.deterministic = True | |
torch.backends.cudnn.benchmark = False | |
np.random.seed(0) | |
torch.manual_seed(0) | |
nbit = 3 |
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 math | |
import numpy as np | |
import torch.nn.functional as F | |
import torch | |
import torch.nn as nn | |
torch.backends.cudnn.deterministic = True | |
torch.backends.cudnn.benchmark = False |
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 as t | |
import numpy as np | |
class GradScale(t.nn.Module): | |
def forward(self, x, scale): | |
y = x | |
y_grad = x / scale | |
return (y - y_grad).detach() + y_grad | |
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 tempfile | |
import torch | |
import torch.distributed as dist | |
import torch.nn as nn | |
import torch.optim as optim | |
import torch.multiprocessing as mp | |
import numpy as np | |
import random | |
from torch.nn.parallel import DistributedDataParallel as DDP |
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
''' | |
Author: komuw/pycrypto_AES.py | |
Security issues: | |
+ https://stackoverflow.com/questions/2641720/for-aes-cbc-encryption-whats-the-importance-of-the-iv | |
+ https://defuse.ca/cbcmodeiv.htm | |
+ https://passingcuriosity.com/2009/aes-encryption-in-python-with-m2crypto/ | |
''' | |
from Crypto.Cipher import AES |
NewerOlder