The error indicates that the tag_scores has size (5, 10), which according to your input_y, it should have been of size (5, 10). So, since tag_scores comes from this line self.linear = nn.Linear(self.hidden_dim,self.output_dim), can you confirm what output_dim you have used to construct the model?