You can do it in a few different ways:

* b = a.reshape(a.shape[0],1)
* b = a.dimshuffle(0, 'x')

I recommand the last one as depending of the graph around, the
dimshuffle could be optimized away.

Fred


On Mon, Oct 24, 2016 at 3:55 AM, <linzhesha...@gmail.com> wrote:

> Assume that i have two vectors a and b, and i would like to add these two to 
> get a matrix. In numpy i can do it in this way.
>
> import numpy as np
> a = np.array([0,1,2])
> b = a.reshape(3,1)
> a+b
>
> In theano i can do it like
>
> a = numpy.array([[0,1,2]])
> b = numpy.array([[0],[1],[2]])##b = a.reshape(a.shape[1],a.shape[0])
> a1=theano.shared(numpy.asarray(a), broadcastable =(True,False), borrow =True)
> b1 = theano.shared(numpy.asarray(b),broadcastable=(False, True),borrow = True)
>
> alpha_matrix = T.add(a1, b1)
> alpha_matrix_compute = theano.function([], alpha_matrix)for i in range(10000):
>     c = alpha_matrix_compute()
>
> But the problem is that, a and b are not given and they are calculated during 
> the program running. So they cannot be defined as shared values.
> So, symbolic value must be used. How to calculate it with symbolic value?
>
> --
>
> ---
> 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 theano-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 

--- 
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 theano-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to