tmeasures.pytorch package

Subpackages

Submodules

tmeasures.pytorch.activations_iterator module

tmeasures.pytorch.activations_iterator_base module

tmeasures.pytorch.activations_transformer module

class tmeasures.pytorch.activations_transformer.ActivationsTransformer(activation_shapes: [Tuple[int]], layer_names: [str], transformation_set: tm.TransformationSet, inverse: bool)[source]

Bases: object

filter_activations(activations: [torch.Tensor]) [torch.Tensor][source]
get_transformations_set(shapes: [Tuple[int]], transformation_set: tm.TransformationSet, inverse: bool)[source]
get_valid_layers(activation_shapes: [Tuple[int]], layer_names: [str], transformation_set: tm.TransformationSet)[source]
trasform_st_same_column(activations: [torch.Tensor], t_i: int)[source]
trasform_st_same_row(activations: [torch.Tensor], t_start: int, t_end: int)[source]
tmeasures.pytorch.activations_transformer.list_get_all(list: list, indices: list[int]) [][source]

tmeasures.pytorch.base module

tmeasures.pytorch.dataset2d module

class tmeasures.pytorch.dataset2d.Dataset2D(*args, **kwds)[source]

Bases: Dataset

abstract property T
abstract get_transformations(row: int, col_from: int, col_to: int)[source]
abstract getitem2d(i, j)[source]
len()[source]
abstract property len0
abstract property len1
row_dataset(row: int)[source]
class tmeasures.pytorch.dataset2d.RowDataset(d: Dataset2D, row: int)[source]

Bases: Dataset

class tmeasures.pytorch.dataset2d.STDataset(dataset: Dataset, transformations: PyTorchTransformationSet, device=device(type='cpu'))[source]

Bases: Dataset2D

len_dataset()[source]
len_transformations()[source]
class tmeasures.pytorch.dataset2d.SampleTransformationDataset(dataset: Dataset, transformations: PyTorchTransformationSet, device=device(type='cpu'))[source]

Bases: STDataset

T()[source]
get_transformations(row: int, col_from: int, col_to: int)[source]
getitem2d(i, j)[source]
property len0
property len1
class tmeasures.pytorch.dataset2d.TransformationSampleDataset(dataset: Dataset, transformations: PyTorchTransformationSet, device=device(type='cpu'))[source]

Bases: STDataset

T()[source]
get_transformations(row: int, col_from: int, col_to: int)[source]
getitem2d(i, j)[source]
property len0
property len1

tmeasures.pytorch.goodfellow module

tmeasures.pytorch.layer_measures module

tmeasures.pytorch.measure_transformer module

tmeasures.pytorch.model module

class tmeasures.pytorch.model.ActivationsModule[source]

Bases: Module

abstract activation_names() List[str][source]
abstract forward_activations(args) List[Tensor][source]
n_activations()[source]
training: bool
class tmeasures.pytorch.model.AutoActivationsModule(module: ~torch.nn.modules.module.Module, full_name=True, filter: ~typing.Callable = <function AutoActivationsModule.<lambda>>)[source]

Bases: ActivationsModule

activation_names() List[str][source]
forward_activations(args) List[Tensor][source]

This function is not thread safe.

register_hooks(activations: List[Module])[source]
reset_values()[source]
training: bool
exception tmeasures.pytorch.model.DuplicateKeyError(*args: object)[source]

Bases: ValueError

class tmeasures.pytorch.model.FilteredActivationsModule(inner_model: ActivationsModule, activations_filter: Callable[[ActivationsModule, str], bool])[source]

Bases: ActivationsModule

activation_names() List[str][source]
eval()[source]

Sets the module in evaluation mode.

This has any effect only on certain modules. See documentations of particular modules for details of their behaviors in training/evaluation mode, if they are affected, e.g. Dropout, BatchNorm, etc.

This is equivalent with self.train(False).

See locally-disable-grad-doc for a comparison between .eval() and several similar mechanisms that may be confused with it.

Returns:

Module: self

forward()[source]

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

abstract forward_activations(args) List[Tensor][source]
training: bool
tmeasures.pytorch.model.flatten_dict(d_or_val: Input, prefix='', sep='/', allow_repeated=False) dict[str, Any][source]
tmeasures.pytorch.model.flatten_dict_list(d_or_val: Union[MutableMapping, Any], key='', full_name=True) List[Tuple[str, Any]][source]
tmeasures.pytorch.model.intersect_lists(a: List, b: List)[source]
tmeasures.pytorch.model.named_children_deep(m: Module)[source]

tmeasures.pytorch.quotient module

tmeasures.pytorch.stats_running module

tmeasures.pytorch.util module

tmeasures.pytorch.variance_invariance module

tmeasures.pytorch.variance_sameequivariance module

Module contents