Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when trying to parse the encoder output to the decoder #977

Open
mvp-aadesh opened this issue Nov 14, 2024 · 1 comment
Open

Error when trying to parse the encoder output to the decoder #977

mvp-aadesh opened this issue Nov 14, 2024 · 1 comment

Comments

@mvp-aadesh
Copy link

Hello,

I am trying to remove the segmentation head and add some more layers before adding segmentation head to my model.
But whenever I pass my encoder output to the decoder I keep getting this Error
My encoder output is a list.
Please let me know what am I missing here.
Error msg:

TypeError                                 Traceback (most recent call last)
[<ipython-input-90-ce779b144a7b>](https://localhost:8080/#) in <cell line: 5>()
      3 sample_input = torch.randn(2, 3, 640, 640).to(device, dtype = torch.float32) / 128.0 - 1.0
      4 y = model.encoder(sample_input)
----> 5 model.decoder(y)

15 frames
[/usr/local/lib/python3.10/dist-packages/torch/nn/modules/conv.py](https://localhost:8080/#) in _conv_forward(self, input, weight, bias)
    547                 self.groups,
    548             )
--> 549         return F.conv2d(
    550             input, weight, bias, self.stride, self.padding, self.dilation, self.groups
    551         )

TypeError: conv2d() received an invalid combination of arguments - got (list, Parameter, NoneType, tuple, tuple, tuple, int), but expected one of:
 * (Tensor input, Tensor weight, Tensor bias = None, tuple of ints stride = 1, tuple of ints padding = 0, tuple of ints dilation = 1, int groups = 1)
      didn't match because some of the arguments have invalid types: (!list of [Tensor, Tensor, Tensor, Tensor, Tensor, Tensor]!, !Parameter!, !NoneType!, !tuple of (int, int)!, !tuple of (int, int)!, !tuple of (int, int)!, !int!)
 * (Tensor input, Tensor weight, Tensor bias = None, tuple of ints stride = 1, str padding = "valid", tuple of ints dilation = 1, int groups = 1)
      didn't match because some of the arguments have invalid types: (!list of [Tensor, Tensor, Tensor, Tensor, Tensor, Tensor]!, !Parameter!, !NoneType!, !tuple of (int, int)!, !tuple of (int, int)!, !tuple of (int, int)!, !int!)

This is my code:

device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
model = smp.DeepLabV3Plus(encoder_name='timm-mobilenetv3_large_075', encoder_weights='imagenet').to(device)
sample_input = torch.randn(2, 3, 640, 640).to(device, dtype = torch.float32) / 128.0 - 1.0
y = model.encoder(sample_input)
model.decoder(y) 
@qubvel
Copy link
Collaborator

qubvel commented Nov 14, 2024

Hey @mvp-aadesh , you should unpack the list to make it work (add a star to y)

...
model.decoder(*y)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants