Pytorch-PCGrad icon indicating copy to clipboard operation
Pytorch-PCGrad copied to clipboard

reduction is always 'mean'

Open tkbadamdorj opened this issue 3 years ago • 1 comments

Setting reduction = 'sum' does not work because of this line:

if self._reduction:
    merged_grad[shared] = torch.stack([g[shared]
                                   for g in pc_grad]).mean(dim=0)

because if reduction is a string, self._reduction is always True

tkbadamdorj avatar Jan 20 '22 20:01 tkbadamdorj

See the forked version here with the issue corrected:

https://github.com/anzeyimana/Pytorch-PCGrad-GradVac-AMP-GradAccum

anzeyimana avatar Jun 19 '22 08:06 anzeyimana