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
import numpy as np | |
def exponential_kernel(x1, x2): | |
# Broadcasting tricks to get every pairwise distance. | |
return np.exp(-((x1[np.newaxis, :, :] - x2[:, np.newaxis, :]) ** 2).sum(2)).T | |
a = np.random.randn(100, 5) | |
print(exponential_kernel(a, a).shape) |
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
import theano.tensor as T | |
import theano | |
a = T.vector() | |
b = T.matrix() | |
fa = a ** 2 | |
f = theano.function([a], fa) | |
f2 = theano.function([b], theano.clone(fa, replace={a: b}, strict=False)) | |
print(f([2])) | |
print(f2([[2]])) |
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
# License: GPL | |
# Based on scikit-tensor by mnick | |
# https://github.com/mnick/scikit-tensor | |
"""Tensor factorization.""" | |
import numpy as np | |
from scipy import linalg | |
def _matricize(X, axis): |
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
# License: BSD 3-clause | |
# Authors: Kyle Kastner, | |
# Pierre Luc Carrier | |
import numpy as np | |
from numpy.lib.stride_tricks import as_strided | |
import scipy.signal as sg | |
from scipy import linalg, fftpack | |
from numpy.testing import assert_almost_equal |
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
import numpy as np | |
from numpy.testing import assert_almost_equal | |
A = np.arange(200).reshape(40, 5).astype('float32') | |
B = np.arange(100).reshape(20, 5) + 10. | |
C = np.vstack((A, B)) | |
mA = np.mean(A, axis=0) | |
mB = np.mean(B, axis=0) | |
mC = np.mean(C, axis=0) |
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
""" | |
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 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
import numpy as np | |
import matplotlib.pyplot as plt | |
control = np.zeros(10000) | |
control[:2000] = -50 | |
control[5000:7000] = 50. | |
control[7000:] = -50 | |
def frequency_modulation(modulation_signal, carrier_freq=100., |
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
# Alec Radford, Indico, Kyle Kastner | |
# License: MIT | |
""" | |
Convolutional VAE in a single file. | |
Bringing in code from IndicoDataSolutions and Alec Radford (NewMu) | |
Additionally converted to use default conv2d interface instead of explicit cuDNN | |
""" | |
import theano | |
import theano.tensor as T | |
from theano.compat.python2x import OrderedDict |
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
# Alec Radford, Indico, Kyle Kastner | |
# License: MIT | |
""" | |
VAE in a single file. | |
Bringing in code from IndicoDataSolutions and Alec Radford (NewMu) | |
""" | |
import theano | |
import theano.tensor as T | |
from theano.compat.python2x import OrderedDict | |
from theano.sandbox.rng_mrg import MRG_RandomStreams as RandomStreams |
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
# Original code from tinrtgu on Kaggle under WTFPL license | |
# Relicensed to BSD 3-clause (it does say do what you want...) | |
# Authors: Kyle Kastner | |
# License: BSD 3-clause | |
# Reference links: | |
# Adaptive learning: http://static.googleusercontent.com/media/research.google.com/en//pubs/archive/41159.pdf | |
# Criteo scalable response prediction: http://people.csail.mit.edu/romer/papers/TISTRespPredAds.pdf | |
# Vowpal Wabbit (hashing trick): https://github.com/JohnLangford/vowpal_wabbit/ | |
# Hashing Trick: http://arxiv.org/pdf/0902.2206.pdf |