Skip to content

Instantly share code, notes, and snippets.

View kastnerkyle's full-sized avatar

Kyle Kastner kastnerkyle

View GitHub Profile
@kastnerkyle
kastnerkyle / tanh_rnn.py
Last active May 17, 2024 08:44
Basic tanh rnn in Theano
# Author: Kyle Kastner
# License: BSD 3-clause
# THEANO_FLAGS="optimizer=None,compute_test_value=raise" python tanh_rnn.py
import numpy as np
import theano
import theano.tensor as T
from scipy import linalg
class sgd(object):
@kastnerkyle
kastnerkyle / sed_commands.sh
Last active August 29, 2015 14:22
Sed commands
# skip hidden files and sed replace
find . -not -path '*/\.*' -type f -exec sed -i -e 's|from pelican|from ../lib/pelican|' {} +
# replace in every file recursive
find . -type f -exec sed -i -e 's/foo/bar/g' {} +
# replace in all files in current dir
sed -i -- 's/foo/bar/g' *
# tmp_wav.txt is raw text from dropbox downloads list - pull out wav files, making sure to strip leading whitespace
@kastnerkyle
kastnerkyle / numpy_tricks.py
Created June 24, 2015 17:18
Stupid numpy tricks
import numpy as np
# Broadcast tricks to repeat a matrix
a = np.arange(100 * 10).reshape((100, 10))
# Number of times to clone each entry
clone_count = 2
# axis 0 clone
b = np.ones((1, clone_count, a.shape[1]))
c = (a[:, None, :] * b).reshape((-1, a.shape[-1]))
# axis 1 clone
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@kastnerkyle
kastnerkyle / Optimizer.py
Last active September 17, 2015 10:08 — forked from jiahao/Optimizer.py
Pure Python implementation of some numerical optimizers
#!/usr/bin/env python
'''
Pure Python implementation of some numerical optimizers
Created on Jan 21, 2011
@author Jiahao Chen
'''
@kastnerkyle
kastnerkyle / minibatch_ocr.py
Last active September 9, 2022 11:34
Minibatch OCR using modified CTC from Shawn Tan and Mohammad Pezeshki
"""
bitmap utils and much of the ctc code modified
From Shawn Tan, Rakesh and Mohammad Pezeshki
"""
# Author: Kyle Kastner
# License: BSD 3-clause
from theano import tensor
from scipy import linalg
import theano
import numpy as np
@kastnerkyle
kastnerkyle / csvd.py
Last active December 21, 2015 20:20
Complex valued SVD tests - DEPRECATED! See audio_tools.py
from scipy.linalg import svd
from scipy.io import wavfile
import matplotlib.pyplot as plt
import numpy as np
from numpy.lib.stride_tricks import as_strided
import theano
import os
try:
import urllib.request as urllib # for backwards compatibility
except ImportError:
@kastnerkyle
kastnerkyle / gp.py
Created November 7, 2015 01:44
Minimal experiments in fast gaussian processes
import numpy as np
import matplotlib.pyplot as plt
from scipy import linalg
from sklearn.externals import joblib
mem = joblib.Memory(cachedir='.')
def plot_gp_confidence(gp, show_gp_points=True, X_low=-1, X_high=1,
X_count=1000, xlim=None, ylim=None, show=False):
@kastnerkyle
kastnerkyle / tf_multi_rnn.py
Last active March 21, 2018 08:09
Stack LSTMs in TensorFlow
# Stacked LSTMs
# Author: Kyle Kastner
# Based on script from /u/siblbombs
# License: BSD 3-Clause
import tensorflow as tf
from tensorflow.models.rnn import rnn
from tensorflow.models.rnn.rnn_cell import LSTMCell
import numpy as np
import time
# Author: Kyle Kastner
# License: BSD 3-clause
# Based on example blog from
# http://kawahara.ca/matlab-jaccard-similarity-coefficient-between-images/
import numpy as np
import matplotlib.pyplot as plt
def _check_01(arr):
"""