torch / nn

Other
1.34k stars 968 forks source link

Why gradInput of nn.Mul is computed by gradOutput add by weight rather than multiply by weight? #1315

Closed ChunyanZhao closed 6 years ago

ChunyanZhao commented 6 years ago

I am confused by the function, and I think that the gradInput should be computed by gradInput = self.weight[1] * gradOutput rather than gradInput = self.weight[1] + gradOutput. https://github.com/torch/nn/blob/872682558c48ee661ebff693aa5a41fcdefa7873/Mul.lua#L29-L34