Contents:
Context manager to set and remove hooks that collect attention maps.
Example
Usage:
>>> with forward_with_attns(model) as attns: >>> outputs = model(inputs) >>> print(attns.items())
model (Model) – Model where the attention hooks will be set.
Model
A dictionary that will be populated after the forward pass.
Generator[Dict[str, Tensor], None, None]
Generator
Dict
str
Tensor
None