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 collections import namedtuple | |
import torch | |
LOG_DIR = "./logs/" | |
CACHE_DIR = "./cache/" | |
device = "cuda" if torch.cuda.is_available() else "cpu" | |
FineTuningConfig = namedtuple('FineTuningConfig', | |
field_names="num_classes, dropout, init_range, batch_size, lr, max_norm," |
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 pytorch_transformers import cached_path | |
# download pre-trained model and config | |
state_dict = torch.load(cached_path("https://s3.amazonaws.com/models.huggingface.co/" | |
"naacl-2019-tutorial/model_checkpoint.pth"), map_location='cpu') | |
config = torch.load(cached_path("https://s3.amazonaws.com/models.huggingface.co/" | |
"naacl-2019-tutorial/model_training_args.bin")) | |
# init model: Transformer base + classifier head |
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.nn as nn | |
import torch | |
class Transformer(nn.Module): | |
"Adopted from https://github.com/huggingface/naacl_transfer_learning_tutorial" | |
def __init__(self, embed_dim, hidden_dim, num_embeddings, num_max_positions, | |
num_heads, num_layers, dropout, causal): | |
super().__init__() | |
self.causal = causal |
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
sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)" | |
echo "ZSH=$HOME/.oh-my-zsh" >> ~/.zshrc | |
echo "source $ZSH/oh-my-zsh.sh" >> ~/.zshrc | |
echo "ZSH_THEME='robbyrussel'" >> ~/.zshrc | |
echo "plugins = (git python osx web-search vi-mode dotenv" >> ~/.zshrc | |
echo "alias config='/usr/bin/git --git-dir=$HOME/.cfg/ --work-tree=$HOME'" >> ~/.zshrc | |
source ~/.zshrc | |
echo ".cfg" >> .gitignore | |
git clone --bare https://github.com/ben0it8/dotfiles.git .cfg/ | |
config checkout |
NewerOlder