Skip to content

Instantly share code, notes, and snippets.

View bayerj's full-sized avatar

Justin Bayer bayerj

View GitHub Profile
.../Users/bayerj/devel/Theano/theano/compile/debugmode.py:1610: UserWarning: FunctionGraph.nodes is deprecated, it has been renamed 'apply_nodes'
e.toposort = lambda: e.nodes # WARNING: STOCHASTIC ORDER
...........S........................K............../Users/bayerj/devel/Theano/theano/compile/tests/test_inplace_opt_for_value.py:170: UserWarning: theano modules are deprecated and will be removed in release 0.7
super(ExampleRNN, self).__init__()
.............................................................................................WARNING (theano.gof.cmodule): Cache leak due to unpickle-able key data set([(((1,), (10, '1.8.0.dev-dff8c94'), (10, '1.8.0.dev-dff8c94')), ('CLinker.cmodule_key', ('-O3', '-Wno-unused-label', '-Wno-unused-variable', '-Wno-write-strings', '-fno-math-errno'), (), (), 'NPY_ABI_VERSION=0x1000009', 'c_compiler_str=g++ 4.2.1', 'md5:b9113ad2b1dcb7629164b394f0809469', (<theano.gof.tests.test_compute_test_value.IncOneC object at 0x109c0cb10>, ((Scalar(int32), ((-1, 0), False)),),
/Users/bayerj/devel/Theano/theano/compile/function.pyc in function(inputs, outputs, mode, updates, givens, no_default_updates, accept_inplace, name, rebuild_strict, allow_input_downcast, profile, on_unused_input)
204 allow_input_downcast=allow_input_downcast,
205 on_unused_input=on_unused_input,
--> 206 profile=profile)
207 # We need to add the flag check_aliased inputs if we have any mutable or
208 # borrowed used defined inputs
/Users/bayerj/devel/Theano/theano/compile/pfunc.pyc in pfunc(params, outputs, mode, updates, givens, no_default_updates, accept_inplace, name, rebuild_strict, allow_input_downcast, profile, on_unused_input)
480 return orig_function(inputs, cloned_outputs, mode,
481 accept_inplace=accept_inplace, name=name, profile=profile,
@bayerj
bayerj / gist:5280297
Created March 31, 2013 11:08
Window moving average implementation using numba with speed tests.
import time
import numpy as np
from numba import jit, float64, int64
def mean_filter(X, window_size):
filtered = np.empty(X.shape)
starts = window_size * [0] + range(1, X.shape[0] - window_size + 1)
for i in range(X.shape[0]):
[... snipped away lotsof Quadtree inserts ...]
#104785 0x00000001000021ae in QuadTree::insert (this=0x1021d6e00, new_index=553) at quadtree.cpp:154
#104786 0x0000000100002235 in QuadTree::insert (this=0x1021d6a10, new_index=553) at quadtree.cpp:157
#104787 0x00000001000021ae in QuadTree::insert (this=0x1021d6980, new_index=553) at quadtree.cpp:154
#104788 0x0000000100002235 in QuadTree::insert (this=0x1021d6590, new_index=553) at quadtree.cpp:157
#104789 0x00000001000021ae in QuadTree::insert (this=0x1021d63e0, new_index=553) at quadtree.cpp:154
#104790 0x00000001000021dc in QuadTree::insert (this=0x1021d61a0, new_index=553) at quadtree.cpp:155
#104791 0x00000001000021dc in QuadTree::insert (this=0x1021d5ff0, new_index=553) at quadtree.cpp:155
#104792 0x0000000100002207 in QuadTree::insert (this=0x1021d5e40, new_index=553) at quadtree.cpp:156
tmp ❯❯❯ py importtheano.py
Vendor: continuumProduct: anacondapro
Message: trial mode expires in 27 days
WARNING (theano.gof.compilelock): Overriding existing lock by dead process '82054' (I am process '82104')
> /Users/bayerj/devel/Theano/theano/gof/cmodule.py(264)dlimport()
-> try:
(Pdb) s
> /Users/bayerj/devel/Theano/theano/gof/cmodule.py(265)dlimport()
-> print module_name
(Pdb) s
@bayerj
bayerj / gist:4513419
Created January 11, 2013 19:45
This is unexpected behaviour when compiling a moving average function with numba. Not compiling it and using python+numpy works fine.
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-4-f143d352e435> in <module>()
----> 1 filtered = mean_filter(X, 10)
/Users/bayerj/anaconda/lib/python2.7/site-packages/numba/decorators.pyc in __call__(self, *args, **kwargs)
162 raise error.NumbaError("Expected %d arguments, got %d" % (
163 nargs, len(args)))
--> 164 return self.wrapper(self, *args, **kwargs)
165
In [1]: from collections import namedtuple
In [3]: p = namedtuple('p', ['bla'])
In [4]: pp = p(2)
In [5]: pp
Out[5]: p(bla=2)
In [6]: import pickle
In [7]: pickle.dumps(pp)
Out[7]: 'ccopy_reg\n_reconstructor\np0\n(c__main__\np\np1\nc__builtin__\ntuple\np2\n(I2\ntp3\ntp4\nRp5\n.'
@bayerj
bayerj / gist:4131398
Created November 22, 2012 14:19
ipython save image with pillow and display
from IPython.core.display import Image as image
from PIL import Image
def save_and_display(arr, fname):
pilimg = Image.fromarray(arr)
pilimg.save(fname)
return image(filename=fname, width=600)
import theano.tensor as T
x = T.matrix()
c = T.matrix()
s = T.switch(c, x, 0)
l = s.sum()
T.grad(l, x) # Assertion error...
import spearmint
exp = spearmint.Experiment()
exp.add_variable('n_hiddens', min=1, max=100, type=int)
for i in range(100): # Do 100 trials.
id, args = exp.draw() # Get a new candidate; id is used as a handle for later pushing back results into the experiment.
cost = f(args) # Evaluate objective.
exp.push(id, cost) # Push results into the experiment so we get a new candidate based on those results in the next iteration.