BinaryCommitteeMachineFBP.jl documentation

This package implements the Focusing Belief Propagation algorithm for committee machines with binary weights described in the paper Unreasonable Effectiveness of Learning Neural Networks: From Accessible States and Robust Ensembles to Basic Algorithmic Schemes by Carlo Baldassi, Christian Borgs, Jennifer Chayes, Alessandro Ingrosso, Carlo Lucibello, Luca Saglietti and Riccardo Zecchina, Proc. Natl. Acad. Sci. U.S.A. 113: E7655-E7662 (2016), doi:10.1073/pnas.1608103113.

The package is tested against Julia 0.4, 0.5 and current 0.6-dev on Linux, OS X, and Windows.

Installation

To install the module, use this command from within Julia:

julia> Pkg.clone("https://github.com/carlobaldassi/BinaryCommitteeMachineFBP.jl")

Dependencies will be installed automatically.

Usage

The module is loaded as any other Julia module:

julia> using BinaryCommitteeMachineFBP

The code provides a main function, focusingBP, and some auxiliary functions and types, documented below.

# BinaryCommitteeMachineFBP.focusingBPFunction.

focusingBP(N, K, patternspec; keywords...)

Run the Focusing Belief Propagation algorithm on a fully-connected committee machine with binary weights. N is the input (first layer) size, K the number of the hidden units (second layer size), and patternspec specifies how to build the patterns for the training set. Note that with the defult settings K must be odd (see notes for the accuracy1 and accuracy2 arguments below).

Possible values of patternspec are:

Note: all inputs and outputs must be ∈ {-1,1}.

The keyword arguments are:

The function returns three objects: the number of training errors, the messages and the patterns. The last two can be used as inputs to successive runs of the algorithms, as the initmessages keyword argument and the patternspec argument, respectively.

Example of a run which solves a problem with N * K = 1605 synapses with K = 5 at α = 0.3:

julia> errs, messages, patterns = B.focusingBP(321, 5, 0.3, randfact=0.1, seed=135, max_iters=1, damping=0.5);

source

Focusing protocols

# BinaryCommitteeMachineFBP.FocusingProtocolType.

FocusingProtocol

Abstract type representing a protocol for the focusing procedure, i.e. a way to produce successive values for the quantities γ, y and β. Currently, however, only β=Inf is supported. To be provided as an argument to focusingBP.

Available protocols are: StandardReinforcement, Scoping, PseudoReinforcement and FreeScoping.

source

# BinaryCommitteeMachineFBP.StandardReinforcementType.

StandardReinforcement(r::Range) <: FocusingProtocol

Standard reinforcement protocol, returns γ=Inf and y=1/(1-x), where x is taken from the given range r.

source

StandardReinforcement(dr::Float64) <: FocusingProtocol

Shorthand for StandardReinforcement(0:dr:(1-dr)).

source

# BinaryCommitteeMachineFBP.ScopingType.

Scoping(γr::Range, y) <: FocusingProtocol

Focusing protocol with fixed y and a varying γ taken from the given γr range.

source

# BinaryCommitteeMachineFBP.PseudoReinforcementType.

PseudoReinforcement(r::Range...; x=0.5) <: FocusingProtocol

A focusing protocol in which both γ and y are progressively increased, according to the formulas

γ = atanh(ρ^x)
y = 1+ρ^(1-2x)/(1-ρ)

where ρ is taken from the given range(s) r. With x=0, this is basically the same as StandardReinforcement.

source

PseudoReinforcement(dr::Float64; x=0.5) <: FocusingProtocol

Shorthand for PseudoReinforcement(0:dr:(1-dr); x=x).

source

# BinaryCommitteeMachineFBP.FreeScopingType.

FreeScoping(list::Vector{NTuple{2,Float64}}) <: FocusingProtocol

A focusing protocol which just returns the values of (γ,y) from the given list.

Example:

FreeScoping([(1/(1-x), (2-x)/(1-x)) for x = 0:0.01:0.99])

source

Reading and writing messages files

# BinaryCommitteeMachineFBP.read_messagesFunction.

read_messages(filename, mag_type)

Reads messages from a file. mag_type is the internal storage format used in the resulting Messages object, it can be either MagT64 (uses tanhs, accurate but slower) or MagP64 (plain format, faster but inaccurate).

The file format is the one produced by write_messages.

source

# BinaryCommitteeMachineFBP.write_messagesFunction.

write_messages(filename, messages)

Writes messages to a file. The messages can be read back with read_messages. Note that the output is a plain text file compressed with gzip.

source