Skip to content

Instantly share code, notes, and snippets.

View bayerj's full-sized avatar

Justin Bayer bayerj

View GitHub Profile
[... 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
@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]):
/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,
.../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)),),
import theano
import theano.tensor as T
import gnumpy
import theano.misc.gnumpy_utils as gput
g = gnumpy.zeros((1, 2))
g += np.array([[2, 1]])
x = T.matrix()
expr = 2 * x
@bayerj
bayerj / quaternions.py
Created July 17, 2013 07:15
Some quaternion code for numpy/Theano.
def q_mult(q1, q2):
w1, x1, y1, z1 = q1[:, 0], q1[:, 1], q1[:, 2], q1[:, 3]
w2, x2, y2, z2 = q2[:, 0], q2[:, 1], q2[:, 2], q2[:, 3]
w = w1 * w2 - x1 * x2 - y1 * y2 - z1 * z2
x = w1 * x2 + x1 * w2 + y1 * z2 - z1 * y2
y = w1 * y2 + y1 * w2 + z1 * x2 - x1 * z2
z = w1 * z2 + z1 * w2 + x1 * y2 - y1 * x2
if isinstance(q1, np.ndarray):
w = w[:, np.newaxis]
@bayerj
bayerj / error
Last active December 20, 2015 03:48
Traceback (most recent call last):
File "theanorngclone.py", line 12, in <module>
f = theano.function([x_sub], samples_sub)
File "/Users/bayerj/devel/Theano/theano/compile/function.py", line 222, in function
profile=profile)
File "/Users/bayerj/devel/Theano/theano/compile/pfunc.py", line 506, in pfunc
on_unused_input=on_unused_input)
File "/Users/bayerj/devel/Theano/theano/compile/function_module.py", line 1298, in orig_function
on_unused_input=on_unused_input).create(
File "/Users/bayerj/devel/Theano/theano/compile/function_module.py", line 994, in __init__
numpydoc>=0.4
dot = (target[:, :, 3:7] * prediction[:, :, 6:10]).sum(axis=2).dimshuffle(0, 1, 'x')
dot = T.clip(dot, -.99, .99)
angle_loss = T.arccos(dot)
return residuals ** 2 + c * angle_loss
@bayerj
bayerj / theanodeter.py
Created August 28, 2013 11:20
Tell whether an expression is deterministic, ie it does not use a random number generator.
import theano, theano.tensor as T
from theano.tensor.shared_randomstreams import RandomStreams
def theano_expr_bfs(expr):
stack = [expr]
while True:
if not stack:
break
expr = stack.pop()