This definition:
self.blocks = nn.Sequential(
*[ResidualBlock(in_channels, out_channels, kernel_size, l2_lambda=l2_lambda) for _ in range(num_blocks)]
)
won’t work for multiple ResidualBlock
s since each of these will expect an input with in_channels
channels while the previous one will return an activation with out_channels
.
You could fix it e.g. via:
self.blocks = nn.Sequential(
ResidualBlock(in_channels, out_channels, kernel_size, l2_lambda=l2_lambda),
*[ResidualBlock(out_channels, out_channels, kernel_size, l2_lambda=l2_lambda) for _ in range(num_blocks-1)]
)
but would need to double check if the “internal” ResidualBlock
s should use out_channels
for their input and output.