# Crash during training: paramter logits has invalid values

**URL:** <https://discuss.ray.io/t/crash-during-training-paramter-logits-has-invalid-values/3131>\
**Category:** Uncategorized\
**Created:** [August 4, 2021, 3:29pm UTC](https://discuss.ray.io/t/crash-during-training-paramter-logits-has-invalid-values/3131 "2021-08-04T15:29:10Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![Sertingolix](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/sertingolix/32/649_2.png) [@Sertingolix](https://discuss.ray.io/u/Sertingolix)\
**Post date:** [August 9, 2021, 7:13am UTC](https://discuss.ray.io/t/crash-during-training-paramter-logits-has-invalid-values/3131/4 "2021-08-09T07:13:48Z")

</div>

You could use something like this for your custom model:

> [@RNN L2 weights regularization](https://discuss.ray.io/t/rnn-l2-weights-regularization/2582/2):
>
> You can get L2 loss with the custom loss API as follows. @override(ModelV2) def custom\_loss(self, policy\_loss, loss\_inputs): l2\_lambda = 0.01 l2\_reg = torch.tensor(0.) for param in self.parameters(): l2\_reg += torch.norm(param) self.l2\_loss = l2\_lambda \* l2\_reg assert self.l2\_loss.requires\_grad, "l2 loss no gradient" custom\_loss = self.l2\_loss # depending on input add los…

I hope that helps.

---

_[View the full topic](https://discuss.ray.io/t/crash-during-training-paramter-logits-has-invalid-values/3131)._
