Skip to content

Instantly share code, notes, and snippets.

View domluna's full-sized avatar
🐺
howling time

Dominique Luna domluna

🐺
howling time
View GitHub Profile
@domluna
domluna / steps.sh
Created May 27, 2017 01:39 — forked from albertstartup/steps.sh
aws gpu, ubuntu 16.04, nvidia driver 367, cuda 8,
# Required downloads:
# NVIDIA-Linux-x86_64-367.27.run
# cuda_8.0.27_linux.run
# cudnn-8.0-linux-x64-v5.0-ga.tgz
sudo apt-get install build-essential
sudo apt-get install linux-image-extra-`uname -r`
sudo ./NVIDIA-Linux-x86_64-367.27.run
./cuda_8.0.27_linux.run --extract=`pwd`/extracts
sudo ./extracts/cuda-linux64-rel-8.0.27-20733550.run
import tensorflow as tf
import numpy as np
w = np.arange(1, 10, dtype=np.float32).reshape((3,3,1,1))
f = tf.Variable(tf.constant(w))
input = tf.placeholder(tf.float32, (None, 28, 28, 1))
conv = tf.nn.conv2d(input, f, [1,2,2,1], 'SAME')
s = tf.Session()
x = np.zeros((28, 28), dtype=np.float32)
import tensorflow as tf
import numpy as np
w = np.arange(1, 10, dtype=np.float32).reshape((3,3,1,1))
f = tf.Variable(tf.constant(w))
input = tf.placeholder(tf.float32, (None, 28, 28, 1))
conv = tf.nn.conv2d(input, f, [1,2,2,1], 'VALID')
s = tf.Session()
x = np.zeros((28, 28), dtype=np.float32)
@domluna
domluna / pagerank.jl
Created October 12, 2014 18:36
Simple pagerank in Julia
# Simple pagerank implementation
# M - transition matrix
# r - initial rankings
# \beta - the taxation cost, (1-\beta) is the teleport prob
# iter - iterations to run for
function pagerank(M::Matrix{Float64}, r::Vector{Float64}, β::Float64, iter::Int64)
c = (1-β)/length(r)
v_prime = β*M*r + c
for i = 1:iter
v_prime = β*M*v_prime + c
@domluna
domluna / run_cnn.py
Created July 12, 2016 06:38
p5 scripts
"""
This script runs a policy gradient algorithm
"""
from gym.envs import make
from modular_rl import *
import argparse, sys, cPickle
from tabulate import tabulate
import shutil, os, logging
import gym
@domluna
domluna / env.yml
Last active November 10, 2016 01:42
CarND Term 1 environment sample
name: CarND-Term1
channels:
- https://conda.anaconda.org/menpo
dependencies:
- python==3.5.2
- numpy
- matplotlib
- tensorflow
- jupyter
- opencv3
@domluna
domluna / trainable.py
Created November 2, 2016 16:00
Example of making an interface in Python.
# Copyright 2016 The TensorFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
@domluna
domluna / conv_tf.py
Created May 26, 2016 17:42
For reference of using tf.get_variable
def conv2d(inputs, filter, strides, name='conv2d'):
k = tf.get_variable('W', filter, initializer=xavier_initializer_conv2d())
b = tf.get_variable('b', filter[-1], initializer=tf.constant_initializer(0.0))
conv = tf.nn.conv2d(inputs, k, strides, 'SAME')
bias_add = tf.nn.bias_add(conv, b)
return tf.nn.relu(bias_add, name=name)
def vision_model(frames, n_frames):
with tf.variable_scope('Conv1') as scope:
@domluna
domluna / derivs.txt
Created September 27, 2016 05:29
Derivatives for softmax and cross entropy
# derivs
# cross entropy -1/p deriv of -log(p)
# softmax
# p * (1 - p) if i == j if this is the node we picked
# -p * p if i != j otherwise
#
# chain rule for both functions dsoftmax * dcross_entropy
# p * (1 - p) * (-1/p) = p - 1
# -p * p * (-1/p) = p
@domluna
domluna / run_cnn.py
Last active July 12, 2016 19:58
DoomCorridor-v0 writeup
"""
This script runs a policy gradient algorithm
"""
from gym.envs import make
from modular_rl import *
import argparse, sys, cPickle
from tabulate import tabulate
import shutil, os, logging
import gym