func1 = [class_A(dim=2, parity=i%2) for i in range(2)]
func2 = [class_B( 2, 2, 1, 1)]
funcs = list(itertools.chain(*zip(func1, func2)))
class Main_model(nn.Module):
def __init__(self, funcs): # funcs is a list of all the classes with the init parameters passed
super().__init__()
self.funcs = nn.ModuleList(funcs)
def forward(self, x):
.......
for func in self.funcs:
.... #print the name of the func alone as a string
return
How to get the names of the classes as a string ?
Please help