Skip to content

TypeError: SequentialWithIdx.forward() missing 1 required positional argument: 'indices'" #7475

Closed

Description

@KumoLiu

Describe the bug
Quicknat not work as expected.

To Reproduce

from monai.networks.nets import Quicknat
import torch

model = Quicknat(
            num_classes=1,
            num_channels=1,
            num_filters=64,
            se_block=None
        ).to("cuda:0")
data = torch.rand((1, 1, 32, 32)).to("cuda:0")

out = model(data)
Error Log

{
	"name": "TypeError",
	"message": "SequentialWithIdx.forward() missing 1 required positional argument: 'indices'",
	"stack": "---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In[2], line 14
      5 model = Quicknat(
      6             num_classes=1,
      7             num_channels=1,
   (...)
     10             se_block=None
     11         ).to(\"cuda:0\")
     12 data = torch.rand((1, 1, 32, 32)).to(\"cuda:0\")
---> 14 out = model(data)
     17 # export
     18 # convert_to_onnx(model, dataloader, filename='quicknat.onnx', verify=True, use_ort=True)

File /usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py:1511, in Module._wrapped_call_impl(self, *args, **kwargs)
   1509     return self._compiled_call_impl(*args, **kwargs)  # type: ignore[misc]
   1510 else:
-> 1511     return self._call_impl(*args, **kwargs)

File /usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py:1520, in Module._call_impl(self, *args, **kwargs)
   1515 # If we don't have any hooks, we want to skip the rest of the logic in
   1516 # this function, and just call forward.
   1517 if not (self._backward_hooks or self._backward_pre_hooks or self._forward_hooks or self._forward_pre_hooks
   1518         or _global_backward_pre_hooks or _global_backward_hooks
   1519         or _global_forward_hooks or _global_forward_pre_hooks):
-> 1520     return forward_call(*args, **kwargs)
   1522 try:
   1523     result = None

File /workspace/MONAI/monai/networks/nets/quicknat.py:438, in Quicknat.forward(self, input)
    437 def forward(self, input: torch.Tensor) -> torch.Tensor:
--> 438     input, _ = self.model(input, None)
    439     return input

File /usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py:1511, in Module._wrapped_call_impl(self, *args, **kwargs)
   1509     return self._compiled_call_impl(*args, **kwargs)  # type: ignore[misc]
   1510 else:
-> 1511     return self._call_impl(*args, **kwargs)

File /usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py:1520, in Module._call_impl(self, *args, **kwargs)
   1515 # If we don't have any hooks, we want to skip the rest of the logic in
   1516 # this function, and just call forward.
   1517 if not (self._backward_hooks or self._backward_pre_hooks or self._forward_hooks or self._forward_pre_hooks
   1518         or _global_backward_pre_hooks or _global_backward_hooks
   1519         or _global_forward_hooks or _global_forward_pre_hooks):
-> 1520     return forward_call(*args, **kwargs)
   1522 try:
   1523     result = None

File /workspace/MONAI/monai/networks/nets/quicknat.py:62, in SequentialWithIdx.forward(self, input, indices)
     60 def forward(self, input, indices):
     61     for module in self:
---> 62         input, indices = module(input, indices)
     63     return input, indices

File /usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py:1511, in Module._wrapped_call_impl(self, *args, **kwargs)
   1509     return self._compiled_call_impl(*args, **kwargs)  # type: ignore[misc]
   1510 else:
-> 1511     return self._call_impl(*args, **kwargs)

File /usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py:1520, in Module._call_impl(self, *args, **kwargs)
   1515 # If we don't have any hooks, we want to skip the rest of the logic in
   1516 # this function, and just call forward.
   1517 if not (self._backward_hooks or self._backward_pre_hooks or self._forward_hooks or self._forward_pre_hooks
   1518         or _global_backward_pre_hooks or _global_backward_hooks
   1519         or _global_forward_hooks or _global_forward_pre_hooks):
-> 1520     return forward_call(*args, **kwargs)
   1522 try:
   1523     result = None

File /workspace/MONAI/monai/networks/nets/quicknat.py:46, in SkipConnectionWithIdx.forward(self, input, indices)
     45 def forward(self, input, indices):
---> 46     return super().forward(input), indices

File /workspace/MONAI/monai/networks/layers/simplelayers.py:129, in SkipConnection.forward(self, x)
    128 def forward(self, x: torch.Tensor) -> torch.Tensor:
--> 129     y = self.submodule(x)
    131     if self.mode == \"cat\":
    132         return torch.cat([x, y], dim=self.dim)

File /usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py:1511, in Module._wrapped_call_impl(self, *args, **kwargs)
   1509     return self._compiled_call_impl(*args, **kwargs)  # type: ignore[misc]
   1510 else:
-> 1511     return self._call_impl(*args, **kwargs)

File /usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py:1520, in Module._call_impl(self, *args, **kwargs)
   1515 # If we don't have any hooks, we want to skip the rest of the logic in
   1516 # this function, and just call forward.
   1517 if not (self._backward_hooks or self._backward_pre_hooks or self._forward_hooks or self._forward_pre_hooks
   1518         or _global_backward_pre_hooks or _global_backward_hooks
   1519         or _global_forward_hooks or _global_forward_pre_hooks):
-> 1520     return forward_call(*args, **kwargs)
   1522 try:
   1523     result = None

TypeError: SequentialWithIdx.forward() missing 1 required positional argument: 'indices'"
}

Quicknat is introduced by this PR.
Looks like the unit tests are always not tested since squeeze_and_excitation is not a required dependency.

@unittest.skipUnless(has_se, "squeeze_and_excitation not installed")

Activity

  1. KumoLiu commented on Feb 19, 2024

    @KumoLiu
    ContributorAuthor

    Hi @vgonzalezd, @Al3xand1a, and @ge96lip, could you please help take a look at this issue?
    Thanks in advance!

  2. jkosek commented on Apr 14, 2025

    @jkosek

    Do we have any progress or fix for this issue?

  3. added a commit that references this issue on Sep 9, 2026
    453688a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions