# How to get weight and bias from the NeuralPDE after solving

**URL:** https://discourse.julialang.org/t/how-to-get-weight-and-bias-from-the-neuralpde-after-solving/100481
**Category:** General Usage
**Tags:** question, neural-network
**Created:** [June 17, 2023, 2:08am UTC](https://discourse.julialang.org/t/how-to-get-weight-and-bias-from-the-neuralpde-after-solving/100481 "2023-06-17T02:08:06Z")
**Posts on this page:** 6
**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: [June 17, 2023, 2:08am UTC](https://discourse.julialang.org/t/how-to-get-weight-and-bias-from-the-neuralpde-after-solving/100481/1 "2023-06-17T02:08:06Z")

</div>

I try to use NeuralPDE to solve the differential equations.  
How could I get the weight and bias from network and may I use the weight after solving to predict the similar problem?  
Thank you all.

---

<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: [June 17, 2023, 1:56pm UTC](https://discourse.julialang.org/t/how-to-get-weight-and-bias-from-the-neuralpde-after-solving/100481/2 "2023-06-17T13:56:31Z")

</div>

It’s the OptimizationSolution, `res.u`, as shown in the tutorial. See for example:

[https://docs.sciml.ai/NeuralPDE/dev/tutorials/pdesystem/#Copy-Pasteable-Code](https://docs.sciml.ai/NeuralPDE/dev/tutorials/pdesystem/#Copy-Pasteable-Code)

---

<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: [June 17, 2023, 2:11pm UTC](https://discourse.julialang.org/t/how-to-get-weight-and-bias-from-the-neuralpde-after-solving/100481/3 "2023-06-17T14:11:26Z")

</div>

The tutorial does not mention on how could we saving the weight and reuse it to predict the solution for the similar system. Do you have any experiences about saving and reusing the training network?

---

<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: [June 17, 2023, 2:25pm UTC](https://discourse.julialang.org/t/how-to-get-weight-and-bias-from-the-neuralpde-after-solving/100481/4 "2023-06-17T14:25:32Z")

</div>

You can save it any way you’d save an array, JLD2 or whatever. It reuses it for predictions in the plots in the tutorial.

---

<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: [June 17, 2023, 4:09pm UTC](https://discourse.julialang.org/t/how-to-get-weight-and-bias-from-the-neuralpde-after-solving/100481/5 "2023-06-17T16:09:07Z")

</div>

The tutorial just create new chains with random weight and zero bias. For the plotting phase, it also use the weight after training to predict the values of variables. However, I would like to ask the method to load the pretrained weight into the chains and predict the new values.

---

<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: [June 17, 2023, 11:52pm UTC](https://discourse.julialang.org/t/how-to-get-weight-and-bias-from-the-neuralpde-after-solving/100481/6 "2023-06-17T23:52:57Z")

</div>

> [@Ethan\_Tran](#):
>
> However, I would like to ask the method to load the pretrained weight into the chains and predict the new values.

The construction takes an argument init\_params to pass in previously trained network parameters. See

[https://neuralpde.sciml.ai/stable/manual/pinns/#NeuralPDE.PhysicsInformedNN](https://neuralpde.sciml.ai/stable/manual/pinns/#NeuralPDE.PhysicsInformedNN)
