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
from torch.optim.optimizer import Optimizer, required | |
class LARS(Optimizer): | |
def __init__(self, params, lr=required, momentum=0, dampening=0, | |
weight_decay=0, nesterov=False, eta=0.001): | |
if lr is not required and lr < 0.0: | |
raise ValueError("Invalid learning rate: {}".format(lr)) | |
if momentum < 0.0: | |
raise ValueError("Invalid momentum value: {}".format(momentum)) |
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, torch.nn as nn | |
from torch.autograd import Variable | |
text = ['BOS', 'How', 'are', 'you', 'EOS'] | |
seq_len = len(text) | |
batch_size = 1 | |
embedding_size = 1 | |
hidden_size = 1 | |
output_size = 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
""" | |
Sublime shortcuts for jupyter notebook | |
""" | |
from jupyter_core.paths import jupyter_config_dir | |
import os | |
custom_js_path = os.path.join(jupyter_config_dir(), 'custom', 'custom.js') | |
custom_path = os.path.join(jupyter_config_dir(), 'custom') | |
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 argparse | |
import torch | |
import torch.nn as nn | |
import torch.nn.functional as F | |
from torch.autograd import Variable | |
from torch.optim import lr_scheduler | |
import torch.utils.data as data | |
from torch.nn.utils.rnn import pack_padded_sequence as pack, pad_packed_sequence as unpack | |
import torchaudio | |
import torchaudio.transforms as tat |
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
""" | |
Create train, valid, test iterators for CIFAR-10 [1]. | |
Easily extended to MNIST, CIFAR-100 and Imagenet. | |
[1]: https://discuss.pytorch.org/t/feedback-on-pytorch-for-kaggle-competitions/2252/4 | |
""" | |
import torch | |
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
# This is inspired by the fantastic guide https://github.com/saiprashanths/dl-setup | |
# I have just updated the python-related commands so that everything works in Python 3. | |
# Tested on Xubuntu 16.04. | |
# First of all let's update the repos: | |
sudo apt-get update | |
# Only if you have a CUDA-compatible Nvidia card, install CUDA. | |
# Check on the Nvidia website what is the latest driver version which supports your card. | |
# At the time of this writing it was 367. |
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 | |
from torch import nn | |
from torch.autograd import Variable | |
import torch.nn.functional as F | |
class RNN(nn.Module): | |
def __init__(self, input_size, hidden_size, output_size, n_layers=1): | |
super(RNN, self).__init__() | |
self.input_size = input_size | |
self.hidden_size = hidden_size |
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
"""Downsized version of Xception, without residual connections. | |
""" | |
from __future__ import print_function | |
from __future__ import absolute_import | |
from keras.models import Model | |
from keras.layers import Dense | |
from keras.layers import Input | |
from keras.layers import BatchNormalization | |
from keras.layers import Activation |
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 torch.nn import functional as F | |
from torch.autograd import Variable | |
from torch import optim | |
import numpy as np | |
import math, random | |
# Generating a noisy multi-sin wave |
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
#!/bin/bash | |
# install CUDA Toolkit v8.0 | |
# instructions from https://developer.nvidia.com/cuda-downloads (linux -> x86_64 -> Ubuntu -> 16.04 -> deb (network)) | |
CUDA_REPO_PKG="cuda-repo-ubuntu1604_8.0.61-1_amd64.deb" | |
wget http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/${CUDA_REPO_PKG} | |
sudo dpkg -i ${CUDA_REPO_PKG} | |
sudo apt-get update | |
sudo apt-get -y install cuda |
NewerOlder