Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
| """Short and sweet LSTM implementation in Tensorflow. | |
| Motivation: | |
| When Tensorflow was released, adding RNNs was a bit of a hack - it required | |
| building separate graphs for every number of timesteps and was a bit obscure | |
| to use. Since then TF devs added things like `dynamic_rnn`, `scan` and `map_fn`. | |
| Currently the APIs are decent, but all the tutorials that I am aware of are not | |
| making the best use of the new APIs. | |
| Advantages of this implementation: |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 theano | |
| import theano.tensor as T | |
| from theano.tensor.shared_randomstreams import RandomStreams | |
| from theano.sandbox.rng_mrg import MRG_RandomStreams | |
| from lasagne.updates import adam | |
| from lasagne.utils import collect_shared_vars | |
| from sklearn.datasets import fetch_mldata | |
| from sklearn.cross_validation import train_test_split | |
| from sklearn import preprocessing |
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
| # Working example for my blog post at: | |
| # http://danijar.com/variable-sequence-lengths-in-tensorflow/ | |
| import functools | |
| import sets | |
| import tensorflow as tf | |
| from tensorflow.models.rnn import rnn_cell | |
| from tensorflow.models.rnn import rnn | |
| def lazy_property(function): |
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 sys | |
| sys.path.append('..') | |
| import os | |
| import json | |
| from time import time | |
| import numpy as np | |
| from tqdm import tqdm | |
| from matplotlib import pyplot as plt | |
| from sklearn.externals import joblib |
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
| # -*- coding: utf-8 -*- | |
| """ | |
| Created on Mon Aug 22 00:36:48 2016 | |
| @author: park | |
| """ | |
| #%% train | |
| import theano |
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
| # Alec Radford, Indico, Kyle Kastner | |
| # License: MIT | |
| """ | |
| Convolutional VAE in a single file. | |
| Bringing in code from IndicoDataSolutions and Alec Radford (NewMu) | |
| Additionally converted to use default conv2d interface instead of explicit cuDNN | |
| """ | |
| import theano | |
| import theano.tensor as T | |
| from theano.compat.python2x import OrderedDict |
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 theano | |
| import theano.tensor as T | |
| from theano.sandbox.rng_mrg import MRG_RandomStreams as RandomStreams | |
| from theano.tensor.signal.downsample import max_pool_2d | |
| from theano.tensor.extra_ops import repeat | |
| from theano.sandbox.cuda.dnn import dnn_conv | |
| from time import time | |
| import numpy as np | |
| from matplotlib import pyplot as plt |
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
| -- Max Jaderberg 4/9/13 | |
| -- GPU Effectiveness test | |
| require 'torch' | |
| require 'sys' | |
| require 'nn' | |
| require 'xlua' | |
| cmd = torch.CmdLine() | |
| cmd:text() |
NewerOlder