0

I am using torch summary. I want to pass more than one argument when printing the model summary, one of which is just an integer. However, I get an error. I follow this question recommendation but it is not working.

My network looks like

import torch
from torch import nn
from torchsummary import summary


class SimpleNet(nn.Module):
  def __init__(self):
    super().__init__()
 
  def forward(self, x,t):
    return t * x

I tried to run summary as summary(model,[(3, 64, 64),(1)]) and got TypeError: rand() argument after * must be an iterable, not int.

"Solved" that by doing summary(model,[(3, 64, 64),(1,)]) but still get another TypeError: can't multiply sequence by non-int of type 'tuple'.

How can I get the model summary then?

I.C.
  • 101

1 Answers1

0

Changing from (3, 64, 64),(1) to (3, 64, 64),(1,) helped because all the elements of list should be Tuple type. However when it tries to run forward it cannot perform multiplication of tuple by tuple (because it is not possible in any python code).

You can change from Tuple to torch.Tensor summary(model,[torch.Tensor((3, 64, 64)),torch.Tensor((1,))])

Jubick
  • 402
  • 3
  • 15
  • Still not working with that modification. I get `TypeError: rand(): argument 'size' must be tuple of ints, but found element of type Tensor at pos 2`. It happens when summary tries to create an input using `x = [torch.rand(2, *in_size).type(dtype) for in_size in input_size]` which was the same line that got me into troubles when I used `(3, 64, 64),(1)`. – I.C. Oct 27 '22 at 16:28