Hi Marc!



 mmitjans:

conv_layer = Conv2d(3,3,(1,5),groups=3)
print(torch.allclose(out1,out2))
> False



Your understanding of groups does seem to be correct.  However,
in your test you’ve overlooked Conv2d's bias.
You can either turn bias off (bias = False) or copy bias over
from conv1 to conv2, along with weight:
>>> import torch
>>> import torch.nn as nn
>>>
>>> I = torch.randn(10,3,4,5)
>>>
>>> conv1 = nn.Conv2d(3,3,(1,5),groups=3)
>>> conv2 = nn.Conv2d(1,1,(1,5),groups=1)
>>>
>>> with torch.no_grad():
...     conv2.weight.copy_(conv1.weight[0:1])
...
Parameter containing:
tensor([[[[-0.3698,  0.0243,  0.3121,  0.0644,  0.2732]]]], requires_grad=True)
>>> out1 = conv1(I)[0,0,...]
>>> out2 = conv2(I[:,0:1,...])[0,0,...]
>>>
>>> print(torch.allclose(out1,out2))
False
>>>
>>> with torch.no_grad():
...      conv2.bias.copy_ (conv1.bias[0])
...
Parameter containing:
tensor([0.1049], requires_grad=True)
>>> out1 = conv1(I)[0,0,...]
>>> out2 = conv2(I[:,0:1,...])[0,0,...]
>>>
>>> print(torch.allclose(out1,out2))
True

Best.
K. Frank