Skip to content

Instantly share code, notes, and snippets.

@wsjeon
wsjeon / distributed_tensorflow_example.py
Last active May 18, 2017 04:15
Simple counter using distributed TensorFlow in localhost
"""How to run:
python main.py --job_name 'ps' --task_index 0 &
python main.py --job_name 'worker' --task_index 0 &
python main.py --job_name 'worker' --task_index 1
"""
import tensorflow as tf
flags = tf.app.flags
flags.DEFINE_string('job_name', 'ps', 'ps or worker')
flags.DEFINE_integer('task_index', 0, 'task index')
@wsjeon
wsjeon / bnlstm.py
Created February 28, 2017 01:23 — forked from spitis/bnlstm.py
Batch normalized LSTM Cell for Tensorflow
"""adapted from https://github.com/OlavHN/bnlstm to store separate population statistics per state"""
import tensorflow as tf, numpy as np
RNNCell = tf.nn.rnn_cell.RNNCell
class BNLSTMCell(RNNCell):
'''Batch normalized LSTM as described in arxiv.org/abs/1603.09025'''
def __init__(self, num_units, is_training_tensor, max_bn_steps, initial_scale=0.1, activation=tf.tanh, decay=0.95):
"""
* max bn steps is the maximum number of steps for which to store separate population stats
"""