Hi Arman!



 arman.avesta:

        self.conv = nn.Conv3d(channels, channels, kernel_size, stride, padding, groups=channels)

Please confirm that using “groups” is the right strategy to achieve my goal:


Yes, setting groups = channels will do what you want.
Let’s illustrate this with a simple case:
>>> import torch
>>> torch.__version__
'1.9.0'
>>> conv = torch.nn.Conv3d (3, 3, 1, groups = 3, bias = False)
>>> conv.weight[:, :, 0, 0, 0]
tensor([[-0.5339],
        [-0.6689],
        [-0.9413]], grad_fn=<SelectBackward>)
>>> conv (torch.tensor ([1.0, 0.0, 0.0]).reshape (1, 3, 1, 1, 1))
tensor([[[[[-0.5339]]],


         [[[ 0.0000]]],


         [[[ 0.0000]]]]], grad_fn=<MkldnnConvolutionBackward>)
>>> conv (torch.tensor ([0.0, 1.0, 0.0]).reshape (1, 3, 1, 1, 1))
tensor([[[[[ 0.0000]]],


         [[[-0.6689]]],


         [[[ 0.0000]]]]], grad_fn=<MkldnnConvolutionBackward>)
>>> conv (torch.tensor ([0.0, 0.0, 1.0]).reshape (1, 3, 1, 1, 1))
tensor([[[[[ 0.0000]]],


         [[[ 0.0000]]],


         [[[-0.9413]]]]], grad_fn=<MkldnnConvolutionBackward>)

Best.
K. Frank