Hi,

If you want to sample the weights only once, before the training starts,
you need to know in advance what the size of those weights should be.
It does not make sense to have a weight matrix that change size between
iterations, but still keeps the same values.

numpy.random _is_ the way to go.

If you need to compute the size of intermediate symbolic variable
once, when constructing the graph, you can use something like
that_tensor.eval() or that_tensor.eval({input_variable: input_value})
where input_value is a numpy array, for instance the first minibatch
from your dataset.

On Mon, Aug 29, 2016, Yanghoon Kim wrote:
> 
> 
> partial code as follows:( please just pay attention to the context of the 
> code)
> 
> 
> rng = T.shared_randomstreams.RandomStreams()
> 
> 
> class gen_rand(object):
>     def init(self, rng, input):
>         self.input_shape = input.shape 
>         print type(self.input_shape)
>         self.output = rng.uniform(size=self.input_shape, low=0, high=1)
>     def return_output(self):
>         return self.output
> 
> I coded a neural network code with one of the weigh W initialized with 
> T.shared_randomstreams.RandomStreams(), the reason I didn't use 
> numpy.random is that I don't want to feed input.shape everytime, but to 
> compute the shape of input in the code.
> 
> the code works but just because it's random tensor, It can't be used as a 
> Weight in neural network, it changes every time.
> 
> How can I initialize a weight in NN with random module in theano( just want 
> to randomly generate value once at the beginning and not to be updated by 
> itself, i tried 'no_default_updates=True' then it can't be updated through 
> gradient descent!!, I also tried copy modue in python to shallow copy 
> rng.uniform, there was an error. I tried numpy.random, but it requires 
> numerical size of the random value but not tensor)
> 
> -- 
> 
> --- 
> You received this message because you are subscribed to the Google Groups 
> "theano-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.


-- 
Pascal

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"theano-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to