I am trying to embed one-hot vectors, each with length 10000 and a corresponding label (0 or 1). With mini-batch size 10, the dimension of the input to my feedforward neural network model is 10 x 10000.
I am trying to embed this input with nn.Embedding(10000, 150).
So, after this embedding layer, my data becomes 10 x 10000 x 150. I am doing binary classification, so the output dimension is 10 x 10000 X 2. My label is of dimension 10 x 2. Either (1, 0) or (0, 1).
So, I get ValueError: Target size (torch.Size([10, 2])) must be the same as input size (torch.Size([10, 10000, 2]))
How can I make this model to work? Each vector of 10000 length corresponds to either a 0 or 1 for its label.
Thanks for the reply. How would you suggest me to edit the final layer? What should the output dimension be?
Since the number of rows of my input data is 10000, I am not sure how the output layer does not include that number.
Here are the dimensions after each layer:
Dimension of input: torch.Size([10, 10000])
Dimension after embedding: torch.Size([10, 10000, 150])
Dimension after layer1: torch.Size([10, 10000, 512])
Dimension after layer2: torch.Size([10, 10000, 512])
Dimension after final layer: torch.Size([10, 10000, 2])
Yep as Anant said already, you have to do that;
Note Embedding layers just acts as a lookup table, they are moreover quite similar to one-hot-encoding as well