Skip to content

Instantly share code, notes, and snippets.

View kastnerkyle's full-sized avatar

Kyle Kastner kastnerkyle

View GitHub Profile
@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.
@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.
@kastnerkyle
kastnerkyle / HyperLSTMCell.py
Created March 31, 2018 13:11 — forked from tam17aki/HyperLSTMCell.py
An implementation of hyper LSTM.
# -*- coding: utf-8 -*-
# Copyright (C) 2017 by Akira TAMAMORI
# Copyright (C) 2016 by hardmaru
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
@kastnerkyle
kastnerkyle / QLearner.py
Created February 21, 2018 16:49 — forked from shashir/QLearner.py
QLearner
import numpy as np
import random as rand
import datetime
class QLearner(object):
def __init__(self, \
num_states=100, \
num_actions = 4, \
alpha = 0.2, \
gamma = 0.9, \
@kastnerkyle
kastnerkyle / parity_random.py
Created February 17, 2018 17:41 — forked from flukeskywalker/parity_random.py
Random search for parity problem using one LSTM unit
# See: Hochreiter, S., & Schmidhuber, J. (1996).
# Bridging long time lags by weight guessing and "Long Short-Term Memory".
# Spatiotemporal models in biological and artificial systems, 37, 65-72.
import numpy as np
import torch
from torch import nn
from torch.nn import functional as F
from torch.autograd import Variable
import sys
@kastnerkyle
kastnerkyle / AliasSampling.ipynb
Created January 21, 2018 18:05 — forked from jph00/AliasSampling.ipynb
Fast weighted sampling using the alias method in numba
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@kastnerkyle
kastnerkyle / gumbel-st.py
Created January 19, 2018 20:40 — forked from around1991/gumbel-st.py
Simple Gumbel-softmax test code
import tensorflow as tf
def gumbel_ST(logits, temp=1.0, hard=False):
eps = 1e-8
gumbel_noise = -tf.log(-tf.log(tf.random_uniform(tf.shape(logits)) + eps)
+ eps)
y = tf.nn.softmax((logits + gumbel_noise) / temp)
if hard:
@kastnerkyle
kastnerkyle / projection_simplex.py
Created January 5, 2018 00:23 — forked from mblondel/projection_simplex_vectorized.py
Vectorized projection onto the simplex
# Author: Mathieu Blondel
# License: BSD 3 clause
import numpy as np
def projection_simplex(V, z=1, axis=None):
"""
Projection of x onto the simplex, scaled by z:
P(x; z) = argmin_{y >= 0, sum(y) = z} ||y - x||^2
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
def policyIterSP(game):
nnet = initNNet() # initialise random neural network
examples = []
for i in range(numIters):
for e in range(numEps):
examples += executeEpisode(game, nnet) # collect examples from this game
new_nnet = trainNNet(examples)
frac_win = pit(new_nnet, nnet) # compare new net with previous net
if frac_win > threshold:
nnet = new_nnet # replace with new net