vision
ActivationImages
¶
Bases: TypedDict
A dictionary of images, comprised of a grid of input images and their corresponding activations.
activation
instance-attribute
¶
activation: Tensor
An image tensor, formatted as a grid, where each row contains an input image and its corresponding noise layer output.
mask
instance-attribute
¶
mask: NotRequired[Tensor]
An image tensor, formatted as a grid, where each row contains an input image and its corresponding noise layer mask.
masked_std
instance-attribute
¶
masked_std: NotRequired[Tensor]
An image tensor, formatted as a grid, where each row contains an input image and its corresponding noise layer mask applied to the standard deviation.
TensorsToVisualize
¶
TransformedImageVisualizationManager
¶
Captures NoisyModel
input images and intermediate activations and creates visualizations, formatted as a grid of images where
each row contains an input image and its corresponding activation.
__init__
¶
__init__(
noisy_model: NoisyModel[ModuleT, ..., NoiseLayerT],
input_name: str | None = None,
max_examples: int = 4,
max_color_channels: int = 3,
) -> None
Construct a new TransformedImageVisualizationManager
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
|
NoisyModel[ModuleT, ..., NoiseLayerT]
|
The model to visualize input images and activations for. |
required |
|
str | None
|
The name of the |
None
|
|
int
|
The maximum number of rows to display in the visualizations. |
4
|
|
int
|
The maximum number of individual color channels to additionally display in each visualization. If the target layer has more than 3 color channels, these will be displayed in grayscale. |
3
|
Raises:
Type | Description |
---|---|
ValueError
|
If |
ValueError
|
If |
prepare_activation_images
¶
Collect the input and activation tensors from the most recent forward pass and populate them into a grid of images for each activation.
Returns:
Type | Description |
---|---|
ActivationImages
|
A dictionary of image tensors, each formatted as a grid of images, where each row corresponds to a specific example. |