Skip to content

Zero ablate hook¤

Zero ablate hook.

zero_ablate_hook(value, hook) ¤

Zero ablate hook.

Parameters:

Name Type Description Default
value Tensor

The activations to store.

required
hook HookPoint

The hook point.

required
Example

dummy_hook_point = HookPoint() value = torch.ones(2, 3) zero_ablate_hook(value, dummy_hook_point) tensor([[0., 0., 0.], [0., 0., 0.]])

Returns:

Type Description
Tensor

Replaced activations.

Source code in sparse_autoencoder/source_model/zero_ablate_hook.py
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
def zero_ablate_hook(
    value: Tensor,
    hook: HookPoint,  # noqa: ARG001
) -> Tensor:
    """Zero ablate hook.

    Args:
        value: The activations to store.
        hook: The hook point.

    Example:
        >>> dummy_hook_point = HookPoint()
        >>> value = torch.ones(2, 3)
        >>> zero_ablate_hook(value, dummy_hook_point)
        tensor([[0., 0., 0.],
                [0., 0., 0.]])

    Returns:
        Replaced activations.
    """
    return torch.zeros_like(value)