How can I implement a simple memory augmented neural network as provided in this PyTorch implementation with Tensorflow 2 and Keras?

Viewed 376

I found this repo (https://github.com/donggong1/memae-anomaly-detection) with a PyTorch implementation of a simple memory for a neural network. I think that this memory can be really easily implemented with Keras. But I don't know how to start.

enter image description here

Can anyone help me with how to reimplement the memory approach with TF2 and Keras? In the best case with just a single MLP with 3 dense layer (no autoencoder needed). I just want an example of how this memory would be implemented in Keras / TF2.0.

The memory is very simple and works as follows: a latent vector is compared with all stored vectors of the memory regarding cosine similarity. Via attention, the most similar entry is chosen and used for further processing. But how are the entries/vectors/prototypes of the memory matrix learned? How to do this in Keras?

It is not clear to me, how I can learn the prototypes stored in the memory.

0 Answers
Related