Broadcasting
Broadcasting is the mechanism by which a scalarmay be added to a matrix, a vector to a matrix or a scalar toa vector.
If the second argument were a vector, its shape would be and its broadcastable pattern (False,)
. They wouldbe automatically expanded to the left to match thedimensions of the matrix (adding to the shape and True
to the pattern), resulting in and (True, False)
.It would then behave just like the example above.
Unlike numpy which does broadcasting dynamically, Theano needsto know, for any operation which supports broadcasting, whichdimensions will need to be broadcasted. When applicable, thisinformation is given in the Type of a Variable.
In these examples, we can see that both the row vector and the column vector are broadcasted in order to be be added to the matrix.
See also: