In this code I am trying to predict u(x,t)= NN(\theta) so that after I predict this I can use the neural network to solve PINN problems. However, I’m not able to train the model and reduce the loss function.
import Flux, DifferentialEquations, Plots, DiffEqFlux using Flux, DifferentialEquations, Plots, DiffEqFlux x=0:0.01:1 y=sin.(2*pi*x); # actual Data # initializing random parameters W1=rand(10,1) b1=rand(10) W2=rand(5,10) b2=rand(5) W3=rand(1,5) b3=rand(1) # Defining Layers L1(x)=σ.(W1*x+b1) L2(x)=σ.(W2*x+b2) L3(x)=σ.(W3*x+b3) # predicting the outcome predict(x)=L3(L2(L1(x))); yp=[predict.(i) for i in x] # stores all the values in yp of individual vector matrices yp1=mapreduce(vec,vcat,yp); # this converts vector matrices of 1*1 to n*1 size # loss function function loss_p() loss= sum(abs2,yp1.-y) return loss end loss_p() # now we train our loss function data= Iterators.repeated((),200) opt=ADAM(0.1) Flux.train!(loss_p,params(predict()),data,opt)
Furthermore, Instead If ,I use the commands in julia i.e
example: m=chain(dense(…)), will I be able to differentiate wrt x and t to solve 1D convection equation using PINN? Please help me out to solve the problem using the approach that I have used, and suggestions would help the most.