Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

better BPINN formulation, improvements to include dataset domain points #842

Open
wants to merge 60 commits into
base: master
Choose a base branch
from

Conversation

AstitvaAggarwal
Copy link
Contributor

@AstitvaAggarwal AstitvaAggarwal commented Mar 29, 2024

Checklist

  • Appropriate tests were added
  • Any code changes were done in a way that does not break public API
  • All documentation related to code changes were updated
  • The new code follows the
    contributor guidelines, in particular the SciML Style Guide and
    COLPRAC.
  • Any new documentation only uses public API

Additional context

will add docs and more tests separately

@AstitvaAggarwal
Copy link
Contributor Author

AstitvaAggarwal commented Mar 29, 2024

@Vaibhavdixit02 @ChrisRackauckas this is the new PR, closed the previous one due to large number of merge conflicts after the repo was recently majorly formatted. Discussions from previous PR: #799

Comment on lines 75 to 91
# if length(Tar.prob.u0) == 1
# nnsol = [f(û[i],
# Tar.prob.p,
# t[i])
# for i in 1:length(û[:, 1])]
# else
# nnsol = [f([û[i], u1[i]],
# Tar.prob.p,
# t[i])
# for i in 1:length(û[:, 1])]
# end
# form of NN output matrix output dim x n
# nnsol = reduce(hcat, nnsol)

# > Instead of dataset gradients trying NN derivatives with dataset collocation
# # convert to matrix as nnsol

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these long comments should get cleaned up

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay

Comment on lines 107 to 130
# PDE(DU,U,P,T)=0

# Derivated via Central Diff
# function calculate_derivatives2(dataset)
# x̂, time = dataset
# num_points = length(x̂)
# # Initialize an array to store the derivative values.
# derivatives = similar(x̂)

# for i in 2:(num_points - 1)
# # Calculate the first-order derivative using central differences.
# Δt_forward = time[i + 1] - time[i]
# Δt_backward = time[i] - time[i - 1]

# derivative = (x̂[i + 1] - x̂[i - 1]) / (Δt_forward + Δt_backward)

# derivatives[i] = derivative
# end

# # Derivatives at the endpoints can be calculated using forward or backward differences.
# derivatives[1] = (x̂[2] - x̂[1]) / (time[2] - time[1])
# derivatives[end] = (x̂[end] - x̂[end - 1]) / (time[end] - time[end - 1])
# return derivatives
# end
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's this all about?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

initially wrote this for testing, while figuring out which kind of derivative is to be used in new loss. the above was the case where the derivative was datapoint interpolation derivatives via central diff.

Comment on lines 151 to 162
# A1 = (prob.u0' .+
# (prob.tspan[2] .- (dataset[end]' .+ sqrt(eps(eltype(Float64)))))' .*
# chainflux(dataset[end]' .+ sqrt(eps(eltype(Float64))))')

# A2 = (prob.u0' .+
# (prob.tspan[2] .- (dataset[end]'))' .*
# chainflux(dataset[end]')')

A1 = chainflux(dataset[end]' .+ sqrt(eps(eltype(dataset[end][1]))))
A2 = chainflux(dataset[end]')

gradients = (A2 .- A1) ./ sqrt(eps(eltype(dataset[end][1])))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You shouldn't use this for gradients?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not anymore, i wrote this for it to work for a specific case, normally the same is done using the derivative function NNodederi in the BPINN ode solver.

@ChrisRackauckas
Copy link
Member

There's a lot of random stuff together in here. Break this apart into simple one thing PRs and lets merge those.

@Vaibhavdixit02
Copy link
Member

@AstitvaAggarwal do you think you can make this into multiple smaller PRs as Chri suggested above?

@AstitvaAggarwal
Copy link
Contributor Author

Yes, will do

AstitvaAggarwal added a commit to AstitvaAggarwal/NeuralPDE.jl that referenced this pull request May 8, 2024
@AstitvaAggarwal
Copy link
Contributor Author

@ChrisRackauckas @Vaibhavdixit02 I've seperated the code into two PRs. one for the better ode solver and this for the PDE solver.

@AstitvaAggarwal AstitvaAggarwal mentioned this pull request May 8, 2024
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants