Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
YichengDWu committed Oct 21, 2022
1 parent 1b72888 commit 31b4317
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/compact/NeuralPDE/pinn_types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -47,21 +47,20 @@ end

function PINN(chain::NamedTuple, rng::AbstractRNG=Random.default_rng())
phi = map(m -> ChainState(m, rng), chain)
init_params = Lux.fmap(float, initialparameters(rng, phi))
init_params = Lux.fmap(float64, initialparameters(rng, phi))

return PINN{typeof(phi), typeof(init_params)}(phi, init_params)
end

function PINN(chain::AbstractExplicitLayer, rng::AbstractRNG=Random.default_rng())
phi = ChainState(chain, rng)
init_params = Lux.fmap(float, initialparameters(rng, phi))
init_params = Lux.fmap(float64, initialparameters(rng, phi))

return PINN{typeof(phi), typeof(init_params)}(phi, init_params)
end

function initialparameters(rng::AbstractRNG, pinn::PINN)
init_params = Lux.fmap(float, initialparameters(rng, pinn.phi))
return init_params
return Lux.fmap(float64, initialparameters(rng, pinn.phi))
end

"""
Expand Down
2 changes: 2 additions & 0 deletions src/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -89,3 +89,5 @@ ChainRulesCore.@non_differentiable init_normal(::Any...)
function isongpu(nt::NamedTuple)
return any(x -> x isa AbstractGPUArray, Lux.fcollect(nt))
end

float64 = Base.Fix1(Broadcast.broadcast, Float64)

0 comments on commit 31b4317

Please sign in to comment.