Thanks again, I will try to briefly summarise the problem and why I need to do this: I’m implementing a small module which is intended to operate as an attention network inside a bigger model.
This attention module has two different inputs: a vector that would be ‘B’ of dimension (F) and a matrix ‘A’, with dimensions (B, E). Combining both inputs, I want to obtain a third tensor ‘C’ of dimensions (B,E,F), which would be the ‘alpha’ of the attention module. That means that this variable ‘C’ multiply other variable ‘D’  of dimensions D=(B,E,F), obtaining the output [also of dimensions (B,E,F)].
Summarised, I need:
C = f(A,B).
C = softmax( C ), to make each element between (0,1).
output = C x D, where ‘x’ would be a dot product attention.
In all this scheme, I’m having troubles finding the optimal way to combine A=(B,E) and B=(F) into a 3D tensor of dimensions (B,E,X) where X could be change into the desired dimensions F with a nn.Linear.
Thanks again!