Skip to content

Instantly share code, notes, and snippets.

Avatar

Quim Llimona lemonzi

View GitHub Profile
@lemonzi
lemonzi / a3c_test.py
Created Apr 24, 2017
Unit testing the A3C algorithm
View a3c_test.py
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 Mar 13, 2017
TensorFlow implementation of an Advantage Actor-Critic loss
View a3c.py
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 Feb 17, 2017
@add_name_scope() decorator for TensorFlow
View add_name_scope.py
"""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
Sphero-osc setup
View setup.sh
#/bin/bash
git clone https://github.com/lemonzi/sphero-osc
cd sphero-osc
npm install
# This is for running it
node .