MAP Estimation

BayesFlux.BNNModeFinderType

Find the mode of a BNN.

Find the mode of a BNN using optimiser. Each optimiser must have implemented a function step!(optimiser, θ, ∇θ) which makes one optimisation step given gradient function ∇θ(θ) and current parameter vector θ. The function must return θ as the first return value and a flag has_converged indicating whether the optimisation procedure should be stopped.

BayesFlux.find_modeFunction
find_mode(bnn::BNN, batchsize::Int, epochs::Int, optimiser::BNNModeFinder)

Find the mode of a BNN.

Arguments

  • bnn::BNN: A Bayesian Neural Network formed using BNN.
  • batchsize::Int: Batchsize used for stochastic gradients.
  • epochs::Int: Number of epochs to run for.
  • optimiser::BNNModeFinder: An optimiser.

Keyword Arguments

  • shuffle::Bool=true: Should data be shuffled after each epoch?
  • partial::Bool=true: Is it allowed to use a batch that is smaller than batchsize?
  • showprogress::Bool=true: Show a progress bar?
BayesFlux.FluxModeFinderType

FluxModeFinder(bnn::BNN, opt::O; windowlength = 100, ϵ = 1e-6) where {O<:Flux.Optimise.AbstractOptimiser}

Use one of Flux optimisers to find the mode. Keep track of changes in θ over a window of windowlegnth and report convergence if the maximum change over the current window is smaller than ϵ.