Logging Utilities

NeuralPDE.LogOptionsType
LogOptions(log_frequency)
LogOptions(; log_frequency = 50)

Options for logging during optimization.

source
NeuralPDE.logscalarFunction
logscalar(logger, s::Real, name::AbstractString, step::Integer)

Log the scalar s under the key name at iteration step to logger.

This is the hook NeuralPDE uses to report scalar training diagnostics (for example "weighted_loss/full_weighted_loss") while discretize runs. The method defined here is a no-op fallback, so any logger that does not implement logscalar is silently ignored; the frequency of the calls is controlled by LogOptions.

Logger backends provide the behavior by adding a method. NeuralPDE ships one for TensorBoardLogger.TBLogger in a package extension, and downstream packages extend it the same way:

function NeuralPDE.logscalar(
        logger::MyLogger, scalar::Real, name::AbstractString, step::Integer
    )
    # record `scalar` however you like
    return nothing
end

Pass the resulting logger to PhysicsInformedNN via its logger keyword argument.

source
NeuralPDE.logvectorFunction
logvector(logger, values::AbstractVector{<:Real}, name::AbstractString, step::Integer)

Log the entries in values under the key name at iteration step.

NeuralPDE calls this hook for vector-valued training diagnostics. The fallback method is a no-op, so logger backends can opt in by defining a more specific method. For example:

function NeuralPDE.logvector(
        logger::MyLogger, values::AbstractVector{<:Real}, name::AbstractString,
        step::Integer
    )
    logger.vectors[(name, step)] = collect(values)
    return nothing
end

Pass the logger to PhysicsInformedNN with the logger keyword. Call frequency is controlled by LogOptions.

source