# Calculating MSE and MAE

**URL:** <https://discuss.pytorch.org/t/calculating-mse-and-mae/92632>\
**Category:** Uncategorized\
**Created:** [August 13, 2020, 5:29am UTC](https://discuss.pytorch.org/t/calculating-mse-and-mae/92632 "2020-08-13T05:29:51Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![alameer](https://discuss.pytorch.org/letter_avatar_proxy/v4/letter/a/9dc877/32.png) [@alameer](https://discuss.pytorch.org/u/alameer)\
**Post date:** [August 13, 2020, 5:29am UTC](https://discuss.pytorch.org/t/calculating-mse-and-mae/92632/1 "2020-08-13T05:29:51Z")

</div>

Hi

I would like to calculate the MSE and MAE for a PyTorch model. How do I go about doing this? Are there functions already available to do this, please? Many thanks in advance

---

<div class="post-metadata">

**Author:** ![mariosasko](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/mariosasko/32/27520_2.png) [@mariosasko](https://discuss.pytorch.org/u/mariosasko)\
**Post date:** [August 13, 2020, 11:09am UTC](https://discuss.pytorch.org/t/calculating-mse-and-mae/92632/2 "2020-08-13T11:09:16Z")

</div>

Yes, they are already implemented in Pytorch. Use `nn.MSELoss` and `nn.L1Loss` respectively.

---

<div class="post-metadata">

**Author:** ![alameer](https://discuss.pytorch.org/letter_avatar_proxy/v4/letter/a/9dc877/32.png) [@alameer](https://discuss.pytorch.org/u/alameer)\
**Post date:** [August 13, 2020, 6:20pm UTC](https://discuss.pytorch.org/t/calculating-mse-and-mae/92632/3 "2020-08-13T18:20:21Z")

</div>

Thanks a lot @mariosasko
