I’m trying to generate a network with sequential blocks and multiple inputs(images) using nn.Sequential(*layer). As I knew, nn.Sequential cannot handle multiple inputs.
In the post nn.Sequential(*layers) forward: with multiple inputs Error, they said that multiple inputs can be passed to nn.Sequential(*layer) using the dictionary, but it’s not working in my code below.
class BlkGenerator(nn.Module):
def __init__(self, block, num_filter, num_blocks, growh_rate):
super(BlkGenerator, self).__init__()
self.block = self.BlockGenerator(block, num_filter, num_blocks, growh_rate)
def BlockGenerator(self, block, num_filter, num_blocks, growh_rate):
blocks = []
for i in range(num_blocks):
dblk = block(num_filter * growh_rate, kernel_size=8, stride=4, padding=2)
blocks.append(dblk)
return nn.Sequential(*blocks)
def forward(self, x1, x2):
return self.block(x1, x2)
I passed two input images to a network using the dictionary
output = model_4ch({0:input2, 1:input2})
but, it gives an error below
File "C:\Users\shyu\Anaconda3\envs\pytorch\lib\site-packages\torch\nn\modules\module.py", line 477, in __call__
result = self.forward(*input, **kwargs)
TypeError: forward() missing 1 required positional argument: 'x2'
How can I solve this problem?
Thanks in advance.