Recursively get the attribute of a module. Args: model (`torch.nn.Module`) The model to get the attribute from. module_name (`str`) The name of the module to get the attribute from.
(model, module_name)
| 5 | |
| 6 | |
| 7 | def recursive_getattr(model, module_name): |
| 8 | """ |
| 9 | Recursively get the attribute of a module. |
| 10 | Args: |
| 11 | model (`torch.nn.Module`) |
| 12 | The model to get the attribute from. |
| 13 | module_name (`str`) |
| 14 | The name of the module to get the attribute from. |
| 15 | """ |
| 16 | split_list = module_name.split('.') |
| 17 | output = model |
| 18 | for name in split_list: |
| 19 | output = getattr(output, name) |
| 20 | return output |
| 21 | |
| 22 | |
| 23 | def recursive_setattr(model, module_name, module): |
no outgoing calls