Created
June 11, 2011 01:12
-
-
Save lamblin/1020135 to your computer and use it in GitHub Desktop.
This file contains 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
hidden value: (2, 3, 3) | |
[[[ 2.43871672e-316 4.07723682e-316 3.54132749e-312] | |
[ 1.62581115e-316 2.44505736e-316 2.36086774e-312] | |
[ 8.12905574e-317 -6.42364390e-319 1.18035621e-312]] | |
[[ 0.00000000e+000 8.19301551e-317 5.17748386e-317] | |
[ 8.12905574e-317 8.12877907e-317 1.18040798e-312] | |
[ 1.62581115e-316 2.44505736e-316 2.36086774e-312]]] | |
out value at step 0: (3, 3) | |
[[ 1. 1. 1.] | |
[ 1. 1. 1.] | |
[ 1. 1. 1.]] | |
Traceback (most recent call last): | |
File "test.py", line 36, in <module> | |
outputs_info=[hidden0]) | |
File "/u/lamblinp/code/Theano_work/theano/scan_module/scan.py", line 910, in scan | |
scan_outs = local_op(* scan_inputs ) | |
File "/u/lamblinp/code/Theano_work/theano/gof/op.py", line 389, in __call__ | |
node.op.perform(node, input_vals, output_storage) | |
File "/u/lamblinp/code/Theano_work/theano/scan_module/scan_op.py", line 530, in perform | |
outs[j][0][pos[j]] = output_storage[offset_out+j].storage[0] | |
ValueError: array dimensions are not compatible for copy |
This file contains 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 numpy | |
import theano | |
from theano import tensor as T | |
theano.config.compute_test_value = 'warn' | |
insize = 2 | |
hiddensize = 3 | |
outsize = 2 | |
inweights = T.shared(numpy.empty((2, 3))) | |
hidden0 = T.shared(numpy.empty(3)) | |
X = numpy.array([ | |
[[2, 3], [1, 2], [-1, 1]], | |
[[1, 0], [0, 1], [1, 2]], | |
]) | |
inpts = T.tensor3('input-sequences') | |
inpts.tag.test_value = X | |
hidden = T.tensordot(inpts, inweights, axes=([2], [0])) | |
print 'hidden value:', hidden.tag.test_value.shape | |
print hidden.tag.test_value | |
# The function will be executed once, to build the inner | |
# graph of the scan node. We can use that | |
def fn(x, h_tm1): | |
out = x + 1 | |
print 'out value at step 0:', out.tag.test_value.shape | |
print out.tag.test_value | |
return out | |
hidden_rec, _ = theano.scan( | |
fn, | |
sequences=hidden, | |
outputs_info=[hidden0]) | |
print 'hidden_rec value:', hidden_rec.tag.test_value.shape | |
print hidden_rec.tag.test_value | |
f = theano.function([inpts], hidden_rec) | |
print f(X) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment