Skip to content

Initialize line split fixes following Catalyst.jl PR #1306 #982

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

Merged
merged 2 commits into from
Aug 1, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions docs/src/examples/augmented_neural_ode.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ const cdev = cpu_device()
const gdev = gpu_device()

function random_point_in_sphere(dim, min_radius, max_radius)
distance = (max_radius - min_radius) .* (rand(Float32, 1) .^ (1.0f0 / dim)) .+
min_radius
distance = (max_radius - min_radius) .* (rand(Float32, 1) .^ (1.0f0 / dim)) .+ min_radius
Copy link
Contributor

Choose a reason for hiding this comment

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

[JuliaFormatter] reported by reviewdog 🐶

Suggested change
distance = (max_radius - min_radius) .* (rand(Float32, 1) .^ (1.0f0 / dim)) .+ min_radius
distance = (max_radius - min_radius) .* (rand(Float32, 1) .^ (1.0f0 / dim)) .+
min_radius

direction = randn(Float32, dim)
unit_direction = direction ./ norm(direction)
return distance .* unit_direction
Expand Down Expand Up @@ -138,8 +137,7 @@ circle, and `-1` to any point which lies between the inner and outer circle. Our

```@example augneuralode
function random_point_in_sphere(dim, min_radius, max_radius)
distance = (max_radius - min_radius) .* (rand(Float32, 1) .^ (1.0f0 / dim)) .+
min_radius
distance = (max_radius - min_radius) .* (rand(Float32, 1) .^ (1.0f0 / dim)) .+ min_radius
Copy link
Contributor

Choose a reason for hiding this comment

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

[JuliaFormatter] reported by reviewdog 🐶

Suggested change
distance = (max_radius - min_radius) .* (rand(Float32, 1) .^ (1.0f0 / dim)) .+ min_radius
distance = (max_radius - min_radius) .* (rand(Float32, 1) .^ (1.0f0 / dim)) .+
min_radius

direction = randn(Float32, dim)
unit_direction = direction ./ norm(direction)
return distance .* unit_direction
Expand Down
6 changes: 2 additions & 4 deletions src/ffjord.jl
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,7 @@ function __ffjord(model::StatefulLuxLayer, u::AbstractArray{T, N}, p, ad = nothi
end
end
if regularize
return cat(mz, -trace_jac, sum(abs2, mz; dims = 1:(N - 1)),
__norm_batched(eJ); dims = Val(N - 1))
return cat(mz, -trace_jac, sum(abs2, mz; dims = 1:(N - 1)), __norm_batched(eJ); dims = Val(N - 1))
Copy link
Contributor

Choose a reason for hiding this comment

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

[JuliaFormatter] reported by reviewdog 🐶

Suggested change
return cat(mz, -trace_jac, sum(abs2, mz; dims = 1:(N - 1)), __norm_batched(eJ); dims = Val(N - 1))
return cat(mz, -trace_jac, sum(abs2, mz; dims = 1:(N - 1)),
__norm_batched(eJ); dims = Val(N - 1))

else
return cat(mz, -trace_jac; dims = Val(N - 1))
end
Expand Down Expand Up @@ -156,8 +155,7 @@ function __forward_ffjord(n::FFJORD, x::AbstractArray{T, N}, ps, st) where {T, N
end

if n.basedist === nothing
logpz = -sum(abs2, z; dims = 1:(N - 1)) / T(2) .-
T(prod(S[1:(N - 1)]) / 2 * log(2π))
logpz = -sum(abs2, z; dims = 1:(N - 1)) / T(2) .- T(prod(S[1:(N - 1)]) / 2 * log(2π))
Copy link
Contributor

Choose a reason for hiding this comment

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

[JuliaFormatter] reported by reviewdog 🐶

Suggested change
logpz = -sum(abs2, z; dims = 1:(N - 1)) / T(2) .- T(prod(S[1:(N - 1)]) / 2 * log(2π))
logpz = -sum(abs2, z; dims = 1:(N - 1)) / T(2) .-
T(prod(S[1:(N - 1)]) / 2 * log(2π))

else
logpz = logpdf(n.basedist, z)
end
Expand Down
6 changes: 2 additions & 4 deletions src/multiple_shooting.jl
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,7 @@ function multiple_shoot(p, ode_data, tsteps, prob::ODEProblem, loss_function::F,
if i > 1
# Ensure continuity between last state in previous prediction
# and current initial condition in ode_data
loss += continuity_term *
continuity_loss(group_predictions[i - 1][griddims..., end], u[griddims..., 1])
loss += continuity_term * continuity_loss(group_predictions[i - 1][griddims..., end], u[griddims..., 1])
Copy link
Contributor

Choose a reason for hiding this comment

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

[JuliaFormatter] reported by reviewdog 🐶

Suggested change
loss += continuity_term * continuity_loss(group_predictions[i - 1][griddims..., end], u[griddims..., 1])
loss += continuity_term * continuity_loss(
group_predictions[i - 1][griddims..., end], u[griddims..., 1])

end
end

Expand Down Expand Up @@ -170,8 +169,7 @@ function multiple_shoot(p, ode_data, tsteps, ensembleprob::EnsembleProblem,
if i > 1
# Ensure continuity between last state in previous prediction
# and current initial condition in ode_data
loss += continuity_term *
continuity_loss(group_predictions[i - 1][griddims..., end, :], u[griddims..., 1, :])
loss += continuity_term * continuity_loss(group_predictions[i - 1][griddims..., end, :], u[griddims..., 1, :])
Copy link
Contributor

Choose a reason for hiding this comment

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

[JuliaFormatter] reported by reviewdog 🐶

Suggested change
loss += continuity_term * continuity_loss(group_predictions[i - 1][griddims..., end, :], u[griddims..., 1, :])
loss += continuity_term * continuity_loss(
group_predictions[i - 1][griddims..., end, :], u[griddims..., 1, :])

end
end

Expand Down
Loading