Skip to content

Instantly share code, notes, and snippets.

class GistTest
def test
puts "testing..."
4.times { |i| puts i }
end
end
@benanne
benanne / tmp_texp_mean_test.py
Created December 17, 2011 23:11
mean of truncated exponential in theano
import numpy as np
import theano
import theano.tensor as T
# mode = theano.compile.DebugMode(check_py_code=False, require_matching_strides=False)
mode = None
# theano.config.floatX = 'float64'
l = T.vector('l')
@benanne
benanne / gist:1751504
Created February 6, 2012 11:07
theano gradient function optimization errors
ERROR (theano.gof.opt): Optimization failure due to: local_gpu_elemwise_0
ERROR (theano.gof.opt): TRACEBACK:
ERROR (theano.gof.opt): Traceback (most recent call last):
File "/home/sander/python_modules/theano/gof/opt.py", line 928, in process_node
replacements = lopt.transform(node)
File "/home/sander/python_modules/theano/sandbox/cuda/opt.py", line 170, in local_gpu_elemwise_0
upcasted = node.op.make_node(*[tensor.cast(i, 'float32') for i in node.inputs])
File "/home/sander/python_modules/theano/tensor/elemwise.py", line 470, in make_node
shadow = self.scalar_op.make_node(*[Scalar(dtype=i.type.dtype)() for i in inputs])
File "/home/sander/python_modules/theano/scalar/basic.py", line 695, in make_node
@benanne
benanne / gist:1759022
Created February 7, 2012 10:30
Theano AdvancedSubtensor memory leak
import theano.tensor as T
import theano
import numpy as np
import gc
def freemem():
gc.collect()
gc.collect()
gc.collect()
return theano.sandbox.cuda.cuda_ndarray.cuda_ndarray.mem_info()[0] / 1024**2
@benanne
benanne / gist:2025317
Created March 12, 2012 23:14
lngamma in theano
import numpy as np
import theano
import theano.tensor as T
def log_gamma_lanczos(z):
# reflection formula. Normally only used for negative arguments,
# but here it's also used for 0 < z < 0.5 to improve accuracy in this region.
flip_z = 1 - z
# because both paths are always executed (reflected and non-reflected),
# the reflection formula causes trouble when the input argument is larger than one.
@benanne
benanne / gist:2025406
Created March 12, 2012 23:30
lngamma in theano, windschitl
import numpy as np
import theano
import theano.tensor as T
def log_gamma_windschitl(z):
return 0.5 * (T.log(2*np.pi) - T.log(z) + z * (2 * T.log(z) - 2 + T.log(z * T.sinh(1/z) + 1 / (810*(z**6)))))
@benanne
benanne / gist:2117212
Created March 19, 2012 15:58
3d conv on GPU error
Error freeing device pointer 0x200605000 (unspecified launch failure).
!!!! error freeing device memory 0x200605000 (self=0x135d2f30)
Error freeing device pointer 0x20030a000 (unspecified launch failure).
!!!! error freeing dev_structure memory 0x20030a000 (self=0x135d2f30)
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
/usr/lib/python2.7/site-packages/IPython/utils/py3compat.py in execfile(fname, *where)
173 else:
174 filename = fname
--> 175 __builtin__.execfile(filename, *where)
@benanne
benanne / gist:2127099
Created March 19, 2012 21:04
theano reshape cuda error
Error freeing device pointer 0x200605000 (unspecified launch failure).
!!!! error freeing device memory 0x200605000 (self=0x132d9630)
Error freeing device pointer 0x20030a000 (unspecified launch failure).
!!!! error freeing dev_structure memory 0x20030a000 (self=0x132d9630)
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
/usr/lib/python2.7/site-packages/IPython/utils/py3compat.py in execfile(fname, *where)
173 else:
174 filename = fname
--> 175 __builtin__.execfile(filename, *where)
@benanne
benanne / gist:2300591
Created April 4, 2012 11:52
one hot + maximum mask in theano
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.
@benanne
benanne / gist:2333153
Created April 8, 2012 00:37
theano GPU convolution error
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)