espnet2.torch_utils.get_layer_from_string.get_layer
Less than 1 minute
espnet2.torch_utils.get_layer_from_string.get_layer
espnet2.torch_utils.get_layer_from_string.get_layer(l_name, library=<module 'torch.nn' from '/data/user_data/msomeki/miniconda/lib/python3.10/site-packages/torch/nn/_init_.py'>)
Return layer object handler from a specified library, such as torch.nn.
This function searches for a layer in the given library based on its name. If a matching layer is found, it returns the corresponding layer object handler.
Example
If l_name is “elu”, the function will return torch.nn.ELU.
- Parameters:
- l_name (str) – Case insensitive name for the layer in the library (e.g. ‘elu’).
- library (module) – Name of the library/module to search for the object handler with l_name, e.g. torch.nn.
- Returns: Handler for the requested layer (e.g. torch.nn.ELU).
- Return type: layer_handler (object)
- Raises:
- NotImplementedError – If no matching layer is found or if multiple matches
- are found for the specified layer name. –