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
""" | |
Convert tar file to zip file | |
Author: Dingdong Yang | |
""" | |
import cv2 | |
import numpy as np | |
import tarfile | |
import zipfile |
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.nn.init as init | |
import torch.nn.functional as F | |
class hGRUKernel(nn.Module): | |
''' | |
initializer: the one used to initialize the weights | |
gain: xavier gain |
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.nn.functional as F | |
from torch.autograd import Variable | |
from torch.nn import Parameter | |
def _l2normalize(v, eps=1e-12): | |
return v / (torch.norm(v, p=2) + eps) | |
def max_singular_value(W, u=None, Ip=1): |
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 time | |
import numpy as np | |
time1 = time.time() | |
## double this tensor's second dimension(20->40), you will almost double the time | |
for _ in range(100): | |
tensor = torch.randn(5, 20, 128, 128) | |
array = np.zeros((128, 128), dtype=np.uint8) | |
tensor[1, 2, :, :] = torch.from_numpy(array).float() |