samedi 24 septembre 2016

Theano - Shared variable to record randomly generated value

I don't understand how to use shared variable to record a randomly generated value.

I am doing the following operation:

import theano 
import theano.tensor as T 
from theano import function
from theano.tensor.shared_randomstreams import RandomStreams

srng = RandomStreams(seed=22)
a = srng.uniform((10,1))
b = srng.uniform((10,1))
sum = a + b
f = function([], sum)

Now I want to use a shared variable to record the the randomly generated value of a, and another shared variable to record the randomly generated value of b.

I tried using get_value but I get the error "'TensorVariable' object has no attribute 'get_value'". I also tried initializing the shared variable with the value of the randomly generated variable, but I get the error "Shared variable constructor needs numeric values and not symbolic variables."

Sorry I am new to theano and am getting stuck on basics. Please help me. Thanks!




Aucun commentaire:

Enregistrer un commentaire