Skip to content

Docs for NeuralSurrogate #305

@jdossgollin

Description

@jdossgollin

Three issues with the NeuralSurrogate docs

First, loading the recommended packages yields a warning

julia> using Plots

julia> using Surrogates

julia> using Flux
┌ Warning: Package Surrogates does not have Flux in its dependencies:
│ - If you have Surrogates checked out for development and have
│   added Flux as a dependency but haven't updated your primary
│   environment's manifest file, try `Pkg.resolve()`.
│ - Otherwise you may need to report an issue with Surrogates
└ Loading Flux into Surrogates from project dependency, future warnings for Surrogates are suppressed.

This seems OK but it would be helpful to have a heads up for users.

Next, an error.
Following along, there is no lb or ub:

julia> neural = NeuralSurrogate(x, y, lb, ub, model = model1, n_echos = 10)
ERROR: UndefVarError: lb not defined
Stacktrace:
 [1] top-level scope

Next if I make up some numbers, there is a typo

lb, ub = -10, 10
surrogate_optimize(schaffer, SRBF(), lower_bound, upper_bound, neura, SobolSample(), maxiters=20, num_new_samples=10)
ERROR: UndefVarError: neura not defined
Stacktrace:
 [1] top-level scope

but even if I fix the typo I get an issue

neural = NeuralSurrogate(x, y, lb, ub, model = model1, n_echos = 10)
surrogate_optimize(schaffer, SRBF(), lower_bound, upper_bound, neural, SobolSample(), maxiters=20, num_new_samples=10)
ERROR: InexactError: Int64(3.8564731213645262)
Stacktrace:
 [1] Int64
   @ ./float.jl:723 [inlined]
 [2] convert
   @ ./number.jl:7 [inlined]
 [3] setindex!(A::Vector{Int64}, x::Float64, i1::Int64)
   @ Base ./array.jl:839
 [4] surrogate_optimize(obj::typeof(schaffer), ::SRBF, lb::Vector{Float64}, ub::Vector{Float64}, surr::NeuralSurrogate{UnitRange{Int64}, UnitRange{Int64}, Chain{Tuple{Dense{typeof(σ), Matrix{Float32}, Vector{Float32}}, Dense{typeof(σ), Matrix{Float32}, Vector{Float32}}, Dense{typeof(identity), Matrix{Float32}, Vector{Float32}}}}, Surrogates.var"#237#241"{Chain{Tuple{Dense{typeof(σ), Matrix{Float32}, Vector{Float32}}, Dense{typeof(σ), Matrix{Float32}, Vector{Float32}}, Dense{typeof(identity), Matrix{Float32}, Vector{Float32}}}}}, Descent, Zygote.Params, Int64, Int64, Int64}, sample_type::SobolSample; maxiters::Int64, num_new_samples::Int64)
   @ Surrogates ~/.julia/packages/Surrogates/lWGHe/src/Optimization.jl:117
 [5] top-level scope

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