Hi. I have created a multi-module model by using add_module method.
First I defined an empty class model:
class EmptyModel(nn.Module):
def __init__(self):
super(EmptyModel, self).__init__()
def forward(self, x):
return x
empty_model = EmptyModel()
Then I add modules from another previously defined model:
empty_model.add_module("stage_1",vgg_8_sub_student)
empty_model.stage_1.eval()
empty_model.add_module("stage_2",nn.Sequential(*list(vgg_8_model.features)[7:]))
empty_model.add_module("classifier",nn.Sequential(vgg_8_model.classifier))
As you can see, the first module is already trained so I set it to eval().
When I use torchsummary to visualize each of these modules, everything works fine. They work properly, But when I try to visualize the whole model, I get an error:
summary(student_partially_trained_from_stage_1,input_size=(3,224,224),device="cpu")
File "/home/aasadian/.local/lib/python3.6/site-packages/torchsummary/torchsummary.py", line 102, in summary
total_params_size = abs(total_params.numpy() * 4. / (1024 ** 2.))
AttributeError: 'int' object has no attribute 'numpy'
Also, I found that when I pass some data points, the whole model does not produce output, i.e., if I feed my model with a batch of data (32,3,224,224), the output is the same size. any help is appreciated.