This file contains 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 python | |
# Clone or update all a user's gists | |
# curl -ks https://raw.github.com/gist/5466075/gist-backup.py | USER=fedir python | |
# USER=fedir python gist-backup.py | |
import json | |
import urllib.request, urllib.parse, urllib.error | |
from subprocess import call | |
from urllib.request import urlopen | |
import os |
This file contains 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
import numpy as np | |
import theano | |
import theano.tensor as T | |
import pickle | |
d = pickle.load(open("info.pkl", mode="rb")) | |
X = d["X"] | |
y = d["y"] | |
fit_function2 = d["fit_function"] |
This file contains 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
# 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 |
This file contains 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
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 |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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 python | |
''' | |
Pure Python implementation of some numerical optimizers | |
Created on Jan 21, 2011 | |
@author Jiahao Chen | |
''' |
This file contains 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
""" | |
bitmap utils and much of the ctc code modified from Shawn Tan | |
""" | |
# Author: Kyle Kastner | |
# License: BSD 3-clause | |
from theano import tensor | |
from scipy import linalg | |
import theano | |
import numpy as np | |
import matplotlib.pyplot as plt |
This file contains 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
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): |
This file contains 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
class SPPLayer(lasagne.layers.Layer): | |
def __init__(self, incoming, **kwargs): | |
super(SPPLayer, self).__init__(incoming, **kwargs) | |
# divide by 4 gives 16 patches | |
self.win1 = (int(np.floor(incoming.output_shape[2]/4.0)), int(np.floor(incoming.output_shape[3]/4.0))) | |
self.str1 = (int(np.ceil(incoming.output_shape[2]/4.0)), int(np.ceil(incoming.output_shape[3]/4.0))) | |
# divide by 2 gives 4 patches | |
self.win2 = (int(np.floor(incoming.output_shape[2]/2.0)), int(np.floor(incoming.output_shape[3]/2.0))) |
This file contains 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
def gaussian_density_batch(x, mean, stddev, correlation, compute_derivatives=False): | |
""" | |
Compute the Gaussian density at x for a 2D normal distribution with parameters mean, stddev, correlation. | |
This works simultaneously on a batch of inputs. The inputs should have dimensions: | |
x.shape = (n, 1, 2) | |
mean.shape = stddev.shape = (n, m, 2) | |
correlation.shape = (n, m, 1) | |
where n*m is the number of different Gaussian density functions that we want to evaluate, on n input points x. | |
So the same input x is plugged into the density for m Gaussian pdfs. (This is convenient for evaluating a |