# How can I training one function at the time with NeuralPDE?

**URL:** <https://discourse.julialang.org/t/how-can-i-training-one-function-at-the-time-with-neuralpde/103398>\
**Category:** Modelling & Simulations\
**Tags:** question\
**Created:** [August 31, 2023, 9:21am UTC](https://discourse.julialang.org/t/how-can-i-training-one-function-at-the-time-with-neuralpde/103398 "2023-08-31T09:21:16Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Knud\_Sorensen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/knud_sorensen/32/52401_2.png) [@Knud\_Sorensen](https://discourse.julialang.org/u/Knud_Sorensen)\
**Post date:** [August 31, 2023, 9:21am UTC](https://discourse.julialang.org/t/how-can-i-training-one-function-at-the-time-with-neuralpde/103398/1 "2023-08-31T09:21:16Z")

</div>

If you have 2 or more functions as Neural nets, say f and g.  
And they are coupled by a differential equation.  
And we already idea how f should look like say we have a mock function f\_m for f  
How would I?

1. Train f to f\_m.
2. Solve/optimize the PDE for g, without updating f.
3. Then solve/optimize the PDE for f, without updating g.

---

<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:** [August 31, 2023, 11:40am UTC](https://discourse.julialang.org/t/how-can-i-training-one-function-at-the-time-with-neuralpde/103398/2 "2023-08-31T11:40:41Z")

</div>

It always trains them both at the same time right now. This would require changes to the package (which would be interesting to explore).

---

<div class="post-metadata">

**Author:** ![Knud\_Sorensen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/knud_sorensen/32/52401_2.png) [@Knud\_Sorensen](https://discourse.julialang.org/u/Knud_Sorensen)\
**Post date:** [August 31, 2023, 12:19pm UTC](https://discourse.julialang.org/t/how-can-i-training-one-function-at-the-time-with-neuralpde/103398/3 "2023-08-31T12:19:13Z")

</div>

For step 1 ? If I want to train f to f\_m over a Domain D, Is there any function that let me do that easy ?  
Naturally, it can be done by calculating f\_m on a discretization of D and the train on that data. I was just wondering if there was an easier way, as discretization suffer from the curse of dimensionality,

---

<div class="post-metadata">

**Author:** ![xtalax](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/xtalax/32/35293_2.png) [@xtalax](https://discourse.julialang.org/u/xtalax)\
**Post date:** [September 12, 2023, 6:32pm UTC](https://discourse.julialang.org/t/how-can-i-training-one-function-at-the-time-with-neuralpde/103398/4 "2023-09-12T18:32:25Z")

</div>

I would try splitting your system in to 2 with a registered interpolation providing the value of f to the first, which solves for g, then wrap the solution in a registered function and use it as the definition of g in the second.

Finding a good initialisation for f will be important here, perhaps you can run this scheme recursively starting from a random initialisation, but a different low order approximation would be better
