I have the following piece of code:
import theano
import theano.tensor as T
import numpy as np
x = theano.shared(np.asarray([1, 2, 3], dtype=theano.config.floatX), borrow=True)
y = T.cast(x, 'int32')
print 'type of y: ', type(y)
print 'type of y.owner.inputs[0]: ', type(y.owner.inputs[0])
print 'value of y: ', y.owner.inputs[0].get_value(borrow=True)
Run with CPU
$ THEANO_FLAGS=mode=FAST_RUN,device=cpu,floatX=float32 python test_share.py
type of y: <class 'theano.tensor.var.TensorVariable'>
type of y.owner.inputs[0]: <class 'theano.tensor.sharedvar.TensorSharedVariable'>
value of y: [ 1. 2. 3.]
Run with GPU
$ THEANO_FLAGS=mode=FAST_RUN,device=gpu,floatX=float32 python test_share.py
Using gpu device 0: GeForce 310M
type of y: <class 'theano.tensor.var.TensorVariable'>
type of y.owner.inputs[0]: <class 'theano.tensor.var.TensorVariable'>
value of y:
Traceback (most recent call last):
File "test_share.py", line 10, in <module>
print 'value of y: ', y.owner.inputs[0].get_value(borrow=True)
AttributeError: 'TensorVariable' object has no attribute 'get_value'
How can I get the same results as CPU?