Basic observation on LeNet¶
Let's observe network variable by two utility functions get_activation_info
and get_weight_info
in mrfi.experiment
.
get_activation_info(fi_model, input_data, method='MinMax', pre_hook=False, **kwargs)
¶
Observe model activations without fault injection.
Parameters:
-
fi_model
(
MRFI
) –Target model.
-
input_data
(
Union[torch.Tensor, DataLoader]
) –A input tensor or a dataloader.
-
method
(
str
) –Name of the basic observer in
mrfi.observer
. -
pre_hook
(
bool
) –Observer value in module input, not output.
-
**kwargs
(
dict
) –Target module to observe,
module_type
,module_name
ormodule_fullname
Returns:
-
dict
–Dictionary of observer result, keys are activation observation name and values are result of
observer.result()
.
get_weight_info(model, method='MinMax', weight_name='weight', **kwargs)
¶
Observe model weights.
Parameters:
-
model
(
Union[MRFI, torch.nn.Module]
) –Target model.
-
method
(
str
) –Name of the basic observer in
mrfi.observer
. -
weight_name
(
Union[str, List[str]]
) –Target weight name.
-
**kwargs
(
dict
) –Target module to observe,
module_type
,module_name
ormodule_fullname
Returns:
-
dict
–Dictionary of observer result, keys are weight observation and values are result of
observer.result()
.
Observing by interactive Python program¶
In a jupyter environment, we obtain these information of each layer in LeNet:
- Shape of weights and activaitons
- Min/Max range of weights and activations
- Standard deviation of weights and activations
- Sampling value in tensor and visualize its distribution
- Visualize its feature map