We don't have any tensor multiplication built in, so you'll
have to break it down into components.
Best if those are themselves matrix multiplies if possible, so the
trick's setting up the tensors to support efficient indexing. There's
a chapter in the manual on arrays vs. vectors that should help.
Overall, that loop's not going to be a big deal in terms of
efficiency, but big tensor multiplies get expensive quickly (even
multiply N x N matrices is an N^3 operation).
- Bob
> On Apr 26, 2017, at 2:58 AM, Ste <mangiol...@gmail.com> wrote:
>
> Hello,
>
> I am looking for some elegant solution/function that does automated/fast tensor multiplication
>
> 3D_Matrix_1[s,k,p] x 3D_Matrix_2[p, g, k] = 2D_Matrix_3[g,s];
>
> I can do it with some for() loop, but would be great if there was a function that speed this calculation up.
>
> Thanks a lot.
>
> --
> You received this message because you are subscribed to the Google Groups "Stan users mailing list" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to stan-users+unsubscribe@googlegroups.com.
> To post to this group, send email to stan-...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to a topic in the Google Groups "Stan users mailing list" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/stan-users/76YG_zOXat8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to stan-users+unsubscribe@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to stan-users+...@googlegroups.com.
import numpy
A = numpy.random.rand(3, 4, 5)
B = numpy.random.rand(4, 5, 3)
print numpy.einsum('ijk, jkl', A, B)
Am = A.reshape(3, 4 * 5)
Bm = B.reshape(4 * 5, 3)
print Am.dot(Bm)>> > To unsubscribe from this group and stop receiving emails from it, send an email to stan-users+unsubscribe@googlegroups.com.
>> > To post to this group, send email to stan-...@googlegroups.com.
>> > For more options, visit https://groups.google.com/d/optout.
>>
>> --
>> You received this message because you are subscribed to a topic in the Google Groups "Stan users mailing list" group.
>> To unsubscribe from this topic, visit https://groups.google.com/d/topic/stan-users/76YG_zOXat8/unsubscribe.
>> To unsubscribe from this group and all its topics, send an email to stan-users+unsubscribe@googlegroups.com.
>> To post to this group, send email to stan-...@googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
>>
>>
>> --
>> You received this message because you are subscribed to the Google Groups "Stan users mailing list" group.
>> To unsubscribe from this group and stop receiving emails from it, send an email to stan-users+unsubscribe@googlegroups.com.
>> To post to this group, send email to stan-...@googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
>
> --
> You received this message because you are subscribed to a topic in the Google Groups "Stan users mailing list" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/topic/stan-users/76YG_zOXat8/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to stan-users+unsubscribe@googlegroups.com.
> To post to this group, send email to stan-...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>
>
> --
> You received this message because you are subscribed to the Google Groups "Stan users mailing list" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to stan-users+unsubscribe@googlegroups.com.
> To post to this group, send email to stan-...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to a topic in the Google Groups "Stan users mailing list" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/stan-users/76YG_zOXat8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to stan-users+unsubscribe@googlegroups.com.