Created
June 10, 2011 13:51
-
-
Save bayerj/1018859 to your computer and use it in GitHub Desktop.
Theano scan over tensor.
This file contains hidden or 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
| 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 | |
| Failed to infer_shape from Op Subtensor{int64:int64:int8}. | |
| Input shapes:[(Elemwise{add,no_inplace}.0, Subtensor{1}.0), None, None, None] | |
| 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 | |
| Traceback (most recent call last): | |
| File "test.py", line 26, in <module> | |
| print f(X) | |
| File "/Users/bayerj/devel/third-party/Theano/theano/compile/function_module.py", line 596, in __call__ | |
| self.fn() | |
| File "/Users/bayerj/devel/third-party/Theano/theano/gof/link.py", line 288, in streamline_default_f | |
| raise_with_op(node) | |
| File "/Users/bayerj/devel/third-party/Theano/theano/gof/link.py", line 284, in streamline_default_f | |
| thunk() | |
| File "/Users/bayerj/devel/third-party/Theano/theano/gof/cc.py", line 1217, in thunk | |
| return p(n, [x[0] for x in i], o) | |
| File "/Users/bayerj/devel/third-party/Theano/theano/scan_module/scan_op.py", line 530, in perform | |
| outs[j][0][pos[j]] = output_storage[offset_out+j].storage[0] | |
| ValueError: ('output operand requires a reduction, but reduction is not enabled', scan_fn{inplace,cpu}(Elemwise{Composite{sub,minimum}}[(0, 2)].0, tensordot.0, InplaceSetIncSubtensor{:int64:}.0), 'Sequence id of Apply node=22') |
This file contains hidden or 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 scipy | |
| import theano | |
| import theano.tensor as T | |
| insize = 2 | |
| hiddensize = 3 | |
| outsize = 2 | |
| inweights = T.shared(scipy.empty((2, 3))) | |
| hidden0 = T.shared(scipy.empty(3)) | |
| inpts = T.tensor3('input-sequences') | |
| hidden = T.tensordot(inpts, inweights, axes=([2], [0])) | |
| hidden_rec, _ = theano.scan( | |
| lambda x, h_tm1: x + 1, | |
| sequences=hidden, | |
| outputs_info=[hidden0]) | |
| f = theano.function([inpts], hidden_rec) | |
| X = scipy.array([ | |
| [[2, 3], [1, 2], [-1, 1]], | |
| [[1, 0], [0, 1], [1, 2]], | |
| ]) | |
| print f(X) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment