element wise matrix multiply? | Dmitry Lagun | 4/17/13 3:40 PM | Hi, I could not quickly find in the documentation - is there some analog of element wise matrix multiplication implemented in Theano? Thanks, Dmitry |

Re: [theano-users] element wise matrix multiply? | Pascal Lamblin | 4/17/13 3:55 PM | Hi Dmitry,
You can simply use '*': a, b = theano.tensor.matrices('a', 'b') f = theano.function([a, b], a * b) f([[0, 1], [2, 3]], [[3, 1], [0, 2]]) array([[ 0., 1.], [ 0., 6.]]) -- Pascal |

Re: [theano-users] element wise matrix multiply? | Dmitry Lagun | 4/17/13 3:55 PM | Thanks! |

Re: [theano-users] element wise matrix multiply? | Samuel Leeman-Munk | 7/8/15 6:57 AM | Is there a speed penalty for elementwise? I imagine blas is optimized for non-elementwise matrix multiplication (more like dot than *) |

Re: [theano-users] element wise matrix multiply? | Daniel Renshaw | 7/8/15 7:01 AM | Element-wise operations are sped up by OpenMP instead of BLAS. See the documentation on Parallel element wise ops with OpenMP [1]. -- |

Re: [theano-users] element wise matrix multiply? | Pascal Lamblin | 7/8/15 8:40 AM | On Wed, Jul 08, 2015, Samuel Leeman-Munk wrote:Well, dot and * are different operations, and you cannot really use one instead of the other, so I'm not sure what do you mean by "penalty". The dot product of an (m, n) matrix by an (n, p) matrix is O(m*n*p) in theory, and the elemwise product of two (m, n) matrices is O(m*n), so even if blas optimizes dot, the elemwise product should still be faster. Also, elemwise product is easily parallelized on GPU and even modern CPUs (provided the memory layout is contiguous), so it is usually not a bottleneck.
> ---- Pascal |

Re: [theano-users] element wise matrix multiply? | Samuel Leeman-Munk | 7/8/15 9:05 AM | Terrific. Good to hear. Thanks for the helpful replies. You received this message because you are subscribed to a topic in the Google Groups "theano-users" group. |