Skip to content

Domain error when using optimize_prior! #129

@pasq-cat

Description

@pasq-cat

I was doing some tests for that paper i mentioned last time and sometimes when i try to fit the priors with

LaplaceRedux.fit!(la, data_loader)
optimize_prior!(la;verbose = false, n_steps = 200)

i get this error message

DomainError with -1.0:
log was called with a negative real argument but will only return a complex result if called with a complex argument. Try log(Complex(x)).

Stacktrace:
[1] throw_complex_domainerror(f::Symbol, x::Float64)
@ Base.Math .\math.jl:33
[2] _log
@ .\special\log.jl:295 [inlined]
[3] log(x::Float64)
@ Base.Math .\special\log.jl:261
[4] logdet
@ C:\Users\Pasqu.julia\juliaup\julia-1.11.1+0.x64.w64.mingw32\share\julia\stdlib\v1.11\LinearAlgebra\src\generic.jl:1719 [inlined]
[5] rrule
@ C:\Users\Pasqu.julia\packages\ChainRules\vdf7M\src\rulesets\LinearAlgebra\dense.jl:148 [inlined]
[6] rrule
@ C:\Users\Pasqu.julia\packages\ChainRulesCore\6Pucz\src\rules.jl:138 [inlined]
[7] chain_rrule
@ C:\Users\Pasqu.julia\packages\Zygote\NRp5C\src\compiler\chainrules.jl:224 [inlined]
[8] macro expansion
@ C:\Users\Pasqu.julia\packages\Zygote\NRp5C\src\compiler\interface2.jl:0 [inlined]
[9] _pullback(ctx::Zygote.Context{true}, f::typeof(logdet), args::Matrix{Float64})
@ Zygote C:\Users\Pasqu.julia\packages\Zygote\NRp5C\src\compiler\interface2.jl:87
[10] log_det_posterior_precision
@ C:\Users\Pasqu.julia\packages\LaplaceRedux\LwTNd\src\baselaplace\utils.jl:157 [inlined]
[11] _pullback(ctx::Zygote.Context{true}, f::typeof(LaplaceRedux.log_det_posterior_precision), args::Laplace)
...
@ Zygote C:\Users\Pasqu.julia\packages\Zygote\NRp5C\src\compiler\interface.jl:147
[24] optimize_prior!(la::Laplace; n_steps::Int64, lr::Float64, λinit::Nothing, σinit::Nothing, verbose::Bool, tune_σ::Bool)
@ LaplaceRedux C:\Users\Pasqu.julia\packages\LaplaceRedux\LwTNd\src\baselaplace\optimize_prior.jl:40

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions