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.misc.pycuda_init | |
import theano.sandbox.cuda as cuda | |
from theano.misc.pycuda_utils import to_gpuarray, to_cudandarray | |
from scikits.cuda import fft | |
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 theano | |
import theano.tensor as T | |
from theano.tensor.opt import register_canonicalize | |
class ConsiderConstant(theano.compile.ViewOp): | |
def grad(self, args, g_outs): | |
return [T.zeros_like(g_out) for g_out in g_outs] | |
consider_constant = ConsiderConstant() | |
register_canonicalize(theano.gof.OpRemove(consider_constant), name='remove_consider_constant') |
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 time | |
import multiprocessing as mp | |
def buffered_gen_mp(source_gen, buffer_size=2, sleep_time=1): | |
""" | |
Generator that runs a slow source generator in a separate process. | |
buffer_size: the maximal number of items to pre-generate (length of the buffer) | |
""" | |
buffer = mp.Queue(maxsize=buffer_size) |
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 threading | |
import Queue | |
import time | |
def buffered_gen(source_gen, buffer_size=2, sleep_time=1): | |
""" | |
Generator that runs a slow source generator in a separate thread. | |
buffer_size: the maximal number of items to pre-generate (length of the buffer) | |
""" | |
buffer = Queue.Queue(maxsize=buffer_size) |
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 | |
def freq2mel(freq): | |
return 1127.01048 * np.log(1 + freq / 700.0) | |
def mel2freq(mel): | |
return (np.exp(mel / 1127.01048) - 1) * 700 | |
def mel_binning_matrix(specgram_window_size, sample_frequency, num_mel_bands): |
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
[ 96%] Building NVCC (Device) object extra/cuda/lib/THC/CMakeFiles/THC.dir//./THC_generated_THC.cu.o | |
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/ext/atomicity.h(48): error: identifier "__atomic_fetch_add" is undefined | |
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/ext/atomicity.h(52): error: identifier "__atomic_fetch_add" is undefined | |
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/limits(1405): error: identifier "__int128" is undefined | |
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/limits(1409): error: identifier "__int128" is undefined | |
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/limits(1412): error: identifier "__int128" is undefined |
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
s = set() | |
with open("kaggle_visible_evaluation_triplets.txt", 'r') as f: | |
for line in f: | |
user, _, _ = line.strip().split('\t') | |
s.add(user) | |
print "%d users" % len(s) |
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 theano | |
import theano.tensor as T | |
import numpy as np | |
def local_feature_extractor(x, W, b, shape_info=None): | |
xr = x.dimshuffle(0, 2, 'x', 1) # in: (num_examples, num_input_features, 1, num_timesteps) | |
Wr = W.dimshuffle(0, 1, 'x', 2) # filters: (num_output_features, num_input_features, 1, width) | |
# the output of the convolution should be equal in length to the input | |
len_left = (Wr.shape[3] - 1) / 2 |
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
Error freeing device pointer 0x200800000 (the launch timed out and was terminated). | |
!!!! error freeing device memory 0x200800000 (self=0xa64f270) | |
Error freeing device pointer 0x200302400 (the launch timed out and was terminated). | |
!!!! error freeing dev_structure memory 0x200302400 (self=0xa64f270) | |
--------------------------------------------------------------------------- | |
MemoryError Traceback (most recent call last) | |
/usr/lib/python2.7/site-packages/IPython/utils/py3compat.pyc in execfile(fname, *where) | |
173 else: | |
174 filename = fname | |
--> 175 __builtin__.execfile(filename, *where) |
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 theano | |
import theano.tensor as T | |
def one_hot(t, r=None): | |
""" | |
given a tensor t of dimension d with integer values from range(r), return a | |
new tensor of dimension d + 1 with values 0/1, where the last dimension | |
gives a one-hot representation of the values in t. | |