I wanna get a module from a class with different name (string variable). However, the content has same form of string as the original module name.
For example
import timm
model_configs = timm.models.resnet.default_cfgs['resnet34'] #this one works
target_network_root = 'resnet'
model_configs = timm.models.target_network_root.default_cfgs['resnet34'] #this one doesn't work
Since, the target_network_root can change, I might export another network than resnet, I like to call specific module from timm.models as variable. I really appreciate your support.
>Solution :
You can use getattr()
For example:
getattr(timm.models, target_network_root)
=> timm.models.resnet