element wise matrix multiply?

5 721 просмотр
Перейти к первому непрочитанному сообщению

Dmitry Lagun

не прочитано,
17 апр. 2013 г., 18:40:1617.04.2013
– theano...@googlegroups.com
Hi,

I could not quickly find in the documentation - is there some analog of element wise matrix multiplication implemented in Theano?

Thanks,
Dmitry

Pascal Lamblin

не прочитано,
17 апр. 2013 г., 18:55:4217.04.2013
– theano...@googlegroups.com
Hi Dmitry,

On Wed, Apr 17, 2013, Dmitry Lagun wrote:
> I could not quickly find in the documentation - is there some analog of
> element wise matrix multiplication implemented in Theano?

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

Dmitry Lagun

не прочитано,
17 апр. 2013 г., 18:55:1717.04.2013
– theano...@googlegroups.com
Thanks!

Samuel Leeman-Munk

не прочитано,
8 июл. 2015 г., 09:57:4808.07.2015
– theano...@googlegroups.com
Is there a speed penalty for elementwise? I imagine blas is optimized for non-elementwise matrix multiplication (more like dot than *)

Daniel Renshaw

не прочитано,
8 июл. 2015 г., 10:01:3208.07.2015
– theano...@googlegroups.com

--

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

Pascal Lamblin

не прочитано,
8 июл. 2015 г., 11:40:0108.07.2015
– theano...@googlegroups.com
On Wed, Jul 08, 2015, Samuel Leeman-Munk wrote:
> Is there a speed penalty for elementwise? I imagine blas is optimized for
> non-elementwise matrix multiplication (more like dot than *)

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.

>
> On Wednesday, April 17, 2013 at 6:55:17 PM UTC-4, Dmitry Lagun wrote:
> >
> > Thanks!
> >
> > On Wednesday, April 17, 2013 6:55:42 PM UTC-4, Pascal Lamblin wrote:
> >>
> >> Hi Dmitry,
> >>
> >> On Wed, Apr 17, 2013, Dmitry Lagun wrote:
> >> > I could not quickly find in the documentation - is there some analog of
> >> > element wise matrix multiplication implemented in Theano?
> >>
> >> 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
> >>
> >
>
> --
>
> ---
> 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...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.


--
Pascal

Samuel Leeman-Munk

не прочитано,
8 июл. 2015 г., 12:05:3408.07.2015
– theano...@googlegroups.com
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.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/theano-users/fZpCchn4JbI/unsubscribe.
To unsubscribe from this group and all its topics, send an email to theano-users...@googlegroups.com.
Ответить всем
Отправить сообщение автору
Переслать
0 новых сообщений