This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from z3 import * | |
# find the (distinct) integers in 0..9 that make this equation work: | |
# | |
# SEND | |
# + MORE | |
# ------ | |
# MONEY | |
S = Int('S') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for i in {1..100}; do | |
filepath=$(printf "http://caliban.mpipz.mpg.de/haeckel/kunstformen/Tafel_%03d_300.jpg" $i) | |
wget $filepath; | |
done |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.