Hi

I would like to use torch.nn.MSELoss() to compute the average root mean squared error (aRMSE). Therefore I want to take the root of the MSE and AFTER that average the error.

My problem is, when I apply the MSEloss() to predictions/references with multiple features and multiple samples, it still only returns a single value. Is it possible to us MSEloss() to only average over one dimension?

Regards

You could set `nn.MSELoss(reduction='none')`

, so that `nn.MSELoss()`

will return the squared loss for each sample, and apply your root mean reduction yourself.

Thank you! I thought reduction= ‘none’ was the default, my mistake.

Follow up question: Should reduction = ‘mean’ not only average over all the samples? It instead averages over every input, resulting in an 1x1 output. In my opinion, the MSE should only average over all the samples and result in separate errors for every feature, e.g. in a multivariate regression problem. This feature does not seem to be implemented.

I agree, this is because in typical applications, the array is 1-dimensional for targets and predictions, I suppose. Usually, I do the averaging manually if I have multi-dims or just define my own MSE (only one line of code anyway).

That being said, the only real API annoyances in PyTorch I have are these loss-related things as they can easily trip you up (and things like naming inconsistencies like binary_cross_entropy expecting probabilities, but cross_entropy expecting logits).