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 | |
| from torch.nn.utils.rnn import pack_padded_sequence, pad_packed_sequence | |
| seqs = ['gigantic_string','tiny_str','medium_str'] | |
| # make <pad> idx 0 | |
| vocab = ['<pad>'] + sorted(set(''.join(seqs))) | |
| # make model |
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
| """ 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 |
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 mincepie import mapreducer, launcher | |
| import gflags | |
| import glob | |
| import leargist | |
| import numpy as np | |
| import os | |
| from PIL import Image | |
| import uuid | |
| # constant value |
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
| # Matches patterns such as: | |
| # https://www.facebook.com/my_page_id => my_page_id | |
| # http://www.facebook.com/my_page_id => my_page_id | |
| # http://www.facebook.com/#!/my_page_id => my_page_id | |
| # http://www.facebook.com/pages/Paris-France/Vanity-Url/123456?v=app_555 => 123456 | |
| # http://www.facebook.com/pages/Vanity-Url/45678 => 45678 | |
| # http://www.facebook.com/#!/page_with_1_number => page_with_1_number | |
| # http://www.facebook.com/bounce_page#!/pages/Vanity-Url/45678 => 45678 | |
| # http://www.facebook.com/bounce_page#!/my_page_id?v=app_166292090072334 => my_page_id | |
| # http://www.facebook.com/my.page.is.great => my.page.is.great |