Group Abstract Group Abstract

Message Boards Message Boards

Define a NN function that multiply matrices within a tensor?

Posted 8 years ago

I'm wondering how to define a net function that will multiply matrices inside a tensor. For example, if $s$ and $t$ are tensors with shapes $\{a,b,c\}$ and $\{a,c,d\}$ respectively, for each $i\leq a$ the subtensors in $s$ and $t$ with first index $i$ form matrices of dimensions $b\times c$ and $c\times d$ respectively. Multiplying corresponding matrices in $s$ and $t$ would produce a new tensor with shape $\{a,b,d\}$.

Is there currently a way to do this in Mathematica using nn layers? DotLayer and ThreadingLayer have depth limitations that seem to prevent it.

POSTED BY: Andrew Dabrowski
3 Replies
POSTED BY: Todd Rowland

The problem is that doing matrix multiplication requires controlling two indices, not just one. I'm guessing this is a capability Mathematica will gain as the function library develops.

POSTED BY: Andrew Dabrowski

Maybe ReshapeLayer might be useful, but I think TransposeLayer must be the way to get the matching index c in the right spot.

POSTED BY: Todd Rowland
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard