Skip to content

Instantly share code, notes, and snippets.

View kastnerkyle's full-sized avatar

Kyle Kastner kastnerkyle

View GitHub Profile
@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.
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.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@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.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
# https://www.12000.org/my_notes/mma_matlab_control/KERNEL/KEse82.htm
# https://faculty.washington.edu/rjl/fdmbook/matlab/poisson.m
# https://wiki.scinet.utoronto.ca/wiki/images/b/be/Rcp8Lecture8.pdf
# http://people.sc.fsu.edu/~jpeterson/notes_fd.pdf
# http://people.bu.edu/andasari/courses/Fall2015/LectureNotes/Lecture14_27Oct2015.pdf
import matplotlib
matplotlib.use("Agg")
import numpy as np
from scipy.misc import imresize
import scipy.sparse as spa