add_hidden_perturbation_in_module

add_hidden_perturbation_in_module#

class braintrace.add_hidden_perturbation_in_module(model, *model_args, **model_kwargs)[source]#

Adds perturbations to the hidden states in the given module and replaces the hidden states with the perturbed states.

Parameters:
  • (brainstate.nn.Module) (model)

  • *model_args (Additional positional arguments to be passed to the model.)

  • **model_kwargs (Additional keyword arguments to be passed to the model.)

Returns:

HiddenPerturbation

Return type:

HiddenPerturbation