Skip to content

Commit

Permalink
update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
tlatkowski committed May 7, 2019
1 parent bb79527 commit 80b854d
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 1 deletion.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,16 @@ The below pictures presents Multihead Siamese Nets GUI for:
2. Negative example:

![](https://github.com/tlatkowski/multihead-siamese-nets/blob/master/pics/negative_sample.png)

# Attention weights visualization
In order to visualize multihead attention weights for compared sentences use GUI demo - check
'Visualize attention weights' checkbox which is visible after choosing model based on multihead attention mechanism.

The example of attention weights visualization looks as follows (4 attention heads):

![](https://github.com/tlatkowski/multihead-siamese-nets/blob/master/pics/attention1.png)
![](https://github.com/tlatkowski/multihead-siamese-nets/blob/master/pics/attention2.png)

# Comparison of models

Experiments performed on GPU **Nvidia GeForce GTX 1080Ti**.
Expand Down
Binary file added pics/attention1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pics/attention2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion utils/visualization.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
def visualize_attention_weights(attention_weights, sentence: str,
cmap='coolwarm'): # cmap='gist_gray'
interactive(True)
num_heads = np.shape(attention_weights)[0]
# num_heads = np.shape(attention_weights)[0]
num_heads = 4
xticklabels = sentence.split(' ')
yticklabels = xticklabels

Expand Down

0 comments on commit 80b854d

Please sign in to comment.