I have a sequence of 12 words which I represent using a 12x256 matrix (using word embeddings). Let us refer to these as . I wish to take this as input and output a 1x256 vector. However I don't want to use a (12x256) x 256 dense layer. Instead I want to create the output embedding using a weighted summation of the 12 embeddings
where the wi s are scalars (thus there is weight sharing).
How can I create trainable wi s in pytorch? I am new and only familiar with the standard modules like nn.Linear.