braindecode.modules.IntermediateOutputWrapper#
- class braindecode.modules.IntermediateOutputWrapper(to_select, model)[source]#
Wraps network model such that outputs of intermediate layers can be returned. forward() returns list of intermediate activations in a network during forward pass.
- Parameters:
to_select (list) – list of module names for which activation should be returned
model (model object) – network model
Examples
>>> model = Deep4Net() >>> select_modules = ['conv_spat','conv_2','conv_3','conv_4'] # Specify intermediate outputs >>> model_pert = IntermediateOutputWrapper(select_modules,model) # Wrap model
Methods
- forward(x)[source]#
Define 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.