|
Hi all, I'm a new user to Theano. In the logistic regression example, I don't quite understand the following code -- self.p_y_given_x = T.nnet.softmax(T.dot(input, self.W) + self.b) input -- m * n_in matrix self.W -- n_in * n_out matrix self.b -- n_out * 1 vector where, m is the number of training examples, n_in is the number of features, n_out is the number of classes. In my understanding, T.dot(input, self.W) yields a m * n_out matrix. How can it be added with a n_out * 1 vector? |
|
Theano does 'broadcasting', have a look at this for an explanation of how it works: http://deeplearning.net/software/theano/library/tensor/basic.html#broadcasting-in-theano-vs-numpy I know that Theano does broadcasting, but it seems to me that two matrices must have at least one same dimension for them to be broadcastable. Isn't that right? For example, how do you broadcast and add a 3 * 2 matrix and a 2 * 1 vector? Thanks.
(Mar 27 '14 at 11:34)
yuchenz
1
Quoting from that page, "If the second argument were a vector, its shape would be (2,) and its broadcastable pattern (F,). They would be automatically expanded to the left to match the dimensions of the matrix (adding 1 to the shape and T to the pattern), resulting in (1, 2) and (T, F). It would then behave just like the example above."
(Mar 27 '14 at 11:52)
Sander Dieleman
I still don't quite understand, but I think I'll learn more about broadcasting before I ask more questions. Thank you so much!
(Mar 27 '14 at 20:33)
yuchenz
|