Skip to content
This repository has been archived by the owner on Dec 11, 2023. It is now read-only.

Attention visualization #358

Open
yapingzhao opened this issue Jul 9, 2018 · 8 comments
Open

Attention visualization #358

yapingzhao opened this issue Jul 9, 2018 · 8 comments

Comments

@yapingzhao
Copy link

Hi,
What is the command to get the alignments between source and target sentences ?
Looking forward to your advice or answers.
Best regards,
Thank you very much!

@hpulfc
Copy link

hpulfc commented Jul 24, 2018

@yapingzhao
hack in source , when beam_width=0, nmt will output the final_state , then you can find the alignments.

@JulianZhang
Copy link

@hpulfc Dear, where I can find the final_state and alignments? thanks

@hpulfc
Copy link

hpulfc commented Aug 24, 2018

@JulianZhang
see the code in nmt/attention_model.py . it in the method named _create_attention_images_summary
like this:

def _create_attention_images_summary(final_context_state):
    pass

@kritinemkul
Copy link

@hpulfc can you please elaborate how to visualize the attention matrix for particular source and target sentence ?

@ranjita-naik
Copy link
Contributor

you can backtrace function : plot_attention in this notebook - https://github.com/tensorflow/tensorflow/blob/r1.11/tensorflow/contrib/eager/python/examples/nmt_with_attention/nmt_with_attention.ipynb. Do let me know if it doesn't work for you.

@kritinemkul
Copy link

@ranjita-naik i tried but it won't work. As I have trained my model and i have corresponding translated file too using tensorflow nmt . I want to view attention of those any of input and output sentences. Would you please suggest how to visualize the attention on tensorflow nmt. Thank you in advance.

@ranjita-naik
Copy link
Contributor

@kritinemkul, what's the error? as shown in the evaluate(sentence, encoder, decoder, inp_lang, targ_lang, max_length_inp, max_length_targ) function, are you collecting attention weights during inference?

@kritinemkul
Copy link

@ranjita-naik, this only works for the pairs which are printed in third cell and there is nothing any like development set and test set. If i gave the sentence other than the printed it will give error of unknown keyword. What i want is, trained the model and infer the out put sentences too as shown in the nmt tutorial. I am unable to show attention for those sentences. Is there any way to visualize attention for those sentence in tensorboard on in command prompt or in any way?

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

No branches or pull requests

5 participants