Skip to content

Instantly share code, notes, and snippets.

View kastnerkyle's full-sized avatar

Kyle Kastner kastnerkyle

View GitHub Profile
@kastnerkyle
kastnerkyle / cfr_kuhn.py
Last active September 18, 2019 07:25
CFR and follow-on improvements in Python
# Author: Kyle Kastner
# License: BSD 3-Clause
# Drectly lifted from the great blogpost by Justin Sermeno https://justinsermeno.com/posts/cfr/
# References:
# https://int8.io/counterfactual-regret-minimization-for-poker-ai/
# http://cs.gettysburg.edu/~tneller/modelai/2013/cfr/cfr.pdf
# https://github.com/Limegrass/Counterfactual-Regret-Minimization/blob/notes/Learning_to_Play_Poker_using_CounterFactual_Regret_Minimization.pdf
# http://poker.cs.ualberta.ca/publications/Burch_Neil_E_201712_PhD.pdf
# http://mlanctot.info/files/papers/PhD_Thesis_MarcLanctot.pdf
@kastnerkyle
kastnerkyle / dqn_fruit.py
Last active March 5, 2019 05:25
Implementation of DQN, Double DQN, Bootstrap DQN, and Bootstrap DQN with Randomized Prior in PyTorch on a toy environment
# extending on code from
# https://github.com/58402140/Fruit
import os
import numpy as np
import matplotlib
matplotlib.use('TkAgg')
from matplotlib import pyplot as plt
import copy
import time
from collections import Counter
@kastnerkyle
kastnerkyle / kld_gaussians_bound.py
Last active January 5, 2019 14:02
Testing out bounds on KLD between two GMMs
# modifying and extending code from sphinx
# https://github.com/skerit/cmusphinx/blob/master/SphinxTrain/python/cmusphinx/divergence.py#L47
import numpy as np
import itertools
def gau_kl(pm, pv, qm, qv):
"""
Kullback-Liebler divergence from Gaussian pm,pv to Gaussian qm,qv.
Also computes KL divergence from a single Gaussian pm,pv to a set
of Gaussians qm, qv.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@kastnerkyle
kastnerkyle / install-cuda.sh
Created December 9, 2018 08:27 — forked from honnibal/install-cuda.sh
Provision GPU for Ubuntu 18.04
#!/usr/bin/env bash
# First download cudnn to a directory /tmp/binaries.
# The filename should be cudnn-9.2-linux-x64-v7.1.tgz
set -e
# Install driver
sudo add-apt-repository ppa:graphics-drivers/ppa
sudo apt-get update
from z3 import *
# find the (distinct) integers in 0..9 that make this equation work:
#
# SEND
# + MORE
# ------
# MONEY
S = Int('S')
@kastnerkyle
kastnerkyle / memoise.py
Created August 9, 2018 10:14 — forked from dutc/memoise.py
How short & how complete can we write a memoising decorator? I think the below is more complete than most formulations (which don't cache independent of arg-binding.) I think it also cuts straight to the core of what memoisation means. Three obvious deficiencies: [1] What do we do about instance and class methods? These can be meaningfully memoi…
from sys import version_info
assert version_info.major == 3 and version_info.minor >= 3, \
'requires PEP 362; Python 3.3 or later; python.org/dev/peps/pep-0362/'
from inspect import signature
class memoise(dict):
def __init__(self, func):
self.func, self.signature = func, signature(func)
def __missing__(self, key):
args, kwargs = key
from __future__ import print_function
import subprocess
from threading import Thread, Event
# https://stackoverflow.com/questions/1191374/using-module-subprocess-with-timeout
def kill_on_timeout(done, timeout, proc):
if not done.wait(timeout):
proc.kill()
def exec_command(command, shell=False, timeout=None):
@kastnerkyle
kastnerkyle / download_haeckel.sh
Created July 30, 2018 01:59 — forked from genekogan/download_haeckel.sh
script to scrape scanned illustrations from Ernst Haeckel's book Kunstformen der Natur (Artforms of Nature)
for i in {1..100}; do
filepath=$(printf "http://caliban.mpipz.mpg.de/haeckel/kunstformen/Tafel_%03d_300.jpg" $i)
wget $filepath;
done
@kastnerkyle
kastnerkyle / Signal reconstruction from spectrograms.ipynb
Created May 31, 2018 18:17 — forked from carlthome/Signal reconstruction from spectrograms.ipynb
Try to recover audio from filtered magnitudes when phase information has been lost.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.