braindecode.visualization.run_with_activation_substitution#
- braindecode.visualization.run_with_activation_substitution(model, x, layer, substitute_fn)[source]#
Run
model(x)after replacinglayer’s output.- Parameters:
model (
Module) – Model to run.x (torch.Tensor) – Model input.
layer (
Module) – Submodule whose output is replaced.substitute_fn (callable) – Called with the layer output and must return its replacement.
- Returns:
The model output after substitution.
- Return type:
Any
- Raises:
TypeError – If
substitute_fnreturnsNone, which PyTorch interprets as keeping the original output.