LibCity / Bigscity-LibCity

LibCity: An Open Library for Urban Spatial-temporal Data Mining
https://libcity.ai/
Apache License 2.0
871 stars 159 forks source link

weighted sum in masked loss #416

Open nehSgnaiL opened 2 months ago

nehSgnaiL commented 2 months ago

Hi,

Thanks for the remarkable work.

I would like to know more about the operations in defined loss. Since the mask has been normalized by mask /= torch.mean(mask), should we use the sum operation torch.sum(loss) rather than the mean operation torch.mean(loss) in returning loss?

https://github.com/LibCity/Bigscity-LibCity/blob/38ff38353ea71045b69260bb2e6875cb0abf95ad/libcity/model/loss.py#L75-L87

I am not sure what I understand is right due to my limited knowledge. If you could respond, that would be greatly appreciated.

nehSgnaiL commented 2 months ago

The codes mask /= torch.mean(mask) and return torch.mean(loss) work properly. The outcome appears to be correct, but I find it difficult to read.