Compute the similarity between the outputs and the embeddings.
pip install keras-embed-sim
from tensorflow import keras
from keras_embed_sim import EmbeddingRet, EmbeddingSim
input_layer = keras.layers.Input(shape=(None,), name='Input')
embed, embed_weights = EmbeddingRet(
input_dim=20,
output_dim=100,
mask_zero=True,
)(input_layer)
output_layer = EmbeddingSim()([embed, embed_weights])