Functional utilities¶
Helpers for constructing attribution baselines and normalizing scores. For practical baseline guidance, see Choosing a baseline.
tslens.get_baseline ¶
get_baseline(inputs: Union[Tensor, Tuple[Tensor, ...]], mode: str = 'zero') -> Union[torch.Tensor, Tuple[torch.Tensor, ...]]
Build a baseline tensor (or tuple of them) matching inputs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
inputs
|
Union[Tensor, Tuple[Tensor, ...]]
|
tensor or tuple of tensors shaped |
required |
mode
|
str
|
|
'zero'
|
tslens.normalize_scale ¶
normalize_scale(data: Tensor, dim: int = 1, norm_type: str = 'standard', legacy: bool = False) -> torch.Tensor
Normalize data along dim.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
Tensor
|
tensor to normalize. |
required |
dim
|
int
|
dimension to reduce over. |
1
|
norm_type
|
str
|
one of |
'standard'
|
legacy
|
bool
|
reproduce the exact |
False
|