Skip to content

Instantly share code, notes, and snippets.

@lemonzi
lemonzi / a3c_test.py
Created April 24, 2017 16:20
Unit testing the A3C algorithm
import tensorflow as tf
from tensorflow.contrib import distributions
# These are your input features, a random tensor.
# There are 128 examples per batch, 1000 time-steps, one observation.
# If your code doesn't use batches, remove the first dimension.
features = tf.random_normal([128, 1000, 1])
# Put your networks here
# policy_mu, policy_sigma = ...
@lemonzi
lemonzi / a3c.py
Created March 13, 2017 22:34
TensorFlow implementation of an Advantage Actor-Critic loss
import numpy as np
import scipy.signal
import tensorflow as tf
import tensorify
@tensorify.tensorflow_op(tf.float32)
def discount(x, gamma=1.0, axis=0):
y = scipy.signal.lfilter([1], [1, -gamma], x[::-1], axis=axis)[::-1]
return y.astype(np.float32)
@lemonzi
lemonzi / add_name_scope.py
Last active February 17, 2017 01:13
@add_name_scope() decorator for TensorFlow
"""Decorators that make TensorFlow programming a bit easier.
Quim Llimona, 2017.
"""
import functools
import tensorflow as tf
def add_name_scope(name=None):
"""Creates a name_scope that contains all ops created by the function.
@lemonzi
lemonzi / setup.sh
Created May 24, 2014 20:43
Sphero-osc setup
#/bin/bash
git clone https://github.com/lemonzi/sphero-osc
cd sphero-osc
npm install
# This is for running it
node .