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

Question about prepare alignments #22

Open
chynphh opened this issue Jun 15, 2020 · 1 comment
Open

Question about prepare alignments #22

chynphh opened this issue Jun 15, 2020 · 1 comment

Comments

@chynphh
Copy link

chynphh commented Jun 15, 2020

Hi,
In prepare_fastspeech.ipynb file,
about

F = torch.mean(torch.max(alignments, dim=-1)[0], dim=-1) 
r, c = torch.argmax(F).item()//4, torch.argmax(F).item()%4
location = torch.max(alignments[r,c], dim=1)[1]

My understanding is: In the first line, the tensor shape changed from (layer_num, target_length, source_length) to (layer_num, target_length), and to (layer_num).
But I don't understand what's the mean of "4", and why use the layer num to calculate the location?

If there is a problem with my understanding, thanks for pointing out.

@Jackson-Kang
Copy link

Hello, @chynphh

4 means the number of heads used to multihead-attention.
If you edit the return value of multihead attention in pytorch, you can get the attention with (layer_num, head_num, target_length, source_length) shape.

Consequently, r and c means n_layers and n_heads.
Hope that this comment be helpful to you.

Sincerely,

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

2 participants