# Modified loss function in NeuralPDE

**URL:** https://discourse.julialang.org/t/modified-loss-function-in-neuralpde/101624
**Category:** General Usage
**Tags:** question, neural-network
**Created:** [July 14, 2023, 1:18pm UTC](https://discourse.julialang.org/t/modified-loss-function-in-neuralpde/101624 "2023-07-14T13:18:29Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Ethan\_Tran](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ethan_tran/32/49198_2.png) [@Ethan\_Tran](https://discourse.julialang.org/u/Ethan_Tran)
#### Post date: [July 14, 2023, 1:18pm UTC](https://discourse.julialang.org/t/modified-loss-function-in-neuralpde/101624/1 "2023-07-14T13:18:29Z")

</div>

Is it possible to modify the loss function in PINNs? like instead of loss function of variables, may I modify it to loss of sin or cos of variables?

---

<div class="post-metadata">

### Author: ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)
#### Post date: [July 14, 2023, 8:38pm UTC](https://discourse.julialang.org/t/modified-loss-function-in-neuralpde/101624/2 "2023-07-14T20:38:27Z")

</div>

See the `additional_loss` function. Unless you mean something different?

---

<div class="post-metadata">

### Author: ![Ethan\_Tran](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ethan_tran/32/49198_2.png) [@Ethan\_Tran](https://discourse.julialang.org/u/Ethan_Tran)
#### Post date: [July 14, 2023, 8:49pm UTC](https://discourse.julialang.org/t/modified-loss-function-in-neuralpde/101624/3 "2023-07-14T20:49:31Z")

</div>

I saw that the `additional_loss` function just have the syntax that `additional_loss(phi, θ, p)`. The problem’s variables include the phase angle, and there are the functions of sin and cos of them. If I use `additional_loss(phi, θ, p)` the network could estimate the loss by sin or cos of phase angle or do I need to implement the specific function at the argument of `additional_loss`?

---

<div class="post-metadata">

### Author: ![Ethan\_Tran](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ethan_tran/32/49198_2.png) [@Ethan\_Tran](https://discourse.julialang.org/u/Ethan_Tran)
#### Post date: [July 14, 2023, 9:54pm UTC](https://discourse.julialang.org/t/modified-loss-function-in-neuralpde/101624/4 "2023-07-14T21:54:54Z")

</div>

The tutorial has the information for the adaptive loss function, so there are any functions for `additional_loss` or do I need to define the new function for `additional_loss`?

---

<div class="post-metadata">

### Author: ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)
#### Post date: [July 15, 2023, 5:19pm UTC](https://discourse.julialang.org/t/modified-loss-function-in-neuralpde/101624/5 "2023-07-15T17:19:58Z")

</div>

> [@Ethan\_Tran](#):
>
> so there are any functions for `additional_loss` or do I need to define the new function for `additional_loss`?

You just define a new function. It can be any differentiable Julia function.
