Training a PINN network using custom training loop and weighted loss function

8 次查看(过去 30 天)
Hello MATLAB Community,
I have a doubt regarding the application of the minimax objective function optimization for the weighted loss minimization in the PINN framework. Suppose say I try to solve the Burger's equation using a PINN approach as outlined in this link. (https://in.mathworks.com/help/deeplearning/ug/solve-partial-differential-equations-with-lbfgs-method-and-deep-learning.html). How can i modify the code below in order to incorporate a weighted loss minimization framework using the minimax optimization.
I request the members of the community to kindly help me out on this regard as soon as possible. Please !!!!
The brief strategy for incorporated a weighted loss minimization is given in the attached images for your reference

回答(1 个)

Yash
Yash 2023-8-30
编辑:Yash 2023-9-1
Refer to the function "dlgradient" (https://www.mathworks.com/help/deeplearning/ref/dlarray.dlgradient.html) to compute derivatives ,, using automatic differentiation.
Define the objective function as given by the equation below to enforce Burger's equation and ensure that the numerical solution satisfies the conservation of momentum and conservation of mass.
J = Wu*MSEu + W0*MSE0 + Wb*MSEb + Wf*MSEf
Again, use the "dlgradient" function to calculate the gradients with respect to the learnable parameters ("theta", "Wu", "W0", "Wb", "Wf"). To update the learnable parameters as per the minimax optimization, employ the gradient descent/ascent procedure with the iterative updates given by:
theta_k+1 = theta_k - eta_k*gradient_J_theta
Wu_k+1 = Wu_k + eta_k_w*gradient_J_Wu
W0_k+1 = W0_k + eta_k_w*gradient_J_W0
Wb_k+1 = Wb_k + eta_k_w*gradient_J_Wb
Wf_k+1 = Wu_f + eta_k_w*gradient_J_Wf
Alternatively, refer to the function "fminimax" (https://www.mathworks.com/help/optim/ug/fminimax.html) to solve the minimax optimization at hand.
Hope this helps!
  1 个评论
Aakhash
Aakhash 2023-9-1
But how can I use the fminimax function inside the custom training loop where batch of data is being passed to the dlfeval function to compute the loss and using gradient optimisation the parameters are updated. It doesn’t make sense to put the fminimax function inside the training loop right?

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Image Data Workflows 的更多信息

产品


版本

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by