Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chapter 13) output tensor dimension error #24

Closed
woojin716 opened this issue Jun 28, 2023 · 1 comment
Closed

Chapter 13) output tensor dimension error #24

woojin716 opened this issue Jun 28, 2023 · 1 comment

Comments

@woojin716
Copy link

woojin716 commented Jun 28, 2023

In Multi-step prediction section of chapter 13 (LSTM-FC Seq2Seq Last Hidden, LSTM-FC Seq2Seq All Hidden) I got RuntimeError: Predictions and targets are expected to have the same shape, but got torch.Size([32, 1, 48]) and torch.Size([32, 48, 1]).

src/dl/models.py Line 361, 363 should be fixed to "unsqueeze(-1)" or something. (forward function part of Seq2SeqModel class)

if self.hparams.decoder_type == "FC":
            if self.hparams.decoder_use_all_hidden:
                y_hat = self.decoder(o.reshape(o.size(0), -1)).unsqueeze(-1)  # fixed
            else: 
                y_hat = self.decoder(o[:, -1, :]).unsqueeze(-1)  # fixed
manujosephv added a commit that referenced this issue Jul 27, 2023
@manujosephv
Copy link
Collaborator

Thank you @woojin716. The unsqueeze(-1) does look like the right way to go. Have changed it in the code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants