ThummeTo / FMIExport.jl

FMIExport.jl is a free-to-use software library for the Julia programming language which allows for the export of FMUs (fmi-standard.org) from any Julia-Code. FMIExport.jl is completely integrated into FMI.jl.
MIT License
22 stars 3 forks source link

Exporting a trained neural network as an FMU #42

Closed SriRama29 closed 5 months ago

SriRama29 commented 5 months ago

Hi, Let us assume I have the parameters of a neural network that I have trained using the neural ODE framework. Is it possible for me to use this package to export it as an FMU?

I have spent some time trying to understand the examples. I think the NeuralFMU example is more complicated than what I need. I think I might need to make my code from a mix of the bouncing ball example and the neural FMU example.

I have not yet figured out how I would load the parameters into the code and export it as an FMU. (Any advice is appreciated!)

But before I attempt to work further on it, I wanted to verify if I can even accomplish my requirement with the package 😄

Looking forward to your response!

ThummeTo commented 5 months ago

Hi,

short answer: you can use this lib to export your neural ODE as FMU!

longer answer: As proposed, I would start with the bouncing ball example. A neural ODE is nothing but a neural network that is interpreted as right-hand side of an ODE, that gets solved by a numerical ODE solver. So to export this as FMU, you just need to define your function f that maps state x to state derivative dx, this is just your NN inference. For the bouncing ball its the second order ODE for a mass that is accelerated by gravity (so the most simple system existing). The more advanced things for discontinuous systems (event indicators, condition and affect) you can skip for your (I think continuous) neural ODE. So to conclude, replacing the f and setting the remaining functions to neutral should do the trick.

Best regards!

Remark: We should make a tutorial for this, because this is not the first time I get ask this :-)