Implement autoencoder with attention layer - tensorflow

I am trying to modify the autoencoder model so I can add an attention layer on the "bottleneck/compressed" layer.
Suppose i have 2 encode Density layers, the attention layer i want to add, and 2 decode Density layers.
How can I develop this architecture in tensorflow?

Related

Attention in Keras

I'm trying to add an attention layer to improve interpretability of my multi-label classification deep learning model. The attention layer is intended to be at the very input into the network and to be fed time series input of shape (250, 5, 6). There are no recurrent relations in the network. Considering the input is 3D and time series I'm not sure what kind of Attention layers would be the most effective. I've tried simple Keras Attention and Multi-headed Attention, but I've concluded simple attention is not what I need and Multi-headed attention was taking ages to get trained. Any ideas what could be useful to look into?

LBP Feature Grafting with CNN Layer using Custom Layer

Can we add manual features extracted by LBP in CNN Layer with the help of Custom Layer or any other terminology.
In the hidden layer.

How can I check/see the inside operations and calculations of any Keras (Dense, Conv1D, LSTM) layers?

I have a question about the architecture of the Keras layers. About kind of unfolding the architecture of the layer. For example, I would like to see the main equation used for the Dense layer in Keras, how the n. of neurons, activation function, and bias are tied to each other. This seems pretty simple in logical understating for the Dense layer. However, finding out the tfa.ESN layer multiplication inside the corresponding layer, for instance, would be very helpful for me.
Thanks to everyone,
J

Can I generate heat map using method such as Grad-CAM in concatenated CNN?

I am trying to apply GradCAM to my pre-trained CNN model to generate heat maps of layers. My custom CNN design is shown as follows:
- It adopted all the convolution layers and the pre-trained weights from the VGG16 model.
- Extract lower level features (early convolution layers) from VGG16.
- Train the fully connected layers of both normal/high and lower level features from VGG16.
- Concatenate outputs of both normal/high- and lower-level f.c. layers and then train more f.c. layers before the final prediction.
model design
I want to use GradCAM to visualize the feature maps of the low-level route and the normal/high-level route and I have done such heatmaps on non-concatenate fine-tuned VGG using the last convolutional layers. My question is, on a concatenated CNN model, can the Grad-CAM method still work using the gradient of the prediction with respect to the low- and high-level feature map feature maps respectfully? If not, are there other methods that can do the heatmaps visualization for such a model? Is using the shared fully connected layer an option?
Any idea and suggestions are much appreciated!

How to use a bidirectional RNN layer in tensorflow ?

When we add a bidirectional RNN layer I can understand that we have to concatenate hidden states. If we use bidirectional RNN layer in encoder decoder model do we have to train the bidirectional RNN layer separately ?
No. To quote from the abstract of Bidirectional Recurrent Neural Networks by Schuster and Paliwal:
The BRNN can be trained without the limitation of using input information just
up to a preset future frame. This is accomplished by training it
simultaneously in positive and negative time direction.
I guess you are talking about tf.nn.static_bidirectional_rnn.