- Beyond Paragraphs: NLP for Long Sequences - Overview | Resources | Lecture
- Event-Centric Natural Language Processing - Overview | Resources | Lecture
- Towards Reproducible Machine Learning Research in NLP - Overview | Resources | Lecture
- Zero- and Few-Shot NLP with Pretrained Language Models - Overview | Resources | Lecture
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 subprocess, getpass | |
def get_gpu_usage(): | |
""" | |
Returns a dict which contains information about memory usage for each GPU. | |
In the following output, the GPU with id "0" uses 5774 MB of 16280 MB. | |
253 MB are used by other users, which means that we are using 5774 - 253 MB. | |
{ |
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 | |
import collections | |
class Builder(object): | |
def __init__(self, *namespaces): | |
self._namespace = collections.ChainMap(*namespaces) | |
def __call__(self, name, *args, **kwargs): | |
try: | |
return self._namespace[name](*args, **kwargs) |
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 configparser | |
from dataclasses import dataclass | |
@dataclass | |
class Sections: | |
raw_sections: dict | |
def __post_init__(self): | |
for section_key, section_value in self.raw_sections.items(): |
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 LongTensor | |
from torch.nn import Embedding, LSTM | |
from torch.autograd import Variable | |
from torch.nn.utils.rnn import pack_padded_sequence, pad_packed_sequence | |
## We want to run LSTM on a batch of 3 character sequences ['long_str', 'tiny', 'medium'] | |
# | |
# Step 1: Construct Vocabulary | |
# Step 2: Load indexed data (list of instances, where each instance is list of character indices) |
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 free and unencumbered software released into the public domain. | |
Anyone is free to copy, modify, publish, use, compile, sell, or | |
distribute this software, either in source code form or as a compiled | |
binary, for any purpose, commercial or non-commercial, and by any | |
means. | |
In jurisdictions that recognize copyright laws, the author or authors | |
of this software dedicate any and all copyright interest in the | |
software to the public domain. We make this dedication for the benefit |
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
""" Trains an agent with (stochastic) Policy Gradients on Pong. Uses OpenAI Gym. """ | |
import numpy as np | |
import cPickle as pickle | |
import gym | |
# hyperparameters | |
H = 200 # number of hidden layer neurons | |
batch_size = 10 # every how many episodes to do a param update? | |
learning_rate = 1e-4 | |
gamma = 0.99 # discount factor for reward |
Turn this cute YouTube cat video into a briefer-but-still-cute GIF:
- youtube-dl is a command-line tool for quickly downloading video files from a given YouTube URL
NewerOlder