(input_sentence, output_words, attentions)
| 818 | # |
| 819 | |
| 820 | def showAttention(input_sentence, output_words, attentions): |
| 821 | fig = plt.figure() |
| 822 | ax = fig.add_subplot(111) |
| 823 | cax = ax.matshow(attentions.cpu().numpy(), cmap='bone') |
| 824 | fig.colorbar(cax) |
| 825 | |
| 826 | # Set up axes |
| 827 | ax.set_xticklabels([''] + input_sentence.split(' ') + |
| 828 | ['<EOS>'], rotation=90) |
| 829 | ax.set_yticklabels([''] + output_words) |
| 830 | |
| 831 | # Show label at every tick |
| 832 | ax.xaxis.set_major_locator(ticker.MultipleLocator(1)) |
| 833 | ax.yaxis.set_major_locator(ticker.MultipleLocator(1)) |
| 834 | |
| 835 | plt.show() |
| 836 | |
| 837 | |
| 838 | def evaluateAndShowAttention(input_sentence): |
no outgoing calls
no test coverage detected