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
#!/bin/bash | |
# Script for installing tmux on systems where you don't have root access. | |
# tmux will be installed in $HOME/local/bin. | |
# It's assumed that wget and a C/C++ compiler are installed. | |
# exit on error | |
set -e | |
TMUX_VERSION=1.8 |
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 as nn | |
nn.Dropout(p=0.0).eval()(torch.ones(4, 10)) | |
"""Output | |
tensor([[1., 1., 1., 1., 1., 1., 1., 1., 1., 1.], | |
[1., 1., 1., 1., 1., 1., 1., 1., 1., 1.], | |
[1., 1., 1., 1., 1., 1., 1., 1., 1., 1.], | |
[1., 1., 1., 1., 1., 1., 1., 1., 1., 1.]]) | |
""" |
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
class Foo(): | |
def __init__(self, a, b, c, d=0): | |
self.a = a | |
self.b = b | |
self.c = c | |
self.d = d | |
params = { |
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 | |
print("HELLO") | |
x = torch.randn(100, 100).cuda() | |
def print_hello(name): | |
print("Hello", name) | |
print("Very nice to meet you") |
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
# https://github.com/pytorch/examples/blob/master/imagenet/main.py#L392-L396 | |
def adjust_learning_rate(optimizer, epoch, args): | |
"""Sets the learning rate to the initial LR decayed by 10 every 30 epochs""" | |
lr = args.lr * (0.1 ** (epoch // 30)) | |
for param_group in optimizer.param_groups: | |
param_group['lr'] = lr | |
# Create a learning rate adjustment function that divides the learning rate by 10 every 30 epochs | |
def adjust_learning_rate(epoch): |
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 | |
from torch import nn | |
from torch.nn.utils.rnn import pack_padded_sequence, pad_packed_sequence | |
class DynamicRNN(nn.Module): | |
""" | |
The wrapper version of recurrent modules including RNN, LSTM | |
that support packed sequence batch. | |
""" |
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 argparse | |
parser.add_argument( | |
"--list", | |
nargs="+", | |
help="This will accept the list of values or a single value", | |
default=['1'] | |
) | |
args = parser.parse_args() |
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
""" | |
Reference: https://pytorch.org/docs/master/torchvision/models.html | |
""" | |
from urllib.request import urlopen | |
from PIL import Image | |
from torchvision import transforms | |
# Read an example image |
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 time | |
import torch | |
import torch.nn as nn | |
device = 'cuda:0' | |
batch_size = 10 | |
channels = 64 | |
h, w = 128, 128 |
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 as nn | |
import torch.optim as optim | |
import torch.nn.functional as F | |
torch.manual_seed(2809) | |
NewerOlder