Skip to content

Instantly share code, notes, and snippets.

View bayerj's full-sized avatar

Justin Bayer bayerj

View GitHub Profile
@bayerj
bayerj / gist:1012438
Created June 7, 2011 15:06
breaking example for theano shape expression
import theano
import theano.tensor as T
X = T.matrix()
expr = X.shape[0]
f = theano.function([X], expr)
print f([[1, 2], [2, 3]])
floatX (('float64', 'float32'))
Doc: Default floating-point precision for python casts
Value: float64
device (('cpu', 'gpu', 'gpu0', 'gpu1', 'gpu2', 'gpu3', 'gpu4', 'gpu5', 'gpu6', 'gpu7', 'gpu8', 'gpu9', 'gpu10', 'gpu11', 'gpu12', 'gpu13', 'gpu14', 'gpu15'))
Doc: Default device for computations. If gpu*, change the default to try to move computation to it and to put shared variable of float32 on it.
Value: cpu
init_gpu_device (('', 'gpu', 'gpu0', 'gpu1', 'gpu2', 'gpu3', 'gpu4', 'gpu5', 'gpu6', 'gpu7', 'gpu8', 'gpu9', 'gpu10', 'gpu11', 'gpu12', 'gpu13', 'gpu14', 'gpu15'))
Doc: Initialize the gpu device to use, works only if device=cpu. Unlike 'device', setting this option will NOT move computations, nor shared variables, to the specified GPU. It can be used to run GPU-specific tests on a particular GPU.
@bayerj
bayerj / error
Created June 10, 2011 13:51
Theano scan over tensor.
Failed to infer_shape from Op Subtensor{1:9223372036854775807:}.
Input shapes:[(Elemwise{add,no_inplace}.0, Subtensor{1}.0)]
Exception encountered during infer_shape: <type 'exceptions.AssertionError'>
Exception message:
Traceback: Traceback (most recent call last):
File "/Users/bayerj/devel/third-party/Theano/theano/tensor/opt.py", line 721, in on_import
o_shapes = shape_infer(node, [self.shape_of[r] for r in node.inputs])
File "/Users/bayerj/devel/third-party/Theano/theano/tensor/basic.py", line 2863, in infer_shape
assert len(xshp) == node.inputs[0].ndim
AssertionError
@bayerj
bayerj / gist:1125740
Created August 4, 2011 17:46
Linear regression in python.
import scipy
import theano
import theano.tensor as T
# Define variables.
W = T.matrix('weights')
x = T.matrix('features')
z = T.matrix('targets')
# Define model. (Yes, no bias, I am lazy)
@bayerj
bayerj / build.sh
Created September 30, 2011 15:43 — forked from reklis/build.sh
Archive post-action
asdasd#in older versions of Xcode4 you may need to set PRODUCT_NAME manually
DIST_LIST=<TestFlight Distribution List name here>
API_TOKEN=<TestFlight API token here>
TEAM_TOKEN=<TestFlight team token here>
SIGNING_IDENTITY="iPhone Distribution: Development Seed"
PROVISIONING_PROFILE="${HOME}/Library/MobileDevice/Provisioning Profiles/MapBox Ad Hoc.mobileprovision"
LOG="/tmp/testflight.log"
DATE=$( /bin/date +"%Y-%m-%d" )
diff --git a/theano/tensor/basic.py b/theano/tensor/basic.py
index f9e7240..091486b 100644
--- a/theano/tensor/basic.py
+++ b/theano/tensor/basic.py
@@ -5091,6 +5091,7 @@ class AdvancedSubtensor(Op):
rest = inputs[1:]
return [AdvancedIncSubtensor(self.args)(zeros_like(x), gz, *rest)] + [None]*len(rest)
+
class AdvancedIncSubtensor(Op):
$ py -c 'import zmq'
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/Library/Python/2.6/site-packages/zmq/__init__.py", line 38, in <module>
from zmq import core, devices
File "/Library/Python/2.6/site-packages/zmq/core/__init__.py", line 26, in <module>
from zmq.core import (constants, error, message, context,
ImportError: dlopen(/Library/Python/2.6/site-packages/zmq/core/error.so, 2): Symbol not found: _zmq_errno
Referenced from: /Library/Python/2.6/site-packages/zmq/core/error.so
Expected in: flat namespace
import scipy
import theano, theano.tensor as T
# Create parameters.
#
# Parameters are first allocated in a long consecutive array as a shared
# variable. Afterwards, reshaped subtensors are used in the expressions in.
# Why? We want to be able to differentiate wrt groups of parameters which
# are in consecutive memory.
import scipy
import theano, theano.tensor as T
# Create parameters.
#
# Parameters are first allocated in a long consecutive array as a shared
# variable. Afterwards, reshaped subtensors are used in the expressions in.
# Why? We want to be able to differentiate wrt groups of parameters which
# are in consecutive memory.
@bayerj
bayerj / code
Created January 11, 2012 06:38
Theano differentiation through scan
import theano, theano.tensor as T
inpt = T.vector('inpt')
W = T.matrix('weights')
output = T.dot(inpt, W)
d_output_wrt_inpt, _ = theano.map(lambda i: T.grad(output[i], inpt),
T.arange(output.shape[0]))
f = theano.function([inpt, W], d_output_wrt_inpt)