1

I tried to print the summary of the SinGAN model, but I got an error which is:

enter image description here This is the code:

def init_models(opt):

#generator initialization:
netG = models.GeneratorConcatSkip2CleanAdd(opt).to(opt.device)
netG.apply(models.weights_init)
if opt.netG != '':
    netG.load_state_dict(torch.load(opt.netG))
summary(netG,input_size=(3, 201, 256))
print(netG)

#discriminator initialization:
netD = models.WDiscriminator(opt).to(opt.device)
netD.apply(models.weights_init)
if opt.netD != '':
    netD.load_state_dict(torch.load(opt.netD))
print(netD)

return netD, netG

The problem when i add this line:

    summary(netG,input_size=(3, 201, 256))

And I get the complete code from here.

So, is my way wrong? should I use a different variable as a model?

norah
  • 69
  • 1
  • 10
  • where have you imported the `summary` from ? Check its documentation. You are probably using the argument name (`input_size`) wrong, as that tensor is not being passed into model – harshraj22 Jan 03 '22 at 16:05
  • I imported the `summary` using this command `from torchsummary import summary` and I tried to use `input_size` and deleted it but i got same problem – norah Jan 03 '22 at 19:20

1 Answers1

1

The forward function of your model expects two input images. In torchsummary.summary, you are providing only one input shape, so it is trying to pass only one input image to your model, leaving the second required argument unpassed and hence raising the issue. Read here how to pass inputs to torchsummary.summary when model expects multiple inputs in the forward method.

harshraj22
  • 130
  • 1
  • 10