A tensorflow addon for many types of attention mechanisms
You can use attention toolbox by passing a tensor like :
from attention_box import soft_attention
# query is from embedding layer or lstm or cnn logit
attention_output = soft_attention(query, visualize_attention = True )