Skip to content

Instantly share code, notes, and snippets.

@cswhjiang
cswhjiang / tf_lstm.py
Created October 5, 2016 02:35 — forked from siemanko/tf_lstm.py
Simple implementation of LSTM in Tensorflow in 50 lines (+ 130 lines of data generation and comments)
"""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:
dofile('./nn/rop.lua')
-- dofile('./rop_0.lua')
--include('SUMCriterion.lua')
local input_size = 3
local target_size = 4
local hidden_size = 2
--local mini_batch_size = 11
local input = torch.randn(input_size)
function saddle_points
H = [2,0; 0,-1];
% perb = randn(2,2);
% perb = perb*perb'*0.1;
% H = H + perb;
[x, y] = meshgrid([-4:0.1:4], [-4:0.1:4]);
z = zeros(size(x));
@cswhjiang
cswhjiang / equi.py
Last active August 29, 2015 02:49 — forked from ynd/equi.py
import numpy
import theano
from theano import tensor as T
from theano.sandbox import rng_mrg
class EquiSGD(object):
"""Equilibrated SGD (eSGD).
Parameters
function test_nag()
r = randn(2,2);
a00 = 1;
a11 = 40;
A = [a00 0;
0, a11];
% A = A + r*r';
b = [0; 0];