timbmg / Sentence-VAE

PyTorch Re-Implementation of "Generating Sentences from a Continuous Space" by Bowman et al 2015 https://arxiv.org/abs/1511.06349
580 stars 152 forks source link

Question about the inference function #13

Closed vikigenius closed 5 years ago

vikigenius commented 5 years ago

In your inference function you have

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)

Shouldn't the unsequeeze happen only in an else condition if bidirectional is false and number of layers is one? Otherwise if the model uses a bidirectional GRU or has num_layers > 1 you will have a 4d tensor: (1, hidden_factor, batch_size, hidden_size)

timbmg commented 5 years ago

I think you are right. Thanks for pointing out! But now I am thinking about it, that bidirectional option does not make too much sense right now anyway. We'd need another linear layer to combine the two directions. Will add this soon.

MBAnslow commented 5 years ago

Would it be possible to set the bidirectional option to false as the default value in argparse? This took me quite some time to figure out and really, default options should work.

timbmg commented 5 years ago
parser.add_argument('-bi', '--bidirectional', action='store_true')

If --bidirectional is not provided, it is disabled.

MBAnslow commented 5 years ago

Ok, it is just an artifact of how I'm running it then. Thanks for this repo btw, it is very interesting :).