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

TopKDecoder #177

Open
Hongzl1996 opened this issue Nov 5, 2018 · 6 comments
Open

TopKDecoder #177

Hongzl1996 opened this issue Nov 5, 2018 · 6 comments

Comments

@Hongzl1996
Copy link

Hongzl1996 commented Nov 5, 2018

Hi,
I wonder if rnn.forward_step changes the order of (batch_size*self.k) dimension ?
With the code about initializing sequence_scores:
2
and in each step:
3

It seems like sequence_scores is updated as (assume that selk.k = 3):
default

If hidden and inflated_encoder_outputs should be calculated as follow?

inflated_encoder_outputs =  _inflate(encoder_outputs,self.k,1).view(batch_size*self.k, -1)  
hidden_shape = encoder_hidden.size()
hidden = _inflate(encoder_hidden, self.k, 2).view(hidden_shape[0], batch_size*self.k, hidden_shape[2])
@KwanWaiChung
Copy link

hi, I am studying the code and have similar doubts. However, can you be clear what you mean by decoder_output? do you actually mean log_softmax_output?

@Hongzl1996
Copy link
Author

@JojoFisherman Yeah, I mean the output probability of decoder, i.e. log_softmax_output.

@KwanWaiChung
Copy link

I have the same question. It surprised me that no one has answered this. If theres really something wrong in the beam search, surely it will output some weird sequence. Do you have any conclusion about this?

@Hongzl1996
Copy link
Author

It seems some issues have referred that beam search doesn't work correctly. Unfortunately, maybe this repo is not active maintained now. Currently, I use fairseq (pytorch version) to conduct some related experiments.

@GZJAS
Copy link

GZJAS commented Jun 11, 2019

I studied the codes these days, and I thought you can use the torch.repeat_interleave. Such as follow:
hidden = tuple([torch.repeat_interleave(h, self.k, dim=1) for h in encoder_hidden])
inflated_encoder_outputs = torch.repeat_interleave(encoder_outputs, self.k, dim=0)

@muncok
Copy link

muncok commented Feb 21, 2020

I studied the codes these days, and I thought you can use the torch.repeat_interleave. Such as follow:
hidden = tuple([torch.repeat_interleave(h, self.k, dim=1) for h in encoder_hidden])
inflated_encoder_outputs = torch.repeat_interleave(encoder_outputs, self.k, dim=0)

I had the problem with batch_size > 1, but after applying this comment, then it works now.

Thank you!!

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

4 participants