Neural ODE for dynamic systems with input signals

조회 수: 21 (최근 30일)
Bowei Li
Bowei Li 2022년 1월 24일
편집: Sergio 2025년 4월 29일
Hi! Community!
Mathworks provided a nice example here for modeling dynamic systems through neural ODE.
Is it possible to consider input signals in training? That is, to define the differential equation to be:
where is the input signal.
However, dlode45 will not allow the ODE function to be with more than three inputs.
So is there any other possible approach to incorporate the input signal?
Thanks a lot!

채택된 답변

Ben
Ben 2022년 1월 25일
Hi Bowei,
You should be able to create a new ODE function that has only three inputs as required. Let me show a few cases.
Case 1 -
In this case you can define . Assuming you have f as a function handle you can define g in code with:
g = @(t,x,theta) f(t,x,theta,e(t))
Then solve using g in dlode45.
Case 2 -
This is a special case of case 1:
g = @(t,x,theta) f(t,x,theta) + e(t)
Call dlode45 with g.
Case 3 - for
In this case you have an extra hyperparameter i which you just have to select a specific value for. For example let and . You could write this in code as:
e = @(t,i) cos(i*t);
f = @(t,x,A,i) A*x + e(t,i);
x0 = dlarray(randn());
tspan = [0,1];
A = dlarray(randn());
i = 3;
x = dlode45(@(t,x,A) f(t,x,A,i), tspan, x0, A, DataFormat="CB");
Note that in this case you can loop over the values you want for i.
Hope that helps,
Ben
  댓글 수: 7
Sergio
Sergio 2024년 12월 11일
Thanks @Ben! It helps :)
Sergio
Sergio 2025년 4월 29일
편집: Sergio 2025년 4월 29일
Hi again @Ben,
After reading your suggestions regarding the application of neuralODELayer with external input signals I created a custom layer to work with multiple input signals. The approach I followed works when the inputs signals are not splited into minibatches manually like the variable targets in the example you provided
for i = 1:numObs
targets{i} = xTrain(:,i + (1:neuralOdeTimesteps));
end
If I split the input signals in a similar fashion, the script does not run. I posted a new question here providing more details.
The question I have is if splitting the targets and the input signals manually (like in your example) should do the same as setting the minibatches within trainingOptions before using the trainnet function to train the model.
I appreciate your help in advance
Sergio

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

David Willingham
David Willingham 2022년 1월 24일
Hi Bowei,
Thanks for the feedback on our neural ode example! For your request, can you elloborate on what type of signal e(t) might be and what use cases you're looking to apply neural ode's to?
David
  댓글 수: 1
Bowei Li
Bowei Li 2022년 1월 25일
편집: Bowei Li 2022년 1월 25일
Thanks David!
I was thinking about training neural ode for predicting states of dynamic systems given some arbitrary input signals, such as:
where is the system state vector, a function of time t; the input signal is also a function of time t.
For example, can be like or or a random process .
The example here corresponding to the case of and training a neural ode for a set of initial conditions.
Is it possible to train a neural ode for a fixed initial condition, but for a set of input signals .

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Deep Learning Toolbox에 대해 자세히 알아보기

제품


릴리스

R2021b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by