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 / 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 / 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
@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 / .flowconfig
Created June 26, 2016 17:47
Sample flowconfig from Ian Sinnott
[ignore]
.*/node_modules/fbjs/.*
[include]
[libs]
[options]
module.name_mapper.extension='css' -> '<PROJECT_ROOT>/flow/CSSModule.js.flow'
module.name_mapper.extension='styl' -> '<PROJECT_ROOT>/flow/CSSModule.js.flow'
@domluna
domluna / gist:efe1f842239661e490384c9fb4f588fc
Created June 25, 2016 15:32
Gym monitor multiple envs error
[2016-06-25 11:30:22,674] Creating monitor directory /tmp/tmp_EkGLw/monitor
[2016-06-25 11:30:22,924] Starting new video recorder writing to /tmp/tmp_EkGLw/monitor/openaigym.video.0.22978.video000000.mp4
[2016-06-25 11:30:22,932] Starting new video recorder writing to /tmp/tmp_EkGLw/monitor/openaigym.video.1.22978.video000000.mp4
[2016-06-25 11:30:22,934] Starting new video recorder writing to /tmp/tmp_EkGLw/monitor/openaigym.video.2.22978.video000000.mp4
[2016-06-25 11:30:22,940] Starting new video recorder writing to /tmp/tmp_EkGLw/monitor/openaigym.video.3.22978.video000000.mp4
[xcb] Unknown request in queue while dequeuing
[xcb] Most likely this is a multi-threaded client and XInitThreads has not been called
[xcb] Aborting, sorry about that.
python: ../../src/xcb_io.c:179: dequeue_pending_request: Assertion `!xcb_xlib_unknown_req_in_deq' failed.
[1] 22978 abort (core dumped) python examples/run_a3c.py --name Acrobot-v0 --learning_rate 0.05 4
@domluna
domluna / rgb2gray_resize.py
Last active June 13, 2016 17:00
example of rgb2gray + resizing images
from __future__ import absolute_import
from __future__ import print_function
from __future__ import absolute_import
import warnings
from skimage.color import rgb2gray
from skimage.transform import resize
from skimage import img_as_ubyte
@domluna
domluna / CMakeError.log
Created June 11, 2016 16:21
vizdoom install errors
Determining if the pthread_create exist failed with the following output:
Change Dir: /home/dom/src/ViZDoom/CMakeFiles/CMakeTmp
Run Build Command:"/usr/bin/make" "cmTC_0b041/fast"
/usr/bin/make -f CMakeFiles/cmTC_0b041.dir/build.make CMakeFiles/cmTC_0b041.dir/build
make[1]: Entering directory '/home/dom/src/ViZDoom/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_0b041.dir/CheckSymbolExists.c.o
/usr/bin/cc -o CMakeFiles/cmTC_0b041.dir/CheckSymbolExists.c.o -c /home/dom/src/ViZDoom/CMakeFiles/CMakeTmp/CheckSymbolExists.c
Linking C executable cmTC_0b041
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_0b041.dir/link.txt --verbose=1
@domluna
domluna / foo.py
Last active April 12, 2018 23:37
Print the size in bytes of a Tensorflow GraphDef
import tensorflow as tf
def main():
files = ['model-' + str(x) for x in range(20000, 70000, 10000)]
for f in files:
with tf.Graph().as_default():
sess = tf.Session()
saver = tf.train.import_meta_graph('./test_graph_size/' + f + '.meta')
saver.restore(sess, './test_graph_size/' + f)
print(sess.graph_def.ByteSize())
@domluna
domluna / foo.py
Created June 2, 2016 05:57
Tensorflow grayscale + resizing. Session + feed dict is for having a static op.
def rgb2y_resize(input_shape, new_height, new_width, session):
img = tf.placeholder(tf.float32, shape=input_shape)
reshaped = tf.reshape(img, [1] + list(input_shape))
rgb2y = tf.image.rgb_to_grayscale(reshaped)
bilinear = tf.image.resize_bilinear(rgb2y, [new_height, new_width])
squeezed = tf.squeeze(bilinear)
return lambda x: session.run(squeezed, feed_dict={img: x})