xlnstorch.convert_model.parse_sequential

xlnstorch.convert_model.parse_sequential#

xlnstorch.convert_model.parse_sequential(model, parent_name='')#

Parses a PyTorch nn.Sequential model or an equivalent nn.Module that defines nn.Module children in a similar way.

Parameters:
  • model (Union[torch.nn.Sequential, torch.nn.Module]) – The model to parse, typically an instance of nn.Sequential or a custom nn.Module that contains nn.Module children.

  • parent_name (str, optional) – The name of the parent module, used for nested modules. Defaults to “”.

Returns:

Each tuple contains: - name: str, the full name of the module - cls: str, the class name of the module - args: OrderedDict, the parameters of the module This allows for easy introspection of the model structure and parameters.

Return type:

list of tuples