Nature of tensor product in machine learning

25 Views Asked by At

In machine learning there is one fundamental step which is the feedforward step of neural networks. Basically given a matrix of weights W, a input vector $x$, a bias vector and a $g$ function like $\tanh$ the algorithm is defined as

$$g(Wx+b)$$

Nothing very complex, however things get more complex if input is not a vector. If the input is a matrix then the weights $W$ is no longer a table but a cube. What is the general algorithm that allows me to perform the $Wx$ part of the algorithm regardless of the number of "dimensions"?

Is it useful to consider W as a vector of matrices if $x$ is $N * M$ or consider $W$ as a matrix of matrices if $x$ is $N * M * P$?

Thank you, it's over a week I'm searching for a response.