This file contains hidden or 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
from torch.utils.data import DataLoader, Dataset | |
import torch, torch.nn as nn | |
import numpy as np | |
class DS(Dataset): | |
# Constructor | |
def __init__(self): | |
super().__init__() | |
X = list(np.arange(15000)) | |
self.x = X |
This file contains hidden or 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, torch.nn as nn, torch.nn.functional as F | |
def perform_non_parallelconv(input, convs): | |
outs = [] | |
for i in range(len(convs)): | |
o = convs[i](input[:, i]) | |
outs.append(o) | |
outs = torch.cat(outs, dim=1) | |
return outs |
This file contains hidden or 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 | |
with torch.autograd.set_detect_anomaly(True): | |
x = torch.randn(5,6, requires_grad=True) | |
z = x.sum(-1) | |
z += z * z | |
z.sum().backward() |
This file contains hidden or 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.functional as F | |
is_cuda = True | |
input = torch.randn(1, 19, 32, 64, requires_grad=True) | |
target = torch.randint(22, size=(1,32,64,)) | |
print(input.dim()) | |
print("number of out-of-bound targets", (target > 18).sum()) |
This file contains hidden or 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
mv Day.. day_ # move Day folder to day_ folder | |
# move MTS files to root dir | |
mv ./01/2019/* . | |
# to concate MTS files into MP4 | |
ffmpeg -i "concat:$(echo *.MTS | tr ' ' '|')" -strict -2 concat_out.mp4 |
This file contains hidden or 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
TORCH_CUDA_ARCH_LIST="5.2 6.0 6.1 7.0 7.5 8.0 8.6+PTX" python setup.py build | |
python setup.py install | |
D:\cmder_mini\Cmder.exe "%ActivDir%" |
This file contains hidden or 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 torchvision, copy | |
import torch, torch.nn as nn | |
def reset_all_weights(model: nn.Module) -> None: | |
""" | |
refs: | |
- https://discuss.pytorch.org/t/how-to-re-set-alll-parameters-in-a-network/20819/6 | |
- https://stackoverflow.com/questions/63627997/reset-parameters-of-a-neural-network-in-pytorch | |
- https://pytorch.org/docs/stable/generated/torch.nn.Module.html | |
""" |
This file contains hidden or 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, torch.nn as nn | |
class LowlevelModule(nn.Module): | |
def __init__(self, custom_val): | |
super().__init__() | |
self.custom_val = custom_val | |
def print_custom_val(self): | |
print(self.custom_val.item()) |
This file contains hidden or 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, torch.nn as nn | |
import torch.optim as optim, torch.nn.functional as F | |
class CustomLinearNoWeightDecay(nn.Module): | |
def __init__(self, mask): | |
super().__init__() | |
self.register_buffer("mask", mask) | |
out_channels, in_channels = mask.shape | |
self.weight = nn.Parameter(torch.randn(out_channels, in_channels)) | |
This file contains hidden or 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
command: | |
-------- | |
sudo useradd -m -d /home/<user> -s /bin/bash -c "<rollnumber>" -U <user> | |
password: | |
--------- | |
sudo passwd <user> | |
Add user to sudo | |
----------------- |