Click4Ai

489.

Medium

Attention Visualization

In this problem, you will be implementing a function to visualize attention weights from a given attention matrix. Attention matrices are used in transformer models to weight the importance of different input elements. Your function should take in an attention matrix and return a heatmap representation of the attention weights.

Example:

Suppose we have an attention matrix [[0.1, 0.3], [0.7, 0.2]]. The function should return a heatmap with the attention weights plotted.

Constraints:

* The input attention matrix should be a 2D numpy array.

* The heatmap should be a 2D numpy array with the same shape as the input attention matrix.

Test Cases

Test Case 1
Input: [[0.1, 0.3], [0.7, 0.2]]
Expected: Heatmap of attention weights
Test Case 2
Input: [[0.5, 0.5], [0.5, 0.5]]
Expected: Heatmap of attention weights
+ 3 hidden test cases