generator seed fix for DDP mAP drop (#9545)

* Try to fix DDP mAP drop by setting generator's seed to RANK

* Fix default activation bug

* Update dataloaders.py

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update dataloaders.py

Co-authored-by: Glenn Jocher <glenn.jocher@ultralytics.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
authored and GitHub committed 2022-09-24 19:35:07 +02:00
1 parent c8e52304cf
commit f11a8a62d2
4 files changed
+11 -8

No files matched your search

+2 -2
View File
@@ -40,13 +40,13 @@ def autopad(k, p=None, d=1): # kernel, padding, dilation
class Conv(nn.Module):
# Standard convolution with args(ch_in, ch_out, kernel, stride, padding, groups, dilation, activation)
act = nn.SiLU() # default activation
default_act = nn.SiLU() # default activation
def __init__(self, c1, c2, k=1, s=1, p=None, g=1, d=1, act=True):
super().__init__()
self.conv = nn.Conv2d(c1, c2, k, s, autopad(k, p, d), groups=g, dilation=d, bias=False)
self.bn = nn.BatchNorm2d(c2)
self.act = self.act if act is True else act if isinstance(act, nn.Module) else nn.Identity()
self.act = self.default_act if act is True else act if isinstance(act, nn.Module) else nn.Identity()
def forward(self, x):
return self.act(self.bn(self.conv(x)))