# Use multiple output neural network in NeuralPDE

**URL:** https://discourse.julialang.org/t/use-multiple-output-neural-network-in-neuralpde/117225
**Category:** General Usage
**Created:** [July 19, 2024, 9:42am UTC](https://discourse.julialang.org/t/use-multiple-output-neural-network-in-neuralpde/117225 "2024-07-19T09:42:11Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![gradureau](https://avatars.discourse-cdn.com/v4/letter/g/67e7ee/32.png) [@gradureau](https://discourse.julialang.org/u/gradureau)
#### Post date: [July 19, 2024, 9:42am UTC](https://discourse.julialang.org/t/use-multiple-output-neural-network-in-neuralpde/117225/1 "2024-07-19T09:42:11Z")

</div>

Hey everyone,

I am trying out neural PDE to solve Euler’s equations in 1D. In my problem, I have two inputs : t and x, and I have three outputs : density ρ, velocity v and pressure p. Here are the equations:

\partial\_t \rho + \rho~\partial\_x v + v~\partial\_x \rho = 0  
\partial\_t v + v~\partial\_x v + \partial\_x p / \rho = 0  
\partial\_t p + v~\partial\_x p + \gamma p~\partial\_x v = 0

I have noticed that in NeuralPDE, you always use neural networks with one output, so in this problem, I would need to train three different neural networks for each of my output quantities. Is it possible to use only one neural network with three outputs in NeuralPDE?

Thank you for yout answers!

---

<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 23, 2024, 9:06pm UTC](https://discourse.julialang.org/t/use-multiple-output-neural-network-in-neuralpde/117225/2 "2024-07-23T21:06:50Z")

</div>

This is a missing optimization. Using a single neural network is a lot slower if you have one equation which needs a higher derivative in one variable, which is very common for example to diffuse in one set but have other sets be algebraic. However, there are a few cases that could specialize on having all the same derivatives, like Euler’s equations. We are planning to allow for this optimization in the near future with the new parser, and that’s scheduled to finish before the end of this year.

---

<div class="post-metadata">

### Author: ![gradureau](https://avatars.discourse-cdn.com/v4/letter/g/67e7ee/32.png) [@gradureau](https://discourse.julialang.org/u/gradureau)
#### Post date: [July 29, 2024, 8:39am UTC](https://discourse.julialang.org/t/use-multiple-output-neural-network-in-neuralpde/117225/3 "2024-07-29T08:39:41Z")

</div>

Perfect, thank you for your answer!
