vision
Classes:
Name | Description |
---|---|
TransformedImageVisualizationManager |
Captures |
ActivationImages
¶
Bases: TypedDict
A dictionary of images, comprised of a grid of input images and their corresponding activations.
Attributes:
Name | Type | Description |
---|---|---|
activation |
Tensor
|
An image tensor, formatted as a grid, where each row contains an input image and its corresponding noise layer output. |
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 |
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 |
mean |
Tensor
|
An image tensor, formatted as a grid, where each row contains an input image and its corresponding noise layer mean. |
std |
Tensor
|
An image tensor, formatted as a grid, where each row contains an input image and its corresponding noise layer standard deviation. |
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
¶
Bases: TypedDict
A dictionary of tensors to process into a visualization.
Attributes:
Name | Type | Description |
---|---|---|
activation |
Tensor
|
The noise layer activation. |
input |
Tensor
|
The input to the model. |
mask |
NotRequired[Tensor]
|
The noise layer mask. |
masked_std |
NotRequired[Tensor]
|
The masked noise layer standard deviation. |
mean |
Tensor
|
The noise layer mean. |
std |
Tensor
|
The noise layer standard deviation. |
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.
Methods:
Name | Description |
---|---|
__init__ |
Construct a new |
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 |
Attributes:
Name | Type | Description |
---|---|---|
grids |
ActivationImages
|
The tensors representing the grid of images to visualize. |
__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. |