mighty.utils.hooks.get_layers_ordered

mighty.utils.hooks.get_layers_ordered(model, input_sample, ignore_layers=(<class 'torch.nn.modules.container.Sequential'>, ), ignore_children=())[source]

Returns a list of ordered layers of the input model.

Parameters:
modelnn.Module

An input model.

input_sampletorch.Tensor

A sample tensor to be used with the model.

ignore_layerstuple of type

A tuple of model classes not to include in the final result. Default: (nn.Sequential,)

ignore_childrentuple of type

A tuple of model classes to skip entering their children. Default: ()

Returns:
layers_orderedlist of torch.Tensor

An ordered list of layers of the input model. Note that some modules might be added in the list more than once.