Analysis

This module allows to perform analysis on the behaviour of the layers developed.

class anotherspdnet.analysis.EigenvaluesLogger(model: torch.nn.Module, type_layers_tracked: List[torch.nn.Module], filter_layer: Callable[[torch.nn.Module], bool], list_layers: List[torch.nn.Module], storage_path: str, step_name: str = 'step_0', step: int = -1, log_file_basename: str = 'eig', separator: str = ';', mode: str = 'no_spd', spd_tolerance: float = 0.0001)[source]

Class to log eigenvalues evolution of SPDnet type layers. One log file per layer tracked.

if type_layers_tracked is given, we track all the layers of the model that are of the type given in the list.

If filter_layer is given, we track all the layers that verify the condition given by filter_layer. If both are given, we track all the layers that verify the condition given by filter_layer and that are of the type given in the list.

if type_layers_tracked is None, the list should be filled with all the layers of the model that you want tracked.

if mode is “no_spd”, only log when input matrix is not SPD. If mode is If mode is “all”, the logger will log the eigenvalues at each forward pass of the layer.

model: torch.nn.Module
type_layers_tracked: List[torch.nn.Module]
filter_layer: Callable[[torch.nn.Module], bool]
list_layers: List[torch.nn.Module]
storage_path: str
step_name: str = 'step_0'
step: int = -1
log_file_basename: str = 'eig'
separator: str = ';'
mode: str = 'no_spd'
spd_tolerance: float = 0.0001
hook_layers() None[source]

hook the layers to track the eigenvalues

create_log_files() None[source]

Create the log files for each layer tracked

new_step(step_name: str | None = None) None[source]

Create a new step in the logging (e.g. new epoch).

Parameters:

step_name (Optional[str]) – Name of the step. By default, we use the current step number.