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

Maybe a bug in constructing hidden states. #20

Open
leix28 opened this issue Feb 6, 2020 · 2 comments
Open

Maybe a bug in constructing hidden states. #20

leix28 opened this issue Feb 6, 2020 · 2 comments

Comments

@leix28
Copy link

leix28 commented Feb 6, 2020

(1) hidden = self.latent2hidden(z)

(2) if self.bidirectional or self.num_layers > 1:
(3)     hidden = hidden.view(self.hidden_factor, batch_size, self.hidden_size)
(4) else:
(5)     hidden = hidden.unsqueeze(0)

I think line (3) should be

hidden = hidden.view(batch_size, self.hidden_factor, self.hidden_size).transpose(0, 1)

This snap of code appears in both forward and inference.

@rocreguant
Copy link

I tried, there is a dimensionality missmatch with your line...

@Quasimondo
Copy link

I also encountered a problem with inference of a 2-layer model. The fix for me was changing these lines in the inference() code in model.py:

if self.bidirectional or self.num_layers > 1:
    # unflatten hidden state
    hidden = hidden.view(self.hidden_factor, batch_size, self.hidden_size)

hidden = hidden.unsqueeze(0)

to

if self.bidirectional or self.num_layers > 1:
    # unflatten hidden state
    hidden = hidden.view(self.hidden_factor, batch_size, self.hidden_size)
if self.num_layers == 1:   
    hidden = hidden.unsqueeze(0)

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

No branches or pull requests

3 participants