Skip to content
Snippets Groups Projects

Added function to aggregate attention maps

Merged Thibault Lavigne requested to merge 35-new-functon-to-aggregate-attention-maps-2 into main
All threads resolved!
1 file
+ 1
2
Compare changes
  • Side-by-side
  • Inline
+ 1
2
@@ -44,8 +44,7 @@ def compute_coverage(text: str, max_value: float, offset: int, attentions):
# blank vector to accumulate weights for the current text
coverage_vector = np.zeros((height, width))
for i in range(len(text)):
local_weight = attentions[i + offset]
local_weight = cv2.resize(local_weight, (width, height))
local_weight = cv2.resize(attentions[i + offset], (width, height))
coverage_vector = np.clip(coverage_vector + local_weight, 0, 1)
# Normalize coverage vector
Loading