The mgl Reference Manual

This is the mgl Reference Manual, version 0.1.0, generated automatically by Declt version 4.0 beta 2 "William Riker" on Sun Jan 15 07:05:42 2023 GMT+0.

Table of Contents


1 Introduction


2 Systems

The main system appears first, followed by any subsystem dependency.


2.1 mgl

MGL is a machine learning library for backpropagation
neural networks, boltzmann machines, gaussian processes and more.

Author

Gábor Melis <>

Contact

Home Page

http://melisgl.github.io/mgl

Source Control

(GIT https://github.com/melisgl/mgl.git)

Bug Tracker

https://github.com/melisgl/mgl/issues

License

MIT, see COPYING.

Version

0.1.0

Dependencies
  • alexandria (system).
  • closer-mop (system).
  • array-operations (system).
  • lla (system).
  • cl-reexport (system).
  • mgl-gnuplot (system).
  • mgl-mat (system).
  • mgl-pax (system).
  • named-readtables (system).
  • pythonic-string-reader (system).
  • swank (system).
Source

mgl.asd.

Child Component

src (module).


2.2 mgl-gnuplot

Author

Gabor Melis

License

MIT

Dependencies
  • external-program (system).
  • alexandria (system).
Source

mgl-gnuplot.asd.

Child Component

src (module).


3 Modules

Modules are listed depth-first from the system components tree.


3.1 mgl/src

Source

mgl.asd.

Parent Component

mgl (system).

Child Components

3.2 mgl-gnuplot/src

Source

mgl-gnuplot.asd.

Parent Component

mgl-gnuplot (system).

Child Components

4 Files

Files are sorted by type and then listed depth-first from the systems components trees.


4.1 Lisp


4.1.1 mgl/mgl.asd

Source

mgl.asd.

Parent Component

mgl (system).

ASDF Systems

mgl.


4.1.2 mgl-gnuplot/mgl-gnuplot.asd

Source

mgl-gnuplot.asd.

Parent Component

mgl-gnuplot (system).

ASDF Systems

mgl-gnuplot.


4.1.3 mgl/src/package.lisp

Source

mgl.asd.

Parent Component

src (module).

Packages

4.1.4 mgl/src/common.lisp

Dependency

package.lisp (file).

Source

mgl.asd.

Parent Component

src (module).

Public Interface

4.1.5 mgl/src/resample.lisp

Dependency

common.lisp (file).

Source

mgl.asd.

Parent Component

src (module).

Public Interface
Internals

4.1.6 mgl/src/util.lisp

Dependency

resample.lisp (file).

Source

mgl.asd.

Parent Component

src (module).

Public Interface
Internals

4.1.7 mgl/src/log.lisp

Dependency

util.lisp (file).

Source

mgl.asd.

Parent Component

src (module).

Public Interface
Internals

time->string (function).


4.1.8 mgl/src/dataset.lisp

Dependency

log.lisp (file).

Source

mgl.asd.

Parent Component

src (module).

Public Interface
Internals

ensure-sampler (function).


4.1.9 mgl/src/copy.lisp

Dependency

dataset.lisp (file).

Source

mgl.asd.

Parent Component

src (module).

Public Interface
Internals

4.1.10 mgl/src/core.lisp

Dependency

copy.lisp (file).

Source

mgl.asd.

Parent Component

src (module).

Public Interface
Internals

4.1.11 mgl/src/feature.lisp

Dependency

core.lisp (file).

Source

mgl.asd.

Parent Component

src (module).

Public Interface
Internals

4.1.12 mgl/src/monitor.lisp

Dependency

feature.lisp (file).

Source

mgl.asd.

Parent Component

src (module).

Public Interface

4.1.13 mgl/src/counter.lisp

Dependency

monitor.lisp (file).

Source

mgl.asd.

Parent Component

src (module).

Public Interface
Internals

4.1.14 mgl/src/measure.lisp

Dependency

counter.lisp (file).

Source

mgl.asd.

Parent Component

src (module).

Public Interface

@mgl-measurer (special variable).


4.1.15 mgl/src/classification.lisp

Dependency

measure.lisp (file).

Source

mgl.asd.

Parent Component

src (module).

Public Interface
Internals

4.1.16 mgl/src/optimize.lisp

Dependency

classification.lisp (file).

Source

mgl.asd.

Parent Component

src (module).

Public Interface
Internals

4.1.17 mgl/src/gradient-descent.lisp

Dependency

optimize.lisp (file).

Source

mgl.asd.

Parent Component

src (module).

Public Interface
Internals

4.1.18 mgl/src/conjugate-gradient.lisp

Dependency

gradient-descent.lisp (file).

Source

mgl.asd.

Parent Component

src (module).

Public Interface
Internals

4.1.19 mgl/src/differentiable-function.lisp

Dependency

conjugate-gradient.lisp (file).

Source

mgl.asd.

Parent Component

src (module).

Public Interface
Internals

4.1.20 mgl/src/boltzmann-machine.lisp

Dependency

differentiable-function.lisp (file).

Source

mgl.asd.

Parent Component

src (module).

Public Interface
Internals

4.1.21 mgl/src/deep-belief-network.lisp

Dependency

boltzmann-machine.lisp (file).

Source

mgl.asd.

Parent Component

src (module).

Public Interface
Internals

4.1.22 mgl/src/backprop.lisp

Dependency

deep-belief-network.lisp (file).

Source

mgl.asd.

Parent Component

src (module).

Public Interface
Internals

4.1.23 mgl/src/lumps.lisp

Dependency

backprop.lisp (file).

Source

mgl.asd.

Parent Component

src (module).

Public Interface
Internals

4.1.24 mgl/src/unroll.lisp

Dependency

lumps.lisp (file).

Source

mgl.asd.

Parent Component

src (module).

Public Interface
Internals

4.1.25 mgl/src/gaussian-process.lisp

Dependency

unroll.lisp (file).

Source

mgl.asd.

Parent Component

src (module).

Public Interface
Internals

4.1.26 mgl/src/nlp.lisp

Dependency

gaussian-process.lisp (file).

Source

mgl.asd.

Parent Component

src (module).

Public Interface
Internals

4.1.27 mgl/src/mgl.lisp

Dependency

nlp.lisp (file).

Source

mgl.asd.

Parent Component

src (module).

Public Interface

4.1.28 mgl/src/doc.lisp

Dependency

mgl.lisp (file).

Source

mgl.asd.

Parent Component

src (module).

Internals

4.1.29 mgl-gnuplot/src/package.lisp

Source

mgl-gnuplot.asd.

Parent Component

src (module).

Packages

mgl-gnuplot.


4.1.30 mgl-gnuplot/src/gnuplot.lisp

Dependency

package.lisp (file).

Source

mgl-gnuplot.asd.

Parent Component

src (module).

Public Interface
Internals

5 Packages

Packages are listed by definition order.


5.1 mgl-dataset

See MGL-DATASET:@MGL-DATASET.

Source

package.lisp.

Use List
Used By List
Public Interface
Internals

ensure-sampler (function).


5.2 mgl-bp

See MGL-BP:@MGL-BP.

Source

package.lisp.

Use List
Used By List
Public Interface
Internals

5.3 mgl-resample

See MGL-RESAMPLE:@MGL-RESAMPLE.

Source

package.lisp.

Use List
  • common-lisp.
  • mgl-pax.
Used By List

mgl.

Public Interface
Internals

5.4 mgl-log

See MGL-LOG:@MGL-LOG.

Source

package.lisp.

Use List
Used By List
Public Interface
Internals

time->string (function).


5.5 mgl-unroll

Translating Boltzmann Machines to a Backprop networks, aka ‘unrolling’.

Source

package.lisp.

Use List
Used By List

mgl.

Public Interface
Internals

5.6 mgl-gp

Gaussian processes with support for training with backpropagation.

Source

package.lisp.

Use List
Used By List

mgl.

Public Interface
Internals

5.7 mgl-gd

See MGL-GD:@MGL-GD.

Source

package.lisp.

Use List
Used By List
Public Interface
Internals

5.8 mgl-util

Simple utilities, types.

Source

package.lisp.

Use List
Used By List
Public Interface
Internals

5.9 mgl-gnuplot

Minimalistic, interactive or batch mode gnuplot interface that supports multiplots and inline data.

Source

package.lisp.

Use List

common-lisp.

Public Interface
Internals

5.10 mgl-bm

Fully General Boltzmann Machines, Restricted Boltzmann Machines and their stacks called Deep Belief Networks (DBN).

Source

package.lisp.

Nickname

mgl-rbm

Use List
Used By List
Public Interface
Internals

5.11 mgl-common

The only purpose of this package is to avoid conflicts between other packages.

Source

package.lisp.

Use List
  • common-lisp.
  • mgl-pax.
Used By List
Public Interface

5.12 mgl-diffun

See MGL-DIFFUN:@MGL-DIFFUN.

Source

package.lisp.

Use List
Used By List

mgl.

Public Interface
Internals

5.13 mgl

See MGL:@MGL-MANUAL. This package reexports
everything from other packages defined here plus MGL-MAT.

Source

package.lisp.

Use List
Public Interface
Internals

5.14 mgl-opt

See MGL-OPT:@MGL-OPT.

Source

package.lisp.

Use List
Used By List
Public Interface
Internals

5.15 mgl-nlp

See MGL-NLP:@MGL-NLP.

Source

package.lisp.

Use List
Used By List

mgl.

Public Interface
Internals

5.16 mgl-cg

See MGL-CG:@MGL-CG.

Source

package.lisp.

Use List
Used By List
Public Interface
Internals

5.17 mgl-core

See MGL-CORE:@MGL-MODEL, MGL-CORE:@MGL-MONITOR, MGL-CORE:@MGL-CLASSIFICATION.

Source

package.lisp.

Use List
Used By List
Public Interface
Internals

6 Definitions

Definitions are sorted by export status, category, package, and then by lexicographic order.


6.1 Public Interface


6.1.1 Constants

Constant: flt-ctype
Package

mgl-util.

Source

util.lisp.

Constant: least-negative-flt
Package

mgl-util.

Source

util.lisp.

Constant: least-positive-flt
Package

mgl-util.

Source

util.lisp.

Constant: most-negative-flt
Package

mgl-util.

Source

util.lisp.

Constant: most-positive-flt
Package

mgl-util.

Source

util.lisp.


6.1.2 Special variables

Special Variable: *command-stream*

The default stream to which commands and inline data are written by WRITE-COMMAND.

Package

mgl-gnuplot.

Source

gnuplot.lisp.

Special Variable: *cuda-window-start-time*

The default for CUDA-WINDOW-START-TIME.

Package

mgl-bp.

Source

backprop.lisp.

Special Variable: *default-ext*

Extrapolate maximum EXT times the current step-size.

Package

mgl-cg.

Source

conjugate-gradient.lisp.

Special Variable: *default-int*

Don’t reevaluate within INT of the limit of the current bracket.

Package

mgl-cg.

Source

conjugate-gradient.lisp.

Special Variable: *default-max-n-evaluations*
Package

mgl-cg.

Source

conjugate-gradient.lisp.

Special Variable: *default-max-n-evaluations-per-line-search*
Package

mgl-cg.

Source

conjugate-gradient.lisp.

Special Variable: *default-max-n-line-searches*
Package

mgl-cg.

Source

conjugate-gradient.lisp.

Special Variable: *default-ratio*

Maximum allowed slope ratio.

Package

mgl-cg.

Source

conjugate-gradient.lisp.

Special Variable: *default-rho*

RHO is the minimum allowed fraction of the expected (from the slope at the initial point in the linesearch). Constants must satisfy 0 < RHO < SIG < 1.

Package

mgl-cg.

Source

conjugate-gradient.lisp.

Special Variable: *default-sig*

SIG and RHO are the constants controlling the Wolfe-Powell conditions. SIG is the maximum allowed absolute ratio between previous and new slopes (derivatives in the search direction), thus setting SIG to low (positive) values forces higher precision in the line-searches.

Package

mgl-cg.

Source

conjugate-gradient.lisp.

Special Variable: *experiment-random-seed*
Package

mgl-util.

Source

util.lisp.

Special Variable: *infinitely-empty-dataset*

This is the default dataset for MGL-OPT:MINIMIZE. It’s an infinite stream of NILs.

Package

mgl-dataset.

Source

dataset.lisp.

Special Variable: *log-file*
Package

mgl-log.

Source

log.lisp.

Special Variable: *log-time*
Package

mgl-log.

Source

log.lisp.

Special Variable: *no-array-bounds-check*
Package

mgl-util.

Source

util.lisp.

Special Variable: *warp-time*

Controls whether warping is enabled (see @MGL-RNN-TIME-WARP). Don’t enable it for training, as it would make backprop impossible.

Package

mgl-bp.

Source

backprop.lisp.

Special Variable: @mgl-attributes
Package

mgl-core.

Source

counter.lisp.

Special Variable: @mgl-bm
Package

mgl.

Source

mgl.lisp.

Special Variable: @mgl-bp
Package

mgl-bp.

Source

backprop.lisp.

Special Variable: @mgl-bp-*-lump
Package

mgl-bp.

Source

lumps.lisp.

Special Variable: @mgl-bp-+-lump
Package

mgl-bp.

Source

lumps.lisp.

Special Variable: @mgl-bp-abs-lump
Package

mgl-bp.

Source

lumps.lisp.

Special Variable: @mgl-bp-activation-functions
Package

mgl-bp.

Source

lumps.lisp.

Special Variable: @mgl-bp-activation-subnet
Package

mgl-bp.

Source

lumps.lisp.

Special Variable: @mgl-bp-activations
Package

mgl-bp.

Source

lumps.lisp.

Special Variable: @mgl-bp-arithmetic
Package

mgl-bp.

Source

lumps.lisp.

Special Variable: @mgl-bp-batch-normalization
Package

mgl-bp.

Source

lumps.lisp.

Special Variable: @mgl-bp-dropout-lump
Package

mgl-bp.

Source

lumps.lisp.

Special Variable: @mgl-bp-embedding-lump
Package

mgl-bp.

Source

lumps.lisp.

Special Variable: @mgl-bp-exp-lump
Package

mgl-bp.

Source

lumps.lisp.

Special Variable: @mgl-bp-extension-api
Package

mgl-bp.

Source

backprop.lisp.

Special Variable: @mgl-bp-gaussian-random-lump
Package

mgl-bp.

Source

lumps.lisp.

Special Variable: @mgl-bp-input-lump
Package

mgl-bp.

Source

lumps.lisp.

Special Variable: @mgl-bp-inputs
Package

mgl-bp.

Source

lumps.lisp.

Special Variable: @mgl-bp-loss-lump
Package

mgl-bp.

Source

lumps.lisp.

Special Variable: @mgl-bp-losses
Package

mgl-bp.

Source

lumps.lisp.

Special Variable: @mgl-bp-lstm-subnet
Package

mgl-bp.

Source

lumps.lisp.

Special Variable: @mgl-bp-lump
Package

mgl-bp.

Source

lumps.lisp.

Special Variable: @mgl-bp-lumps
Package

mgl-bp.

Source

lumps.lisp.

Special Variable: @mgl-bp-max-channel-lump
Package

mgl-bp.

Source

lumps.lisp.

Special Variable: @mgl-bp-max-lump
Package

mgl-bp.

Source

lumps.lisp.

Special Variable: @mgl-bp-min-lump
Package

mgl-bp.

Source

lumps.lisp.

Special Variable: @mgl-bp-monitoring
Package

mgl-bp.

Source

backprop.lisp.

Special Variable: @mgl-bp-normalized-lump
Package

mgl-bp.

Source

lumps.lisp.

Special Variable: @mgl-bp-overview
Package

mgl-bp.

Source

backprop.lisp.

Special Variable: @mgl-bp-relu-lump
Package

mgl-bp.

Source

lumps.lisp.

Special Variable: @mgl-bp-rnn-operations
Package

mgl-bp.

Source

lumps.lisp.

Special Variable: @mgl-bp-sample-binary-lump
Package

mgl-bp.

Source

lumps.lisp.

Special Variable: @mgl-bp-scaled-tanh-lump
Package

mgl-bp.

Source

lumps.lisp.

Special Variable: @mgl-bp-seq-barrier-lump
Package

mgl-bp.

Source

lumps.lisp.

Special Variable: @mgl-bp-sigmoid-lump
Package

mgl-bp.

Source

lumps.lisp.

Special Variable: @mgl-bp-sine-lump
Package

mgl-bp.

Source

lumps.lisp.

Special Variable: @mgl-bp-softmax-xe-loss-lump
Package

mgl-bp.

Source

lumps.lisp.

Special Variable: @mgl-bp-squared-difference-lump
Package

mgl-bp.

Source

lumps.lisp.

Special Variable: @mgl-bp-stochasticity
Package

mgl-bp.

Source

lumps.lisp.

Special Variable: @mgl-bp-sum-lump
Package

mgl-bp.

Source

lumps.lisp.

Special Variable: @mgl-bp-tanh-lump
Package

mgl-bp.

Source

lumps.lisp.

Special Variable: @mgl-bp-training
Package

mgl-bp.

Source

backprop.lisp.

Special Variable: @mgl-bp-utilities
Package

mgl-bp.

Source

lumps.lisp.

Special Variable: @mgl-bp-v*m-lump
Package

mgl-bp.

Source

lumps.lisp.

Special Variable: @mgl-bp-weight-lump
Package

mgl-bp.

Source

lumps.lisp.

Special Variable: @mgl-bpn
Package

mgl-bp.

Source

backprop.lisp.

Special Variable: @mgl-cg
Package

mgl-cg.

Source

conjugate-gradient.lisp.

Special Variable: @mgl-classification
Package

mgl-core.

Source

classification.lisp.

Special Variable: @mgl-classification-counter
Package

mgl-core.

Source

classification.lisp.

Special Variable: @mgl-classification-measurer
Package

mgl-core.

Source

classification.lisp.

Special Variable: @mgl-classification-monitor
Package

mgl-core.

Source

classification.lisp.

Special Variable: @mgl-code-organization
Package

mgl.

Source

mgl.lisp.

Special Variable: @mgl-common
Package

mgl-common.

Source

common.lisp.

Special Variable: @mgl-confusion-matrix
Package

mgl-core.

Source

classification.lisp.

Special Variable: @mgl-core
Package

mgl-core.

Source

core.lisp.

Special Variable: @mgl-counter
Package

mgl-core.

Source

counter.lisp.

Special Variable: @mgl-counter-classes
Package

mgl-core.

Source

counter.lisp.

Special Variable: @mgl-dataset
Package

mgl-dataset.

Source

dataset.lisp.

Special Variable: @mgl-dependencies
Package

mgl.

Source

mgl.lisp.

Special Variable: @mgl-diffun
Package

mgl-diffun.

Source

differentiable-function.lisp.

Special Variable: @mgl-executors
Package

mgl-core.

Source

core.lisp.

Special Variable: @mgl-feature-encoding
Package

mgl-core.

Source

feature.lisp.

Special Variable: @mgl-feature-selection
Package

mgl-core.

Source

feature.lisp.

Special Variable: @mgl-features
Package

mgl-core.

Source

feature.lisp.

Special Variable: @mgl-fnn
Package

mgl-bp.

Source

backprop.lisp.

Special Variable: @mgl-fnn-tutorial
Package

mgl-bp.

Source

backprop.lisp.

Special Variable: @mgl-gd
Package

mgl-gd.

Source

gradient-descent.lisp.

Special Variable: @mgl-gd-adam-optimizer
Package

mgl-gd.

Source

gradient-descent.lisp.

Special Variable: @mgl-gd-batch-gd-optimizer
Package

mgl-gd.

Source

gradient-descent.lisp.

Special Variable: @mgl-gd-normalized-batch-gd-optimizer
Package

mgl-gd.

Source

gradient-descent.lisp.

Special Variable: @mgl-gd-per-weight-optimization
Package

mgl-gd.

Source

gradient-descent.lisp.

Special Variable: @mgl-gd-segmented-gd-optimizer
Package

mgl-gd.

Source

gradient-descent.lisp.

Special Variable: @mgl-gd-sgd-optimizer
Package

mgl-gd.

Source

gradient-descent.lisp.

Special Variable: @mgl-gd-utilities
Package

mgl-gd.

Source

gradient-descent.lisp.

Special Variable: @mgl-glossary
Package

mgl.

Source

mgl.lisp.

Special Variable: @mgl-gp
Package

mgl.

Source

mgl.lisp.

Special Variable: @mgl-introduction
Package

mgl.

Source

mgl.lisp.

Package

mgl.

Source

mgl.lisp.

Special Variable: @mgl-log
Package

mgl-log.

Source

log.lisp.

Special Variable: @mgl-manual
Package

mgl.

Source

mgl.lisp.

Special Variable: @mgl-measurer
Package

mgl-core.

Source

measure.lisp.

Special Variable: @mgl-model-stripe
Package

mgl-core.

Source

core.lisp.

Special Variable: @mgl-monitor
Package

mgl-core.

Source

monitor.lisp.

Special Variable: @mgl-monitoring
Package

mgl-core.

Source

monitor.lisp.

Special Variable: @mgl-nlp
Package

mgl-nlp.

Source

nlp.lisp.

Special Variable: @mgl-nlp-bag-of-words
Package

mgl-nlp.

Source

nlp.lisp.

Special Variable: @mgl-opt
Package

mgl-opt.

Source

optimize.lisp.

Special Variable: @mgl-opt-cost
Package

mgl-opt.

Source

optimize.lisp.

Special Variable: @mgl-opt-extension-api
Package

mgl-opt.

Source

optimize.lisp.

Special Variable: @mgl-opt-gradient-sink
Package

mgl-opt.

Source

optimize.lisp.

Special Variable: @mgl-opt-gradient-source
Package

mgl-opt.

Source

optimize.lisp.

Special Variable: @mgl-opt-iterative-optimizer
Package

mgl-opt.

Source

optimize.lisp.

Special Variable: @mgl-opt-optimizer
Package

mgl-opt.

Source

optimize.lisp.

Special Variable: @mgl-overview
Package

mgl.

Source

mgl.lisp.

Special Variable: @mgl-parameterized-executor-cache
Package

mgl-core.

Source

core.lisp.

Special Variable: @mgl-persistence
Package

mgl-core.

Source

core.lisp.

Special Variable: @mgl-resample
Package

mgl-resample.

Source

resample.lisp.

Special Variable: @mgl-resample-bagging
Package

mgl-resample.

Source

resample.lisp.

Special Variable: @mgl-resample-cross-validation
Package

mgl-resample.

Source

resample.lisp.

Special Variable: @mgl-resample-cv-bagging
Package

mgl-resample.

Source

resample.lisp.

Special Variable: @mgl-resample-misc
Package

mgl-resample.

Source

resample.lisp.

Special Variable: @mgl-resample-partitions
Package

mgl-resample.

Source

resample.lisp.

Special Variable: @mgl-resample-shuffling
Package

mgl-resample.

Source

resample.lisp.

Special Variable: @mgl-rnn
Package

mgl-bp.

Source

backprop.lisp.

Special Variable: @mgl-rnn-time-warp
Package

mgl-bp.

Source

backprop.lisp.

Special Variable: @mgl-rnn-tutorial
Package

mgl-bp.

Source

backprop.lisp.

Special Variable: @mgl-sampler
Package

mgl-dataset.

Source

dataset.lisp.

Special Variable: @mgl-sampler-function-sampler
Package

mgl-dataset.

Source

dataset.lisp.


6.1.3 Macros

Macro: apply-key (key object)
Package

mgl-util.

Source

util.lisp.

Macro: build-fnn ((&key fnn class initargs max-n-stripes name) &body clumps)

Syntactic sugar to assemble FNNs from CLUMPs. Like LET*, it is a sequence of bindings (of symbols to CLUMPs). The names of the clumps created default to the symbol of the binding. In case a clump is not bound to a symbol (because it was created in a nested expression), the local function CLUMP can be used to find the clump with the given name in the fnn being built. Example:

(build-fnn ()
(features (->input :size n-features))
(biases (->weight :size n-features))
(weights (->weight :size (* n-hiddens n-features))) (activations0 (->v*m :weights weights :x (clump ’features))) (activations (->+ :args (list biases activations0))) (output (->sigmoid :x activations)))

Package

mgl-bp.

Source

backprop.lisp.

Macro: build-rnn ((&key rnn class name initargs max-n-stripes max-lag) &body body)

Create an RNN with MAX-N-STRIPES and MAX-LAG whose UNFOLDER is BODY wrapped in a lambda. Bind symbol given as the RNN argument to the RNN object so that BODY can see it.

Package

mgl-bp.

Source

backprop.lisp.

Macro: data (data &rest options)
Package

mgl-gnuplot.

Source

gnuplot.lisp.

Macro: defclass-now (name direct-superclasses direct-slots &rest options)
Package

mgl-util.

Source

util.lisp.

Macro: define-descriptions ((object class &key inheritp) &body descriptions)
Package

mgl-util.

Source

util.lisp.

Macro: define-slots-not-to-be-copied (context class &body slot-names)
Package

mgl-util.

Source

copy.lisp.

Macro: define-slots-to-be-shallow-copied (context class &body slot-names)
Package

mgl-util.

Source

copy.lisp.

Macro: defmaker ((name &key unkeyword-args extra-keyword-args make-instance-args) &body body)
Package

mgl-util.

Source

util.lisp.

Macro: do-batches-for-model ((batch (dataset model)) &body body)

Convenience macro over MAP-BATCHES-FOR-MODEL.

Package

mgl-core.

Source

core.lisp.

Macro: do-clouds ((cloud bm) &body body)
Package

mgl-bm.

Source

boltzmann-machine.lisp.

Macro: do-executors ((instances object) &body body)

Convenience macro on top of MAP-OVER-EXECUTORS.

Package

mgl-core.

Source

core.lisp.

Macro: do-gradient-sink (((segment accumulator) sink) &body body)

A convenience macro on top of MAP-GRADIENT-SINK.

Package

mgl-opt.

Source

optimize.lisp.

Macro: do-segment-set ((segment &optional start) segment-set &body body)

Iterate over SEGMENTS in SEGMENT-SET. If START is specified, the it is bound to the start index of SEGMENT within SEGMENT-SET. The start index is the sum of the sizes of previous segments.

Package

mgl-opt.

Source

optimize.lisp.

Macro: file (filename &rest options)
Package

mgl-gnuplot.

Source

gnuplot.lisp.

Macro: fn (expression &rest options)
Package

mgl-gnuplot.

Source

gnuplot.lisp.

Macro: plot (() &body mappings)
Package

mgl-gnuplot.

Source

gnuplot.lisp.

Macro: push-all (list place)
Package

mgl-util.

Source

util.lisp.

Macro: repeatably ((&key seed) &body body)
Package

mgl-util.

Source

util.lisp.

Macro: repeatedly (&body body)

Like CONSTANTLY but evaluates BODY it for each time.

Package

mgl-util.

Source

util.lisp.

Macro: special-case (test &body body)

Let the compiler compile BODY for the case when TEST is true and also when it’s false. The purpose is to allow different constraints to propagate to the two branches allowing them to be more optimized.

Package

mgl-util.

Source

util.lisp.

Macro: splot (() &body mappings)
Package

mgl-gnuplot.

Source

gnuplot.lisp.

Macro: the! (&rest args)
Package

mgl-util.

Source

util.lisp.

Macro: while (test &body body)
Package

mgl-util.

Source

util.lisp.

Macro: with-command-stream ((stream) &body body)

Binds *COMMAND-STREAM* to STREAM routing all command output to STREAM by default.

Package

mgl-gnuplot.

Source

gnuplot.lisp.

Macro: with-copying (&body body)
Package

mgl-util.

Source

copy.lisp.

Macro: with-logging-entry ((stream) &body body)
Package

mgl-log.

Source

log.lisp.

Macro: with-padded-attribute-printing ((attributeds) &body body)

Note the width of values for each attribute key which is the number of characters in the value’s PRINC-TO-STRING’ed representation. In BODY, if attributes with they same key are printed they are forced to be at least this wide. This allows for nice, table-like output:

(let ((attributeds
(list (make-instance ’basic-counter
:attributes ’(:a 1 :b 23 :c 456)) (make-instance ’basic-counter
:attributes ’(:a 123 :b 45 :c 6))))) (with-padded-attribute-printing (attributeds)
(map nil (lambda (attributed)
(format t "~A~%" attributed)) attributeds)))
;; 1 23 456: 0.000e+0 (0)
;; 123 45 6 : 0.000e+0 (0)

Package

mgl-core.

Source

counter.lisp.

Macro: with-session ((&key display geometry persistp output error) &body body)

Start gnuplot, bind STREAM and *COMMAND-STREAM* to its standard input. The stream is closed when BODY exits.

Package

mgl-gnuplot.

Source

gnuplot.lisp.

Macro: with-stripes (specs &body body)

Bind start and optionally end indices belonging to stripes in striped objects.

(WITH-STRIPES ((STRIPE1 OBJECT1 START1 END1)
(STRIPE2 OBJECT2 START2) ...)
...)

This is how one’s supposed to find the index range corresponding to the Nth input in an input lump of a bpn:

(with-stripes ((n input-lump start end))
(loop for i upfrom start below end
do (setf (mref (nodes input-lump) i) 0d0)))

Note how the input lump is striped, but the matrix into which we are indexing (NODES) is not known to WITH-STRIPES. In fact, for lumps the same stripe indices work with NODES and MGL-BP:DERIVATIVES.

Package

mgl-core.

Source

core.lisp.

Macro: with-weights-copied ((from-bpn) &body body)

In BODY ->WEIGHT will first look up if a weight lump of the same name exists in FROM-BPN and return that, or else create a weight lump normally. If FROM-BPN is NIL, then no weights are copied.

Package

mgl-bp.

Source

lumps.lisp.

Macro: with-zero-on-underflow ((prototype) &body body)
Package

mgl-util.

Source

util.lisp.


6.1.4 Setf expanders

Setf Expander: (setf max-n-stripes) (object)
Package

mgl-core.

Source

core.lisp.

Reader

max-n-stripes (generic function).

Setf Expander: (setf n-stripes) (object)
Package

mgl-core.

Source

core.lisp.

Reader

n-stripes (generic function).


6.1.5 Ordinary functions

Function: ->* (x y &key name size default-value shared-with-clump)
Package

mgl-bp.

Source

lumps.lisp.

Function: ->+ (args &key name size default-value shared-with-clump)
Package

mgl-bp.

Source

lumps.lisp.

Function: ->abs (x &key name size default-value shared-with-clump)
Package

mgl-bp.

Source

lumps.lisp.

Function: ->activation (inputs &key name size peepholes add-bias-p)

Create a subnetwork of class ->ACTIVATION that computes the over activation from dense connection from lumps in INPUTS, and elementwise connection from lumps in PEEPHOLES. Create new ->WEIGHT lumps as necessary. INPUTS and PEEPHOLES can be a single lump or a list of lumps. Finally, if ADD-BIAS-P, then add an elementwise bias too. SIZE must be specified explicitly, because it is not possible to determine it unless there are peephole connections.

“‘cl-transcript
(->activation (->input :size 10 :name ’input) :name ’h1 :size 4) ==> #<->ACTIVATION (H1 :ACTIVATION) :STRIPES 1/1 :CLUMPS 4> “‘

This is the basic workhorse of neural networks which takes care of the linear transformation whose results and then fed to some non-linearity (->SIGMOID, ->TANH, etc).

The name of the subnetwork clump is ‘(,NAME :ACTIVATION)‘. The bias weight lump (if any) is named ‘(:BIAS ,NAME)‘. Dense connection weight lumps are named are named after the input and NAME: ‘(,(NAME INPUT) ,NAME)‘, while peepholes weight lumps are named ‘(,(NAME INPUT) ,NAME :PEEPHOLE)‘. This is useful to know if, for example, they are to be initialized differently.

Package

mgl-bp.

Source

lumps.lisp.

Function: ->batch-normalization (scale shift &key name size default-value shared-with-clump dimensions batch-size variance-adjustment population-decay)
Package

mgl-bp.

Source

lumps.lisp.

Function: ->batch-normalized (x &key name size default-value shared-with-clump normalization batch-size variance-adjustment population-decay)
Package

mgl-bp.

Source

lumps.lisp.

Function: ->batch-normalized-activation (inputs &key name size peepholes batch-size variance-adjustment population-decay)

A utility functions that creates and wraps an ->ACTIVATION in ->BATCH-NORMALIZED and with its BATCH-NORMALIZATION the two weight
lumps for the scale and shift
parameters. ‘(->BATCH-NORMALIZED-ACTIVATION INPUTS :NAME ’H1 :SIZE
10)‘ is equivalent to:

“‘commonlisp
(->batch-normalized (->activation inputs :name ’h1 :size 10 :add-bias-p nil) :name ’(h1 :batch-normalized-activation))
“‘

Note how biases are turned off since normalization will cancel them anyway (but a shift is added which amounts to the same effect).

Package

mgl-bp.

Source

lumps.lisp.

Function: ->dropout (x &key name size default-value shared-with-clump dropout)
Package

mgl-bp.

Source

lumps.lisp.

Function: ->embedding (&key name size default-value shared-with-clump weights input-row-indices)
Package

mgl-bp.

Source

lumps.lisp.

Function: ->exp (x &key name size default-value shared-with-clump)
Package

mgl-bp.

Source

lumps.lisp.

Function: ->gaussian-random (&key name size default-value shared-with-clump mean variance variance-for-prediction)
Package

mgl-bp.

Source

lumps.lisp.

Function: ->gp (&key name size default-value shared-with-clump means covariances)
Package

mgl-gp.

Source

gaussian-process.lisp.

Function: ->input (&key name size default-value shared-with-clump x dropout)
Package

mgl-bp.

Source

lumps.lisp.

Function: ->loss (x &key name size default-value shared-with-clump importance)
Package

mgl-bp.

Source

lumps.lisp.

Function: ->lstm (inputs &key name cell-init output-init size activation-fn gate-fn input-fn output-fn peepholes)

Create an LSTM layer consisting of input, forget, output gates with which input, cell state and output are scaled. Lots of lumps are created, the final one representing to output of the LSTM has NAME. The rest of the lumps are named automatically based on NAME. This function returns only the output lump (‘m‘), but all created lumps are added automatically to the BPN being built.

There are many papers and tutorials on LSTMs. This version is well described in "Long Short-Term Memory Recurrent Neural Network Architectures for Large Scale Acoustic Modeling" (2014, Hasim Sak, Andrew Senior, Francoise Beaufays). Using the notation from that paper:

$$
i_t = s(W\_{ix} x\_t + W\_{im} m\_{t-1} + W\_{ic} \odot
c\_{t-1} + b\_i)
$$

$$
f\_t = s(W\_{fx} x\_t + W\_{fm} m\_{t-1} + W\_{fc} \odot c\_{t-1} + b\_f)
$$

$$
c\_t = f\_t \odot c\_{t-1} + i\_t \odot g(W\_{cx} x\_t +
W\_{cm} m\_{t-1} + b\_c)
$$

$$
o\_t = s(W\_{ox} x\_t + W\_{om} m\_{t-1} + W\_{oc} \odot
c\_t + b\_o)
$$

$$
m\_t = o\_t \odot h(c\_t),
$$

where ‘i‘, ‘f‘, and ‘o‘ are the input, forget and output gates. ‘c‘ is the cell state and ‘m‘ is the actual output.

Weight matrices for connections from ‘c‘ (‘W_ic‘, ‘W_fc‘ and ‘W_oc‘) are diagonal and represented by just the vector of diagonal values. These connections are only added if PEEPHOLES is true.

A notable difference from the paper is that in addition to being a single lump, ‘x_t‘ (INPUTS) can also be a list of lumps. Whenever some activation is to be calculated based on ‘x_t‘, it is going to be the sum of individual activations. For example, ‘W_ix * x_t‘ is really ‘sum_j W_ijx * inputs_j‘.

If CELL-INIT is non-NIL, then it must be a CLUMP of SIZE form which stands for the initial state of the value cell (‘c_{-1}‘). CELL-INIT being NIL is equivalent to the state of all zeros.

ACTIVATION-FN defaults to ->ACTIVATION, but it can be for example ->BATCH-NORMALIZED-ACTIVATION. In general, functions like the aforementioned two with signature like (INPUTS &KEY NAME SIZE PEEPHOLES) can be passed as ACTIVATION-FN.

Package

mgl-bp.

Source

lumps.lisp.

Function: ->max (x &key name size default-value shared-with-clump group-size)
Package

mgl-bp.

Source

lumps.lisp.

Function: ->max-channel (x &key name size default-value shared-with-clump group-size)
Package

mgl-bp.

Source

lumps.lisp.

Function: ->min (x &key name size default-value shared-with-clump group-size)
Package

mgl-bp.

Source

lumps.lisp.

Function: ->normalized (x &key name size default-value shared-with-clump group-size scale)
Package

mgl-bp.

Source

lumps.lisp.

Function: ->periodic (x &key name size default-value shared-with-clump period)
Package

mgl-gp.

Source

gaussian-process.lisp.

Function: ->ref (&key name size default-value shared-with-clump index into drop-negative-index-p)
Package

mgl-gp.

Source

gaussian-process.lisp.

Function: ->relu (x &key name size default-value shared-with-clump)
Package

mgl-bp.

Source

lumps.lisp.

Function: ->rep (x n &key name size default-value shared-with-clump)
Package

mgl-gp.

Source

gaussian-process.lisp.

Function: ->rough-exponential (x &key name size default-value shared-with-clump signal-variance length-scale roughness)
Package

mgl-gp.

Source

gaussian-process.lisp.

Function: ->sample-binary (x &key name size default-value shared-with-clump)
Package

mgl-bp.

Source

lumps.lisp.

Function: ->scaled-tanh (x &key name size default-value shared-with-clump)
Package

mgl-bp.

Source

lumps.lisp.

Function: ->seq-barrier (&key name size default-value shared-with-clump seq-elt-fn)
Package

mgl-bp.

Source

lumps.lisp.

Function: ->sigmoid (x &key name size default-value shared-with-clump dropout)
Package

mgl-bp.

Source

lumps.lisp.

Function: ->sin (x &key name size default-value shared-with-clump)
Package

mgl-bp.

Source

lumps.lisp.

Function: ->softmax-xe-loss (x &key name size default-value shared-with-clump group-size target)
Package

mgl-bp.

Source

lumps.lisp.

Function: ->squared-difference (x y &key name size default-value shared-with-clump)
Package

mgl-bp.

Source

lumps.lisp.

Function: ->stretch (x n &key name size default-value shared-with-clump)
Package

mgl-gp.

Source

gaussian-process.lisp.

Function: ->sum (x &key name size default-value shared-with-clump)
Package

mgl-bp.

Source

lumps.lisp.

Function: ->tanh (x &key name size default-value shared-with-clump)
Package

mgl-bp.

Source

lumps.lisp.

Function: ->v*m (x weights &key name size default-value shared-with-clump transpose-weights-p)
Package

mgl-bp.

Source

lumps.lisp.

Function: ->weight (&key name size default-value shared-with-clump dimensions)
Package

mgl-bp.

Source

lumps.lisp.

Function: add-clump (clump bpn)

Add CLUMP to BPN. MAX-N-STRIPES of CLUMP gets set to that of BPN. It is an error to add a clump with a name already used by one of the CLUMPS of BPN.

Package

mgl-bp.

Source

backprop.lisp.

Function: add-confusion-matrix (matrix result-matrix)

Add MATRIX into RESULT-MATRIX.

Package

mgl-core.

Source

classification.lisp.

Function: add-to-running-stat (x stat &key weight)
Package

mgl-util.

Source

util.lisp.

Function: append1 (list obj)
Package

mgl-util.

Source

util.lisp.

Function: applies-to-p (generic-function &rest args)
Package

mgl-util.

Source

util.lisp.

Function: apply-monitors (monitors &rest arguments)

Call APPLY-MONITOR on each monitor in MONITORS and ARGUMENTS. This is how an event is fired.

Package

mgl-core.

Source

monitor.lisp.

Function: arrange-for-clipping-gradients (batch-gd-optimizer l2-upper-bound &key callback)

Make it so that the norm of the batch normalized gradients accumulated by BATCH-GD-OPTIMIZER is clipped to L2-UPPER-BOUND before every update. See CLIP-L2-NORM.

Package

mgl-gd.

Source

gradient-descent.lisp.

Function: arrange-for-renormalizing-activations (bpn optimizer l2-upper-bound)

By pushing a lambda to AFTER-UPDATE-HOOK of OPTIMIZER arrange for all weights beings trained by OPTIMIZER to be renormalized (as in RENORMALIZE-ACTIVATIONS with L2-UPPER-BOUND).

It is assumed that if the weights either belong to an activation lump or are simply added to the activations (i.e. they are biases).

Package

mgl-bp.

Source

lumps.lisp.

Function: as-column-vector (a)
Package

mgl-util.

Source

util.lisp.

Function: bag (seq fn &key ratio n weight replacement key test random-state)

Sample from SEQ with SAMPLE-FROM (passing RATIO, WEIGHT, REPLACEMENT), or SAMPLE-STRATIFIED if KEY is not NIL. Call FN with the sample. If N is NIL then keep repeating this until FN performs a non-local exit. Else N must be a non-negative integer, N iterations will be performed, the primary values returned by FN collected into a list and returned. See SAMPLE-FROM and SAMPLE-STRATIFIED for examples.

Package

mgl-resample.

Source

resample.lisp.

Function: bag-cv (data fn &key n n-folds folds split-fn pass-fold random-state)

Perform cross-validation on different shuffles of DATA N times and collect the results. Since CROSS-VALIDATE collects the return values of FN, the return value of this function is a list of lists of FN results. If N is NIL, don’t collect anything just keep doing repeated CVs until FN performs a non-local exit.

The following example simply collects the test and training sets for 2-fold CV repeated 3 times with shuffled data:

“‘commonlisp
;;; This is non-deterministic.
(bag-cv ’(0 1 2 3 4) #’list :n 3 :n-folds 2)
=> ((((2 3 4) (1 0))
((1 0) (2 3 4)))
(((2 1 0) (4 3))
((4 3) (2 1 0)))
(((1 0 3) (2 4))
((2 4) (1 0 3))))
“‘

CV bagging is useful when a single CV is not producing stable results. As an ensemble method, CV bagging has the advantage over bagging that each example will occur the same number of times and after the first CV is complete there is a complete but less reliable estimate for each example which gets refined by further CVs.

Package

mgl-resample.

Source

resample.lisp.

Function: binarize-randomly (x)

Return 1 with X probability and 0 otherwise.

Package

mgl-util.

Source

util.lisp.

Function: binomial-log-likelihood-ratio (k1 n1 k2 n2)

See "Accurate Methods for the Statistics of Surprise and Coincidence" by Ted Dunning (http://citeseer.ist.psu.edu/29096.html).

All classes must have non-zero counts, that is, K1, N1-K1, K2, N2-K2 are positive integers. To ensure this - and also as kind of prior - add a small number such as 1 to K1, K2 and 2 to N1, N2 before calling.

Package

mgl-util.

Source

util.lisp.

Function: bleu (candidates references &key candidate-key reference-key n)

Compute the [BLEU score](http://en.wikipedia.org/wiki/BLEU) for
bilingual CORPUS. BLEU measures how good a translation is compared
to human reference translations.

CANDIDATES (keyed by CANDIDATE-KEY) and REFERENCES (keyed by
REFERENCE-KEY) are sequences of sentences. A sentence is a sequence
of words. Words are compared with EQUAL, and may be any kind of
object (not necessarily strings).

Currently there is no support for multiple reference translations. N
determines the largest n-grams to consider.

The first return value is the BLEU score (between 0 and 1, not as a
percentage). The second value is the sum of the lengths of
CANDIDATES divided by the sum of the lengths of REFERENCES (or NIL,
if the denominator is 0). The third is a list of n-gram
precisions (also between 0 and 1 or NIL), one for each element in
\[1..‘N‘].

This is basically a reimplementation of [multi-bleu.perl](https://github.com/moses-smt/mosesdecoder/blob/master/scripts/generic/multi-bleu.perl).

“‘cl-transcript
(bleu ’((1 2 3 4) (a b))
’((1 2 3 4) (1 2)))
=> 0.8408964
=> 1
=> (;; 1-gram precision: 4/6
2/3
;; 2-gram precision: 3/4
3/4
;; 3-gram precision: 2/2
1
;; 4-gram precision: 1/1
1)
“‘

Package

mgl-nlp.

Source

nlp.lisp.

Function: call-periodic-fn (n fn &rest args)
Package

mgl-util.

Source

util.lisp.

Function: call-periodic-fn! (n fn &rest args)
Package

mgl-util.

Source

util.lisp.

Function: call-repeatably (fn &key seed)
Package

mgl-util.

Source

util.lisp.

Function: cg (fn w &key max-n-line-searches max-n-evaluations-per-line-search max-n-evaluations sig rho int ext ratio spare-vectors)

CG-OPTIMIZER passes each batch of data to this function with its CG-ARGS passed on.

Minimize a differentiable multivariate function with conjugate gradient. The Polak-Ribiere flavour of conjugate gradients is used to compute search directions, and a line search using quadratic and cubic polynomial approximations and the Wolfe-Powell stopping criteria is used together with the slope ratio method for guessing initial step sizes. Additionally a bunch of checks are made to make sure that exploration is taking place and that extrapolation will not be unboundedly large.

FN is a function of two parameters: WEIGHTS and DERIVATIVES. WEIGHTS is a MAT of the same size as W that is where the search start from. DERIVATIVES is also a MAT of that size and it is where FN shall place the partial derivatives. FN returns the value of the function that is being minimized.

CG performs a number of line searches and invokes FN at each step. A line search invokes FN at most MAX-N-EVALUATIONS-PER-LINE-SEARCH number of times and can succeed in improving the minimum by the sufficient margin or it can fail. Note, the even a failed line search may improve further and hence change the weights it’s just that the improvement was deemed too small. CG stops when either:

- two line searches fail in a row
- MAX-N-LINE-SEARCHES is reached
- MAX-N-EVALUATIONS is reached

CG returns a MAT that contains the best weights, the minimum, the number of line searches performed, the number of succesful line searches and the number of evaluations.

When using MAX-N-EVALUATIONS remember that there is an extra evaluation of FN before the first line search.

SPARE-VECTORS is a list of preallocated MATs of the same size as W. Passing 6 of them covers the current need of the algorithm and it will not cons up vectors of size W at all.

NOTE: If the function terminates within a few iterations, it could be an indication that the function values and derivatives are not consistent (ie, there may be a bug in the implementation of FN function).

SIG and RHO are the constants controlling the Wolfe-Powell conditions. SIG is the maximum allowed absolute ratio between previous and new slopes (derivatives in the search direction), thus setting SIG to low (positive) values forces higher precision in the line-searches. RHO is the minimum allowed fraction of the expected (from the slope at the initial point in the linesearch). Constants must satisfy 0 < RHO < SIG < 1. Tuning of SIG (depending on the nature of the function to be optimized) may speed up the minimization; it is probably not worth playing much with RHO.

Package

mgl-cg.

Source

conjugate-gradient.lisp.

Function: chunk-lump-name (chunk-name kind)

The name of the lump that represents CHUNK.

Package

mgl-unroll.

Source

unroll.lisp.

Function: clear-running-stat (stat)
Package

mgl-util.

Source

util.lisp.

Function: clip-l2-norm (mats l2-upper-bound &key callback)

Scale MATS so that their $L_2$ norm does not exceed L2-UPPER-BOUND.

Compute the norm of of MATS as if they were a single vector. If the norm is greater than L2-UPPER-BOUND, then scale each matrix destructively by the norm divided by L2-UPPER-BOUND and if non-NIL call the function CALLBACK with the scaling factor.

Package

mgl-gd.

Source

gradient-descent.lisp.

Function: cloud-chunk-among-chunks (cloud chunks)
Package

mgl-bm.

Source

boltzmann-machine.lisp.

Function: command (command)
Package

mgl-gnuplot.

Source

gnuplot.lisp.

Function: conditioning-cloud-p (cloud)
Package

mgl-bm.

Source

boltzmann-machine.lisp.

Function: confusion-matrix-accuracy (matrix &key filter)

Return the overall accuracy of the results in MATRIX. It’s computed as the number of correctly classified cases (hits) divided by the name of cases. Return the number of hits and the number of cases as the second and third value. If FILTER function is given, then call it with the target and the prediction of the cell. Disregard cell for which FILTER returns NIL.

Precision and recall can be easily computed by giving the right filter, although those are provided in separate convenience functions.

Package

mgl-core.

Source

classification.lisp.

Function: confusion-matrix-precision (matrix prediction)

Return the accuracy over the cases when the classifier said PREDICTION.

Package

mgl-core.

Source

classification.lisp.

Function: confusion-matrix-recall (matrix target)

Return the accuracy over the cases when the correct class is TARGET.

Package

mgl-core.

Source

classification.lisp.

Function: count-features (documents mapper &key key)

Return scored features as an EQUAL hash table whose keys are features of DOCUMENTS and values are counts of occurrences of features. MAPPER takes a function and a document and calls function with features of the document.

“‘cl-transcript
(sort (alexandria:hash-table-alist
(count-features ’(("hello" "world")
("this" "is" "our" "world"))
(lambda (fn document)
(map nil fn document))))
#’string< :key #’car)
=> (("hello" . 1) ("is" . 1) ("our" . 1) ("this" . 1) ("world" . 2)) “‘

Package

mgl-core.

Source

feature.lisp.

Function: cross-validate (data fn &key n-folds folds split-fn pass-fold)

Map FN over the FOLDS of DATA split with SPLIT-FN and collect the results in a list. The simplest demonstration is:

“‘cl-transcript
(cross-validate ’(0 1 2 3 4)
(lambda (test training)
(list test training))
:n-folds 5)
=> (((0) (1 2 3 4))
((1) (0 2 3 4))
((2) (0 1 3 4))
((3) (0 1 2 4))
((4) (0 1 2 3)))
“‘

Of course, in practice one would typically train a model and return the trained model and/or its score on TEST. Also, sometimes one may want to do only some of the folds and remember which ones they were:

“‘cl-transcript
(cross-validate ’(0 1 2 3 4)
(lambda (fold test training)
(list :fold fold test training))
:folds ’(2 3)
:pass-fold t)
=> ((:fold 2 (2) (0 1 3 4))
(:fold 3 (3) (0 1 2 4)))
“‘

Finally, the way the data is split can be customized. By default SPLIT-FOLD/MOD is called with the arguments DATA, the fold (from among FOLDS) and N-FOLDS. SPLIT-FOLD/MOD returns two values which are then passed on to FN. One can use SPLIT-FOLD/CONT or SPLIT-STRATIFIED or any other function that works with these arguments. The only real constraint is that FN has to take as many arguments (plus the fold argument if PASS-FOLD) as SPLIT-FN returns.

Package

mgl-resample.

Source

resample.lisp.

Function: data* (data options)
Package

mgl-gnuplot.

Source

gnuplot.lisp.

Function: dbm->dbn (dbm &key rbm-class dbn-class dbn-initargs)

Convert DBM to a DBN by discarding intralayer connections and doubling activations of clouds where necessary. If a chunk does not have input from below then scale its input from above by 2; similarly, if a chunk does not have input from above then scale its input from below by 2. By default, weights are shared between clouds and their copies.

For now, unrolling the resulting DBN to a BPN is not supported.

Package

mgl-bm.

Source

boltzmann-machine.lisp.

Function: decay-rate-to-half-life (decay-rate)
Package

mgl-util.

Source

util.lisp.

Function: decay-to-half-life (decay)
Package

mgl-util.

Source

util.lisp.

Function: down-dbm (dbm)

Do a single downward pass in DBM, propagating the mean-field much like performing approximate inference, but in the other direction. Disregard intralayer and upward connections, double activations to chunks having downward connections.

Package

mgl-bm.

Source

boltzmann-machine.lisp.

Function: down-mean-field (dbn)

Propagate the means down from the means of DBN.

Package

mgl-bm.

Source

deep-belief-network.lisp.

Function: end-session (stream)
Package

mgl-gnuplot.

Source

gnuplot.lisp.

Function: ensure-softmax-target-matrix (softmax-xe-loss n)

Set TARGET of SOFTMAX-XE-LOSS to a MAT capable of holding the dense target values for N stripes.

Package

mgl-bp.

Source

lumps.lisp.

Function: feature-disambiguities (documents mapper class-fn &key classes)

Return scored features as an EQUAL hash table whose keys are features of DOCUMENTS and values are their _disambiguities_. MAPPER takes a function and a document and calls function with features of the document.

From the paper ’Using Ambiguity Measure Feature Selection Algorithm for Support Vector Machine Classifier’.

Package

mgl-core.

Source

feature.lisp.

Function: feature-llrs (documents mapper class-fn &key classes)

Return scored features as an EQUAL hash table whose keys are features of DOCUMENTS and values are their log likelihood ratios. MAPPER takes a function and a document and calls function with features of the document.

“‘cl-transcript
(sort (alexandria:hash-table-alist
(feature-llrs ’((:a "hello" "world")
(:b "this" "is" "our" "world")) (lambda (fn document)
(map nil fn (rest document))) #’first))
#’string< :key #’car)
=> (("hello" . 2.6032386) ("is" . 2.6032386) ("our" . 2.6032386) ("this" . 2.6032386) ("world" . 4.8428774e-8))
“‘

Package

mgl-core.

Source

feature.lisp.

Function: file* (filename options)
Package

mgl-gnuplot.

Source

gnuplot.lisp.

Function: find-clump (name bpn &key errorp)

Find the clump with NAME among CLUMPS of BPN. As always, names are compared with EQUAL. If not found, then return NIL or signal and error depending on ERRORP.

Package

mgl-bp.

Source

backprop.lisp.

Function: flt (x)
Package

mgl-util.

Source

util.lisp.

Function: flt-vector (&rest args)
Package

mgl-util.

Source

util.lisp.

Function: fn* (expression options)
Package

mgl-gnuplot.

Source

gnuplot.lisp.

Function: fracture (fractions seq &key weight)

Partition SEQ into a number of subsequences. FRACTIONS is either a positive integer or a list of non-negative real numbers. WEIGHT is NIL or a function that returns a non-negative real number when called with an element from SEQ. If FRACTIONS is a positive integer then return a list of that many subsequences with equal sum of weights bar rounding errors, else partition SEQ into subsequences, where the sum of weights of subsequence I is proportional to element I of FRACTIONS. If WEIGHT is NIL, then it’s element is assumed to have the same weight.

To split into 5 sequences:

“‘cl-transcript
(fracture 5 ’(0 1 2 3 4 5 6 7 8 9))
=> ((0 1) (2 3) (4 5) (6 7) (8 9))
“‘

To split into two sequences whose lengths are proportional to 2 and 3:

“‘cl-transcript
(fracture ’(2 3) ’(0 1 2 3 4 5 6 7 8 9))
=> ((0 1 2 3) (4 5 6 7 8 9))
“‘

Package

mgl-resample.

Source

resample.lisp.

Function: fracture-stratified (fractions seq &key key test weight)

Similar to FRACTURE, but also makes sure that keys are evenly distributed among the partitions (see STRATIFY). It can be useful for classification tasks to partition the data set while keeping the distribution of classes the same.

Note that the sets returned are not in random order. In fact, they are sorted internally by KEY.

For example, to make two splits with approximately the same number of even and odd numbers:

“‘cl-transcript
(fracture-stratified 2 ’(0 1 2 3 4 5 6 7 8 9) :key #’evenp)
=> ((0 2 1 3) (4 6 8 5 7 9))
“‘

Package

mgl-resample.

Source

resample.lisp.

Function: gaussian-random-1 ()
Package

mgl-util.

Source

util.lisp.

Function: gp-confidences-as-plot-data (gp inputs &key means covariances levels-and-options)

Return a list of MGL-GNUPLOT:DATA-MAPPINGs, one for each level in LEVELS-AND-OPTIONS (a list of (LEVEL OPTIONS)). Each mapping contains INPUTS in its first column, and MEANS + LEVEL*VARIANCES in the second.

Package

mgl-gp.

Source

gaussian-process.lisp.

Function: gp-covariances (gp x1 &optional x2)
Package

mgl-gp.

Source

gaussian-process.lisp.

Function: gp-means-and-covariances (gp x1 &optional x2)
Package

mgl-gp.

Source

gaussian-process.lisp.

Function: gp-samples-as-plot-data (gp inputs &key means covariances options)

Returns a matrix that contains INPUTS in its first column, and a sample taken with SAMPLE-GP in its second.

Package

mgl-gp.

Source

gaussian-process.lisp.

Function: group (seq group-size &key start end)
Package

mgl-util.

Source

util.lisp.

Function: half-life-to-decay (half-life)

b^h=0.5, b=0.5^(1/h)

Package

mgl-util.

Source

util.lisp.

Function: half-life-to-decay-rate (half-life)
Package

mgl-util.

Source

util.lisp.

Function: hash-table->vector (hash-table)
Package

mgl-util.

Source

util.lisp.

Function: initialize-fnn-from-bm (fnn bm inits)

Initialize FNN from the weights of BM according to cloud INITS that was returned by UNROLL-DBN or UNROLL-DBM.

Package

mgl-unroll.

Source

unroll.lisp.

Function: inputs->nodes (bm)

Copy the previously clamped INPUTS to NODES as if SET-INPUT were called with the same parameters.

Package

mgl-bm.

Source

boltzmann-machine.lisp.

Function: insert-into-sorted-vector (item vector pred &key key max-length)

Insert ITEM into VECTOR while keeping it sorted by PRED. Extend the vector if needed while respecting MAX-LENGTH.

Package

mgl-util.

Source

util.lisp.

Function: invert-permutation (permutation)
Package

mgl-util.

Source

util.lisp.

Function: lag (name &key lag rnn path)

In RNN or if it’s NIL the RNN being extended with another
BPN (called _unfolding_), look up the CLUMP with NAME in the BPN that’s LAG number of time steps before the BPN being added. If this function is called from UNFOLDER of an RNN (which is what happens behind the scene in the body of BUILD-RNN), then it returns an opaque object representing a lagged connection to a clump, else it returns the CLUMP itself.

FIXDOC: PATH

Package

mgl-bp.

Source

backprop.lisp.

Function: last1 (seq)
Package

mgl-util.

Source

util.lisp.

Function: list-samples (sampler max-size)

Return a list of samples of length at most MAX-SIZE or less if SAMPLER runs out.

Package

mgl-dataset.

Source

dataset.lisp.

Function: list-segments (gradient-source)

A utility function that returns the list of segments from MAP-SEGMENTS on GRADIENT-SOURCE.

Package

mgl-opt.

Source

optimize.lisp.

Function: load-state (filename object)

Load weights of OBJECT from FILENAME. Return OBJECT.

Package

mgl-core.

Source

core.lisp.

Function: log-mat-room (&key verbose)
Package

mgl-log.

Source

log.lisp.

Function: log-msg (format &rest args)
Package

mgl-log.

Source

log.lisp.

Function: log-padded (attributeds)

Log (see LOG-MSG) ATTRIBUTEDS non-escaped (as in PRINC or ~A) with the output being as table-like as possible.

Package

mgl-core.

Source

counter.lisp.

Function: make-classification-accuracy-monitors (model &key operation-mode attributes label-index-fn)

Return a list of MONITOR objects associated with [CLASSIFICATION-ACCURACY-COUNTER][]s. LABEL-INDEX-FN is a function like LABEL-INDEX. See that function for more.

Implemented in terms of MAKE-CLASSIFICATION-ACCURACY-MONITORS*.

Package

mgl-core.

Source

classification.lisp.

Function: make-confusion-matrix (&key test)

Classes are compared with TEST.

Package

mgl-core.

Source

classification.lisp.

Function: make-cost-monitors (model &key operation-mode attributes)

Return a list of MONITOR objects, each associated with one BASIC-COUNTER with attribute :TYPE "cost". Implemented in terms of MAKE-COST-MONITORS*.

Package

mgl-opt.

Source

optimize.lisp.

Function: make-cross-entropy-monitors (model &key operation-mode attributes label-index-distribution-fn)

Return a list of MONITOR objects associated with [CROSS-ENTROPY-COUNTER][]s. LABEL-INDEX-DISTRIBUTION-FN is a function like LABEL-INDEX-DISTRIBUTION. See that function for more.

Implemented in terms of MAKE-CROSS-ENTROPY-MONITORS*.

Package

mgl-core.

Source

classification.lisp.

Function: make-indexer (scored-features n &key start class)

Take the top N features from SCORED-FEATURES (see @MGL-FEATURE-SELECTION), assign indices to them starting from START. Return an ENCODER/DECODER (or another CLASS) that converts between objects and indices.

Package

mgl-core.

Source

feature.lisp.

Function: make-label-monitors (model &key operation-mode attributes label-index-fn label-index-distribution-fn)

Return classification accuracy and cross-entropy monitors. See MAKE-CLASSIFICATION-ACCURACY-MONITORS and MAKE-CROSS-ENTROPY-MONITORS for a description of paramters.

Package

mgl-core.

Source

classification.lisp.

Function: make-n-gram-mappee (function n)

Make a function of a single argument that’s suitable as the function argument to a mapper function. It calls FUNCTION with every N element.

“‘cl-transcript
(map nil (make-n-gram-mappee #’print 3) ’(a b c d e))
..
.. (A B C)
.. (B C D)
.. (C D E)
“‘

Package

mgl-nlp.

Source

nlp.lisp.

Function: make-random-generator (seq &key reorder)

Return a function that returns elements of VECTOR in random order without end. When there are no more elements, start over with a different random order.

Package

mgl-util.

Source

util.lisp.

Function: make-random-sampler (seq &key max-n-samples reorder)

Create a sampler that returns elements of SEQ in random order. If MAX-N-SAMPLES is non-nil, then at most MAX-N-SAMPLES are sampled. The first pass over a shuffled copy of SEQ, and this copy is reshuffled whenever the sampler reaches the end of it. Shuffling is performed by calling the REORDER function.

Package

mgl-dataset.

Source

dataset.lisp.

Function: make-reconstruction-monitors (model &key operation-mode attributes)
Package

mgl-bm.

Source

boltzmann-machine.lisp.

Function: make-sequence-generator (seq)

Return a function that returns elements of SEQ in order without end. When there are no more elements, start over.

Package

mgl-util.

Source

util.lisp.

Function: make-sequence-sampler (seq &key max-n-samples)

Create a sampler that returns elements of SEQ in their original order. If MAX-N-SAMPLES is non-nil, then at most MAX-N-SAMPLES are sampled.

Package

mgl-dataset.

Source

dataset.lisp.

Function: make-sorted-group-generator (generator pred group-size &key key randomize-size)
Package

mgl-util.

Source

util.lisp.

Function: make-step-monitor-monitors (rnn &key counter-values-fn make-counter)

Return a list of monitors, one for every monitor in STEP-MONITORS
of RNN. These monitors extract the results from their warp counterpairs with COUNTER-VALUES-FN and add them to their own counter that’s created by MAKE-COUNTER. Wow. Ew. The idea is that one does something like this do monitor warped prediction:

“‘commonlisp
(let ((*warp-time* t))
(setf (step-monitors rnn)
(make-cost-monitors rnn :attributes ’(:event "warped pred."))) (monitor-bpn-results dataset rnn
;; Just collect and reset the warp
;; monitors after each batch of
;; instances.
(make-step-monitor-monitors rnn)))
“‘

Package

mgl-bp.

Source

backprop.lisp.

Function: map-batches-for-model (fn dataset model)

Call FN with batches of instances from DATASET suitable for MODEL. The number of instances in a batch is MAX-N-STRIPES of MODEL or less if there are no more instances left.

Package

mgl-core.

Source

core.lisp.

Function: map-dataset (fn dataset)

Call FN with each instance in DATASET. This is basically equivalent to iterating over the elements of a sequence or a sampler (see @MGL-SAMPLER).

Package

mgl-dataset.

Source

dataset.lisp.

Function: map-datasets (fn datasets &key impute)

Call FN with a list of instances, one from each dataset in
DATASETS. Return nothing. If IMPUTE is specified then iterate until the largest dataset is consumed imputing IMPUTE for missing values. If IMPUTE is not specified then iterate until the smallest dataset runs out.

“‘cl-transcript
(map-datasets #’prin1 ’((0 1 2) (:a :b)))
.. (0 :A)(1 :B)

(map-datasets #’prin1 ’((0 1 2) (:a :b)) :impute nil)
.. (0 :A)(1 :B)(2 NIL)
“‘

It is of course allowed to mix sequences with samplers:

“‘cl-transcript
(map-datasets #’prin1
(list ’(0 1 2)
(make-sequence-sampler ’(:a :b) :max-n-samples 2))) .. (0 :A)(1 :B)
“‘

Package

mgl-dataset.

Source

dataset.lisp.

Function: mark-everything-present (object)
Package

mgl-bm.

Source

boltzmann-machine.lisp.

Function: max-position (seq start end)
Package

mgl-util.

Source

util.lisp.

Function: max-row-positions (mat &key start end)

Find the colums with the maximum in each row of the 2d MAT and return them as a list.

Package

mgl-util.

Source

util.lisp.

Function: measure-classification-accuracy (truths predictions &key test truth-key prediction-key weight)

Return the number of correct classifications and as the second value the number of instances (equal to length of TRUTHS in the non-weighted case). TRUTHS (keyed by TRUTH-KEY) is a sequence of opaque class labels compared with TEST to another sequence of classes labels in PREDICTIONS (keyed by PREDICTION-KEY). If WEIGHT is non-nil, then it is a function that returns the weight of an element of TRUTHS. Weighted cases add their weight to both counts (returned as the first and second values) instead of 1 as in the non-weighted case.

Note how the returned values are suitable for MULTIPLE-VALUE-CALL with #’ADD-TO-COUNTER and a CLASSIFICATION-ACCURACY-COUNTER.

Package

mgl-core.

Source

classification.lisp.

Function: measure-confusion (truths predictions &key test truth-key prediction-key weight)

Create a CONFUSION-MATRIX from TRUTHS and PREDICTIONS.
TRUTHS (keyed by TRUTH-KEY) is a sequence of class labels compared with TEST to another sequence of class labels in PREDICTIONS (keyed by PREDICTION-KEY). If WEIGHT is non-nil, then it is a function that returns the weight of an element of TRUTHS. Weighted cases add their weight to both counts (returned as the first and second values).

Note how the returned confusion matrix can be added to another with ADD-TO-COUNTER.

Package

mgl-core.

Source

classification.lisp.

Function: measure-cross-entropy (truths predictions &key truth-key prediction-key min-prediction-pr)

Return the sum of the cross-entropy between pairs of elements with the same index of TRUTHS and PREDICTIONS. TRUTH-KEY is a function that’s when applied to an element of TRUTHS returns a sequence representing some kind of discrete target distribution (P in the definition below). TRUTH-KEY may be NIL which is equivalent to the IDENTITY function. PREDICTION-KEY is the same kind of key for PREDICTIONS, but the sequence it returns represents a distribution that approximates (Q below) the true one.

Cross-entropy of the true and approximating distributions is defined as:

cross-entropy(p,q) = - sum_i p(i) * log(q(i))

of which this function returns the sum over the pairs of elements of TRUTHS and PREDICTIONS keyed by TRUTH-KEY and PREDICTION-KEY.

Due to the logarithm, if q(i) is close to zero, we run into numerical problems. To prevent this, all q(i) that are less than MIN-PREDICTION-PR are treated as if they were MIN-PREDICTION-PR.

The second value returned is the sum of p(i) over all TRUTHS and all ‘I‘. This is normally equal to ‘(LENGTH TRUTHS)‘, since elements of TRUTHS represent a probability distribution, but this is not enforced which allows relative importance of elements to be controlled.

The third value returned is a plist that maps each index occurring in the distribution sequences to a list of two elements:

sum_j p_j(i) * log(q_j(i))

and

sum_j p_j(i)

where ‘J‘ indexes into TRUTHS and PREDICTIONS.

(measure-cross-entropy ’((0 1 0)) ’((0.1 0.7 0.2)))
=> 0.35667497
1
(2 (0.0 0)
1 (0.35667497 1)
0 (0.0 0))

Note how the returned values are suitable for MULTIPLE-VALUE-CALL with #’ADD-TO-COUNTER and a CROSS-ENTROPY-COUNTER.

Package

mgl-core.

Source

classification.lisp.

Function: measure-roc-auc (predictions pred &key key weight)

Return the area under the ROC curve for PREDICTIONS representing predictions for a binary classification problem. PRED is a predicate function for deciding whether a prediction belongs to the so called positive class. KEY returns a number for each element which is the predictor’s idea of how much that element is likely to belong to the class, although it’s not necessarily a probability.

If WEIGHT is NIL, then all elements of PREDICTIONS count as 1 towards the unnormalized sum within AUC. Else WEIGHT must be a function like KEY, but it should return the importance (a positive real number) of elements. If the weight of an prediction is 2 then it’s as if there were another identical copy of that prediction in PREDICTIONS.

The algorithm is based on algorithm 2 in the paper ’An introduction to ROC analysis’ by Tom Fawcett.

ROC AUC is equal to the probability of a randomly chosen positive having higher KEY (score) than a randomly chosen negative element. With equal scores in mind, a more precise version is: AUC is the expectation of the above probability over all possible sequences sorted by scores.

Package

mgl-core.

Source

classification.lisp.

Function: merge-cloud-specs (specs default-specs)

Combine cloud SPECS and DEFAULT-SPECS. If the first element of SPECS is :MERGE then merge them else return SPECS. Merging concatenates them but removes those specs from DEFAULT-SPECS that are between chunks that have a spec in SPECS. If a spec has CLASS NIL then it is removed as well. A cloud spec at minimum specifies the name of the chunks it connects:

(:chunk1 inputs :chunk2 features)

in which case it defaults to be a FULL-CLOUD. If that is not desired then the class can be specified:

(:chunk1 inputs :chunk2 features :class factored-cloud)

To remove a cloud from DEFAULT-SPECS use :CLASS NIL:

(:chunk1 inputs :chunk2 features :class nil)

Other initargs are passed as is to MAKE-INSTANCE:

(:chunk1 inputs :chunk2 features :class factored-cloud :rank 10)

You may also pass a CLOUD object as a spec.

Package

mgl-bm.

Source

boltzmann-machine.lisp.

Function: minimize (optimizer gradient-source &key weights dataset)

Minimize the value of the real valued function represented by GRADIENT-SOURCE by updating some of its parameters in WEIGHTS (a MAT or a sequence of MATs). Return WEIGHTS. DATASET (see MGL:@MGL-DATASET) is a set of unoptimized parameters of the same function. For example, WEIGHTS may be the weights of a neural network while DATASET is the training set consisting of inputs suitable for SET-INPUT. The default
DATASET, (*INFINITELY-EMPTY-DATASET*) is suitable for when all parameters are optimized, so there is nothing left to come from the environment.

Optimization terminates if DATASET is a sampler and it runs out or when some other condition met (see TERMINATION, for example). If DATASET is a SEQUENCE, then it is reused over and over again.

Examples for various optimizers are provided in MGL-GD:@MGL-GD and MGL-CG:@MGL-CG.

Package

mgl-opt.

Source

optimize.lisp.

Function: monitor-bm-mean-field-bottom-up (dataset bm monitors)
Package

mgl-bm.

Source

boltzmann-machine.lisp.

Function: monitor-bm-mean-field-reconstructions (dataset bm monitors &key set-visible-p)

Like COLLECT-BM-MEAN-FIELD-ERRORS but reconstruct the labels even if they were missing.

Package

mgl-bm.

Source

boltzmann-machine.lisp.

Function: monitor-bpn-results (dataset bpn monitors)

For every batch (of size MAX-N-STRIPES of BPN) of instances in DATASET, set the batch as the next input with SET-INPUT, perform a FORWARD pass and apply MONITORS to the BPN (with APPLY-MONITORS). Finally, return the counters of MONITORS. This is built on top of MONITOR-MODEL-RESULTS.

Package

mgl-bp.

Source

backprop.lisp.

Function: monitor-dbn-mean-field-bottom-up (dataset dbn monitors)

Run the mean field up to RBM then down to the bottom and collect the errors with COLLECT-BATCH-ERRORS. By default, return the rmse at each level in the DBN.

Package

mgl-bm.

Source

deep-belief-network.lisp.

Function: monitor-dbn-mean-field-reconstructions (dataset dbn monitors &key set-visible-p)

Run the mean field up to RBM then down to the bottom and collect the errors with COLLECT-BATCH-ERRORS. By default, return the rmse at each level in the DBN.

Package

mgl-bm.

Source

deep-belief-network.lisp.

Function: monitor-model-results (fn dataset model monitors)

Call FN with batches of instances from DATASET until it runs
out (as in DO-BATCHES-FOR-MODEL). FN is supposed to apply MODEL to the batch and return some kind of result (for neural networks, the result is the model state itself). Apply MONITORS to each batch and the result returned by FN for that batch. Finally, return the list of counters of MONITORS.

The purpose of this function is to collect various results and statistics (such as error measures) efficiently by applying the model only once, leaving extraction of quantities of interest from the model’s results to MONITORS.

See the model specific versions of this functions such as MGL-BP:MONITOR-BPN-RESULTS.

Package

mgl-core.

Source

monitor.lisp.

Function: monitor-optimization-periodically (optimizer periodic-fns)

For each periodic function in the list of PERIODIC-FNS, add a
monitor to OPTIMIZER’s ON-OPTIMIZATION-STARTED, ON-OPTIMIZATION-FINISHED and ON-N-INSTANCES-CHANGED hooks. The monitors are simple functions that just call each periodic function with the event parameters (OPTIMIZER GRADIENT-SOURCE N-INSTANCES). Return OPTIMIZER.

To log and reset the monitors of the gradient source after every
1000 instances seen by OPTIMIZER:

(monitor-optimization-periodically optimizer
’((:fn log-my-test-error :period 2000)
(:fn reset-optimization-monitors :period 1000
:last-eval 0)))

Note how we don’t pass it’s allowed to just pass the initargs for a PERIODIC-FN instead of PERIODIC-FN itself. The :LAST-EVAL 0 bit prevents RESET-OPTIMIZATION-MONITORS from being called at the start of the optimization when the monitors are empty anyway.

Package

mgl-opt.

Source

optimize.lisp.

Function: multinomial-log-likelihood-ratio (k1 k2)

See "Accurate Methods for the Statistics of Surprise and Coincidence" by Ted Dunning (http://citeseer.ist.psu.edu/29096.html).

K1 is the number of outcomes in each class. K2 is the same in a possibly different process.

All elements in K1 and K2 are positive integers. To ensure this - and also as kind of prior - add a small number such as 1 each element in K1 and K2 before calling.

Package

mgl-util.

Source

util.lisp.

Function: n-rbms (dbn)
Setf Expander: (setf n-rbms) (dbn)
Package

mgl-bm.

Source

deep-belief-network.lisp.

Function: name= (x y)

Return T if X and Y are EQL or if they are structured components whose elements are EQUAL. Strings and bit-vectors are EQUAL if they are the same length and have identical components. Other arrays must be EQ to be EQUAL.

Package

mgl-common.

Alias for

equal.

Function: nodes->inputs (bm)

Copy NODES to INPUTS.

Package

mgl-bm.

Source

boltzmann-machine.lisp.

Function: permute (seq permutation)
Package

mgl-util.

Source

util.lisp.

Function: plot* (mappings)
Package

mgl-gnuplot.

Source

gnuplot.lisp.

Function: poisson-random (mean)
Package

mgl-util.

Source

util.lisp.

Function: populate-map-cache (fnn dbm samples &key key convert-to-dbm-sample-fn if-exists periodic-fn)

Populate the CLAMPING-CACHE of the MAP lumps of FNN unrolled from DBM. The values for the MAP lumps are taken from mean field of the correspending chunk of the DBM. What happens when the cache already has an entry for a sample is determined by IF-EXISTS: if :SKIP, the default, the cache is unchanged; if :SUPERSEDE, the cache entry is replaced by the calculated contents; if :APPEND, the new (lump array) entries are appended to the existing ones; if :ERROR, an error is signalled.

Package

mgl-unroll.

Source

unroll.lisp.

Function: print-table (list &key stream empty-value repeat-marker compactp new-line-prefix)
Package

mgl-util.

Source

util.lisp.

Function: rank (cloud)
Package

mgl-bm.

Source

boltzmann-machine.lisp.

Function: read-state (object stream)

Read the weights of OBJECT from the bivalent STREAM where weights mean the learnt parameters. There is currently no sanity checking of data which will most certainly change in the future together with the serialization format. Return OBJECT.

Package

mgl-core.

Source

core.lisp.

Function: reconstruction-error (bm)

Return the squared norm of INPUTS - NODES not considering constant or conditioning chunks that aren’t reconstructed in any case. The second value returned is the number of nodes that contributed to the error.

Package

mgl-bm.

Source

boltzmann-machine.lisp.

Function: reconstruction-rmse (chunks)

Return the squared norm of INPUTS - NODES not considering constant or conditioning chunks that aren’t reconstructed in any case. The second value returned is the number of nodes that contributed to the error.

Package

mgl-bm.

Source

boltzmann-machine.lisp.

Function: renormalize-activations (->v*m-lumps l2-upper-bound)

If the l2 norm of the incoming weight vector of the a unit is larger than L2-UPPER-BOUND then renormalize it to L2-UPPER-BOUND. The list of ->V*M-LUMPS is assumed to be eventually fed to the same lump.

To use it, group the activation clumps into the same GD-OPTIMIZER and hang this function on AFTER-UPDATE-HOOK, that latter of which is done for you ARRANGE-FOR-RENORMALIZING-ACTIVATIONS.

See "Improving neural networks by preventing co-adaptation of feature detectors (Hinton, 2012)", <http://arxiv.org/pdf/1207.0580.pdf>.

Package

mgl-bp.

Source

lumps.lisp.

Function: rows-to-arrays (mat)
Package

mgl-util.

Source

util.lisp.

Function: running-stat-mean (stat)
Package

mgl-util.

Source

util.lisp.

Function: running-stat-variance (stat)
Package

mgl-util.

Source

util.lisp.

Function: sample-from (ratio seq &key weight replacement random-state)

Return a sequence constructed by sampling with or without REPLACEMENT from SEQ. The sum of weights in the result sequence will approximately be the sum of weights of SEQ times RATIO. If WEIGHT is NIL then elements are assumed to have equal weights, else WEIGHT should return a non-negative real number when called with an element of SEQ.

To randomly select half of the elements:

“‘common-lisp
(sample-from 1/2 ’(0 1 2 3 4 5))
=> (5 3 2)
“‘

To randomly select some elements such that the sum of their weights constitute about half of the sum of weights across the whole sequence:

“‘common-lisp
(sample-from 1/2 ’(0 1 2 3 4 5 6 7 8 9) :weight #’identity)
=> ;; sums to 28 that’s near 45/2
(9 4 1 6 8)
“‘

To sample with replacement (that is, allowing the element to be sampled multiple times):

“‘common-lisp
(sample-from 1 ’(0 1 2 3 4 5) :replacement t)
=> (1 1 5 1 4 4)
“‘

Package

mgl-resample.

Source

resample.lisp.

Function: sample-hidden (bm)

Generate samples from the probability distribution defined by the chunk type and the mean that resides in NODES.

Package

mgl-bm.

Source

boltzmann-machine.lisp.

Function: sample-stratified (ratio seq &key weight replacement key test random-state)

Like SAMPLE-FROM but makes sure that the weighted proportion of classes in the result is approximately the same as the proportion in SEQ. See STRATIFY for the description of KEY and TEST.

Package

mgl-resample.

Source

resample.lisp.

Function: sample-visible (bm)

Generate samples from the probability distribution defined by the chunk type and the mean that resides in NODES.

Package

mgl-bm.

Source

boltzmann-machine.lisp.

Function: save-state (filename object &key if-exists ensure)

Save weights of OBJECT to FILENAME. If ENSURE, then ENSURE-DIRECTORIES-EXIST is called on FILENAME. IF-EXISTS is passed on to OPEN. Return OBJECT.

Package

mgl-core.

Source

core.lisp.

Function: scaled-tanh (x)
Package

mgl-util.

Source

util.lisp.

Function: sech (x)
Package

mgl-util.

Source

util.lisp.

Function: segment-set->mat (segment-set mat)

Copy the values of SEGMENT-SET to MAT as if they were concatenated into a single MAT.

Package

mgl-opt.

Source

optimize.lisp.

Function: segment-set<-mat (segment-set mat)

Copy the values of MAT to the weight matrices of SEGMENT-SET as if they were concatenated into a single MAT.

Package

mgl-opt.

Source

optimize.lisp.

Function: select-random-element (seq)
Package

mgl-util.

Source

util.lisp.

Function: set-dropout-and-rescale-activation-weights (lump dropout fnn)

Set the dropout of LUMP to DROPOUT. Find the activation lump to which LUMP is fed and rescale its weights to compensate. There must be exactly on such activation lump or this function will fail.

Package

mgl-unroll.

Source

unroll.lisp.

Function: set-hidden-mean/1 (bm)

Set NODES of the chunks in the hidden layer to the means of their respective probability distributions.

Package

mgl-bm.

Source

boltzmann-machine.lisp.

Function: set-n-instances (optimizer gradient-source n-instances)

Set [N-INSTANCES][(reader iterative-optimizer)] of OPTIMIZER and fire ON-N-INSTANCES-CHANGED. ITERATIVE-OPTIMIZER subclasses must call this to increment [N-INSTANCES][(reader iterative-optimizer)].

Package

mgl-opt.

Source

optimize.lisp.

Function: set-visible-mean/1 (bm)

Set NODES of the chunks in the visible layer to the means of their respective probability distributions.

Package

mgl-bm.

Source

boltzmann-machine.lisp.

Function: settle-hidden-mean-field (bm &key supervisor)

Convenience function on top of SETTLE-MEAN-FIELD.

Package

mgl-bm.

Source

boltzmann-machine.lisp.

Function: settle-mean-field (chunks bm &key other-chunks supervisor)

Do possibly damped mean field updates on CHUNKS until convergence. Compute V’_{t+1}, what would normally be the means, but average it with the previous value: V_{t+1} = k * V_t + (1 - k) * V’{t+1} where K is the damping factor (an FLT between 0 and 1).

Call SUPERVISOR with CHUNKS BM and the iteration. Settling is finished when SUPERVISOR returns NIL. If SUPERVISOR returns a non-nil value then it’s taken to be a damping factor. For no damping return 0.

Package

mgl-bm.

Source

boltzmann-machine.lisp.

Function: settle-visible-mean-field (bm &key supervisor)

Convenience function on top of SETTLE-MEAN-FIELD.

Package

mgl-bm.

Source

boltzmann-machine.lisp.

Function: shuffle (seq)

Copy of SEQ and shuffle it using Fisher-Yates algorithm.

Package

mgl-resample.

Source

resample.lisp.

Function: shuffle! (seq)

Shuffle SEQ using Fisher-Yates algorithm.

Package

mgl-resample.

Source

resample.lisp.

Function: shuffle-groups (seq group-size &key start end)
Package

mgl-util.

Source

util.lisp.

Function: sigmoid (x)
Package

mgl-util.

Source

util.lisp.

Function: sign (x)
Package

mgl-util.

Source

util.lisp.

Function: sorting-permutation (seq pred &key key)
Package

mgl-util.

Source

util.lisp.

Function: split-fold/cont (seq fold n-folds)

Imagine dividing SEQ into N-FOLDS subsequences of the same
size (bar rounding). Return the subsequence of index FOLD as the first value and the all the other subsequences concatenated into one as the second value. The order of elements remains stable. This function is suitable as the SPLIT-FN argument of CROSS-VALIDATE.

Package

mgl-resample.

Source

resample.lisp.

Function: split-fold/mod (seq fold n-folds)

Partition SEQ into two sequences: one with elements of SEQ with indices whose remainder is FOLD when divided with N-FOLDS, and a second one with the rest. The second one is the larger set. The order of elements remains stable. This function is suitable as the SPLIT-FN argument of CROSS-VALIDATE.

Package

mgl-resample.

Source

resample.lisp.

Function: split-plist (list keys)
Package

mgl-util.

Source

util.lisp.

Function: split-stratified (seq fold n-folds &key key test weight)

Split SEQ into N-FOLDS partitions (as in FRACTURE-STRATIFIED). Return the partition of index FOLD as the first value, and the concatenation of the rest as the second value. This function is suitable as the SPLIT-FN argument of CROSS-VALIDATE (mostly likely as a closure with KEY, TEST, WEIGHT bound).

Package

mgl-resample.

Source

resample.lisp.

Function: splot* (mappings)
Package

mgl-gnuplot.

Source

gnuplot.lisp.

Function: spread-strata (seq &key key test)

Return a sequence that’s a reordering of SEQ such that elements belonging to different strata (under KEY and TEST, see STRATIFY) are distributed evenly. The order of elements belonging to the same stratum is unchanged.

For example, to make sure that even and odd numbers are distributed evenly:

“‘cl-transcript
(spread-strata ’(0 2 4 6 8 1 3 5 7 9) :key #’evenp)
=> (0 1 2 3 4 5 6 7 8 9)
“‘

Same thing with unbalanced classes:

“‘cl-transcript
(spread-strata (vector 0 2 3 5 6 1 4)
:key (lambda (x)
(if (member x ’(1 4)) t
nil)))
=> #(0 1 2 3 4 5 6)
“‘

Package

mgl-resample.

Source

resample.lisp.

Function: start-session (&key binary display geometry persistp output error)
Package

mgl-gnuplot.

Source

gnuplot.lisp.

Function: stratify (seq &key key test)

Return the list of strata of SEQ. SEQ is a sequence of elements for which the function KEY returns the class they belong to. Such classes are opaque objects compared for equality with TEST. A stratum is a sequence of elements with the same (under TEST) KEY.

“‘cl-transcript
(stratify ’(0 1 2 3 4 5 6 7 8 9) :key #’evenp)
=> ((0 2 4 6 8) (1 3 5 7 9))
“‘

Package

mgl-resample.

Source

resample.lisp.

Function: subseq* (sequence start &optional end)
Package

mgl-util.

Source

util.lisp.

Function: supervise-mean-field/default (chunks bm iteration &key node-change-limit n-undamped-iterations n-damped-iterations damping-factor)

A supervisor for SETTLE-MEAN-FIELD. Return NIL if the average of the absolute value of change in nodes is below NODE-CHANGE-LIMIT, else return 0 damping for N-UNDAMPED-ITERATIONS then DAMPING-FACTOR for another N-DAMPED-ITERATIONS, then NIL.

Package

mgl-bm.

Source

boltzmann-machine.lisp.

Function: terminate-optimization-p (n-instances termination)

Utility function for subclasses of ITERATIVE-OPTIMIZER. It returns whether optimization is to be terminated based on N-INSTANCES and TERMINATION that are values of the respective accessors of ITERATIVE-OPTIMIZER.

Package

mgl-opt.

Source

optimize.lisp.

Function: time-step (&key rnn)

Return the time step RNN is currently executing or being unfolded for. It is 0 when the RNN is being unfolded for the first time.

Package

mgl-bp.

Source

backprop.lisp.

Function: try-chance (chance)
Package

mgl-util.

Source

util.lisp.

Function: uninterned-symbol-p (object)
Package

mgl-util.

Source

util.lisp.

Function: unroll-dbm (dbm &key chunks map reconstruction)
Package

mgl-unroll.

Source

unroll.lisp.

Function: unroll-dbn (dbn &key bottom-up-only)

Unroll DBN recursively and turn it into a feed-forward backpropagation network. A single RBM in DBN of the form VISIBLE <-> HIDDEN is transformed into a VISIBLE -> HIDDEN -> RECONSTRUCTION-OF-VISIBLE network. While the undirected connection <-> has a common weight matrix for both directions, in the backprop network the weights pertaining to ->’s are distinct but are initialized from the same <-> (with one being the tranpose of it).

If BOTTOM-UP-ONLY then don’t generate the part of the network that represents the top-down flow, that is, skip the reconstructions.

Return backprop network lump definition forms, as the second value ‘inits’: initialization specifications suitable for INITIALIZE-FNN-FROM-BM.

If there is no corresponding chunk in the layer below or there is no rbm below then the chunk is translated into an INPUT lump. Desired outputs and error node are not added. The first element of RMBS is the topmost one (last of the DBN), the one that goes into the middle of the backprop network.

Package

mgl-unroll.

Source

unroll.lisp.

Function: up-dbm (dbm)

Do a single upward pass in DBM, performing approximate inference. Disregard intralayer and downward connections, double activations to chunks having upward connections.

Package

mgl-bm.

Source

boltzmann-machine.lisp.

Function: update-gp (gp inputs outputs &key means covariances)

Update GP with the evidence embodied by INPUTS and the corresponding OUTPUTS. Return a new POSTERIOR-GP. If MEANS and COVARIANCES are given, then GP-MEANS-AND-COVARIANCES is not called.

Package

mgl-gp.

Source

gaussian-process.lisp.

Function: warped-time (&key rnn time lag)

Return the index of the BPN in CLUMPS of RNN whose task it is to execute computation at ‘(- (TIME-STEP RNN) LAG)‘. This is normally the same as TIME-STEP (disregarding LAG). That is, CLUMPS can be indexed by TIME-STEP to get the BPN. However, when *WARP-TIME* is true, execution proceeds in a cycle as the structure of the network allows.

Suppose we have a typical RNN that only ever references the previous time step so its MAX-LAG is 1. Its UNFOLDER returns ‘BPN‘s of identical structure bar a shift in their time lagged connections except for the very first, so WARP-START and WARP-LENGTH are both 1. If *WARP-TIME* is NIL, then the mapping from TIME-STEP to the BPN in CLUMPS is straightforward:

time: | 0 | 1 | 2 | 3 | 4 | 5 ——–+—-+—-+—-+—-+—-+—-
warped: | 0 | 1 | 2 | 3 | 4 | 5 ——–+—-+—-+—-+—-+—-+—-
bpn: | b0 | b1 | b2 | b3 | b4 | b5

When *WARP-TIME* is true, we reuse the ‘B1‘ - ‘B2‘ bpns in a loop:

time: | 0 | 1 | 2 | 3 | 4 | 5 ——–+—-+—-+—-+—-+—-+—-
warped: | 0 | 1 | 2 | 1 | 2 | 1 ——–+—-+—-+—-+—-+—-+—-
bpn: | b0 | b1 | b2 | b1*| b2 | b1*

‘B1*‘ is the same BPN as ‘B1‘, but its connections created by LAG go through warped time and end up referencing ‘B2‘. This way, memory consumption is independent of the number time steps needed to process a sequence or make predictions.

To be able to pull this trick off WARP-START and WARP-LENGTH must be specified when the RNN is instantiated. In general, with *WARP-TIME* ‘(+ WARP-START (MAX 2 WARP-LENGTH))‘ bpns are needed. The 2 comes from the fact that with cycle length 1 a bpn would need to takes its input from itself which is problematic because it has NODES for only one set of values.

Package

mgl-bp.

Source

backprop.lisp.

Function: write-state (object stream)

Write weight of OBJECT to the bivalent STREAM. Return OBJECT.

Package

mgl-core.

Source

core.lisp.

Function: zip-evenly (seqs &key result-type)

Make a single sequence out of the sequences in SEQS so that in the returned sequence indices of elements belonging to the same source sequence are spread evenly across the whole range. The result is a list is RESULT-TYPE is LIST, it’s a vector if RESULT-TYPE is VECTOR. If RESULT-TYPE is NIL, then it’s determined by the type of the first sequence in SEQS.

“‘cl-transcript
(zip-evenly ’((0 2 4) (1 3)))
=> (0 1 2 3 4)
“‘

Package

mgl-resample.

Source

resample.lisp.


6.1.6 Generic functions

Generic Function: accumulate-gradients* (gradient-source sink batch multiplier valuep)

Add MULTIPLIER times the sum of first-order
gradients to accumulators of SINK (normally accessed with DO-GRADIENT-SINK) and if VALUEP, return the sum of values of the function being optimized for a BATCH of instances. GRADIENT-SOURCE is the object representing the function being optimized, SINK is gradient sink.

Note the number of instances in BATCH may be larger than what GRADIENT-SOURCE process in one go (in the sense of say, MAX-N-STRIPES), so DO-BATCHES-FOR-MODEL or something like (GROUP BATCH MAX-N-STRIPES) can be handy.

Package

mgl-opt.

Source

optimize.lisp.

Methods
Method: accumulate-gradients* ((learner bp-learner) gradient-sink batch multiplier valuep)
Source

backprop.lisp.

Method: accumulate-gradients* ((learner bm-pcd-learner) gradient-sink batch multiplier valuep)
Source

boltzmann-machine.lisp.

Method: accumulate-gradients* ((learner rbm-cd-learner) gradient-sink batch multiplier valuep)
Source

boltzmann-machine.lisp.

Method: accumulate-gradients* ((learner sparse-bm-learner) sink batch multiplier valuep)
Source

boltzmann-machine.lisp.

Method: accumulate-gradients* ((diff-fn diffun) gradient-sink batch multiplier valuep)
Source

differentiable-function.lisp.

Method: accumulate-gradients* ((optimizer decayed-cg-optimizer-mixin) gradient-source batch multiplier valuep)
Source

conjugate-gradient.lisp.

Generic Function: add-to-counter (counter &rest args)

Add ARGS to COUNTER in some way. See specialized
methods for type specific documentation. The kind of arguments to be supported is the what the measurer functions (see @MGL-MEASURER) intended to be paired with the counter return as multiple values.

Package

mgl-core.

Source

counter.lisp.

Methods
Method: add-to-counter ((counter cross-entropy-counter) &rest args)
Source

classification.lisp.

Method: add-to-counter ((counter concat-counter) &rest args)
Method: add-to-counter ((counter basic-counter) &rest args)
Generic Reader: after-update-hook (object)
Generic Writer: (setf after-update-hook) (object)
Package

mgl-gd.

Methods
Reader Method: after-update-hook ((gd-optimizer gd-optimizer))
Writer Method: (setf after-update-hook) ((gd-optimizer gd-optimizer))

A list of functions with no arguments called after each weight update.

Source

gradient-descent.lisp.

Target Slot

after-update-hook.

Generic Function: apply-monitor (monitor &rest arguments)

Apply MONITOR to ARGUMENTS. This sound fairly
generic, because it is. MONITOR can be anything, even a simple function or symbol, in which case this is just CL:APPLY. See @MGL-MONITOR for more.

Package

mgl-core.

Source

monitor.lisp.

Methods
Method: apply-monitor ((monitor monitor) &rest arguments)
Method: apply-monitor ((monitor function) &rest arguments)
Method: apply-monitor ((monitor symbol) &rest arguments)
Generic Reader: attributes (object)
Generic Writer: (setf attributes) (object)
Package

mgl-core.

Methods
Reader Method: attributes ((attributed attributed))
Writer Method: (setf attributes) ((attributed attributed))

A plist of attribute keys and values.

Source

counter.lisp.

Target Slot

attributes.

Generic Function: backward (clump)

Compute the partial derivatives of the function
represented by CLUMP and add them to DERIVATIVES of the corresponding argument clumps. The DERIVATIVES of CLUMP contains the sum of partial derivatives of all clumps by the corresponding output. This function is intended to be called after a FORWARD pass.

Take the ->SIGMOID clump for example when the network is being applied to a batch of two instances ‘x1‘ and ‘x2‘. ‘x1‘ and ‘x2‘ are set in the ->INPUT lump X. The sigmoid computes ‘1/(1+exp(-x))‘ where ‘X‘ is its only argument clump.

f(x) = 1/(1+exp(-x))

When BACKWARD is called on the sigmoid lump, its DERIVATIVES is a 2x1 MAT object that contains the partial derivatives of the loss function:

dL(x1)/df
dL(x2)/df

Now the BACKWARD method of the sigmoid needs to add ‘dL(x1)/dx1‘ and ‘dL(x2)/dx2‘ to DERIVATIVES of ‘X‘. Now, ‘dL(x1)/dx1 = dL(x1)/df * df(x1)/dx1‘ and the first term is what we have in DERIVATIVES of the sigmoid so it only needs to calculate the second term.

Package

mgl-bp.

Source

backprop.lisp.

Methods
Method: backward ((lump ->periodic))
Source

gaussian-process.lisp.

Method: backward ((lump ->rough-exponential))
Source

gaussian-process.lisp.

Method: backward ((lump ->stretch))
Source

gaussian-process.lisp.

Method: backward ((lump ->rep))
Source

gaussian-process.lisp.

Method: backward ((lump ->ref))
Source

gaussian-process.lisp.

Method: backward ((lump ->gp))
Source

gaussian-process.lisp.

Method: backward ((lump ->constant))
Source

unroll.lisp.

Method: backward ((lump ->seq-barrier))
Source

lumps.lisp.

Method: backward ((lump ->normalized))
Source

lumps.lisp.

Method: backward ((lump ->exp))
Source

lumps.lisp.

Method: backward ((lump ->sin))
Source

lumps.lisp.

Method: backward ((lump ->abs))
Source

lumps.lisp.

Method: backward ((lump ->*))
Source

lumps.lisp.

Method: backward ((lump ->+))
Source

lumps.lisp.

Method: backward ((lump ->v*m))
Source

lumps.lisp.

Method: backward ((lump ->sample-binary))
Source

lumps.lisp.

Method: backward ((lump ->gaussian-random))
Source

lumps.lisp.

Method: backward ((lump ->softmax-xe-loss))
Source

lumps.lisp.

Method: backward ((lump ->squared-difference))
Source

lumps.lisp.

Method: backward :around ((lump ->loss))
Source

lumps.lisp.

Method: backward ((lump ->sum))
Source

lumps.lisp.

Method: backward ((lump ->max-channel))
Source

lumps.lisp.

Method: backward ((lump ->min))
Source

lumps.lisp.

Method: backward ((lump ->max))
Source

lumps.lisp.

Method: backward ((lump ->relu))
Source

lumps.lisp.

Method: backward ((lump ->scaled-tanh))
Source

lumps.lisp.

Method: backward ((lump ->tanh))
Source

lumps.lisp.

Method: backward ((lump ->sigmoid))
Source

lumps.lisp.

Method: backward ((lump ->embedding))
Source

lumps.lisp.

Method: backward ((lump ->batch-normalized))
Source

lumps.lisp.

Method: backward ((lump ->input))
Source

lumps.lisp.

Method: backward ((lump ->dropout))
Source

lumps.lisp.

Method: backward ((lump ->weight))
Source

lumps.lisp.

Method: backward ((bpn bpn))
Generic Reader: bag-of-words-kind (object)
Package

mgl-nlp.

Methods
Reader Method: bag-of-words-kind ((bag-of-words-encoder bag-of-words-encoder))

automatically generated reader method

Source

nlp.lisp.

Target Slot

kind.

Generic Reader: batch-normalization (object)
Package

mgl-bp.

Methods
Reader Method: batch-normalization ((->batch-normalized ->batch-normalized))

The ->BATCH-NORMALIZATION of this lump. May be
shared between multiple ->BATCH-NORMALIZED lumps.

Batch normalization is special in that it has state apart from the computed results (NODES) and its derivatives (DERIVATIVES). This state is the estimated mean and variance of its inputs and they are encapsulated by ->BATCH-NORMALIZATION.

If NORMALIZATION is not given at instantiation, then a new ->BATCH-NORMALIZATION object will be created automatically, passing :BATCH-SIZE, :VARIANCE-ADJUSTMENT, and :POPULATION-DECAY arguments on to ->BATCH-NORMALIZATION. See [BATCH-SIZE][(reader ->batch-normalization)], [VARIANCE-ADJUSTMENT][(reader ->batch-normalization)] and [POPULATION-DECAY][(reader ->batch-normalization)]. New scale and shift weight lumps will be created with names:

‘(,name :scale)
‘(,name :shift)

where ‘\NAME‘ is the NAME of this lump.

This default behavior covers the use-case where the statistics kept by ->BATCH-NORMALIZATION are to be shared only between time steps of an RNN.

Source

lumps.lisp.

Target Slot

normalization.

Generic Reader: batch-size (object)
Package

mgl-common.

Source

common.lisp.

Methods
Reader Method: batch-size ((->batch-normalization ->batch-normalization))

Normally all stripes participate in the batch.
Lowering the number of stripes may increase the regularization effect, but it also makes the computation less efficient. By setting BATCH-SIZE to a divisor of N-STRIPES one can decouple the concern of efficiency from that of regularization. The default value, NIL, is equivalent to N-STRIPES. BATCH-SIZE only affects training.

With the special value :USE-POPULATION, instead of the mean and the variance of the current batch, use the population statistics for normalization. This effectively cancels the regularization effect, leaving only the faster learning.

Source

lumps.lisp.

Target Slot

batch-size.

Reader Method: batch-size ((cg-optimizer cg-optimizer))

After having gone through BATCH-SIZE number of
instances, weights are updated. Normally, CG operates on all available data, but it may be useful to introduce some noise into the optimization to reduce overfitting by using smaller batch sizes. If BATCH-SIZE is not set, it is initialized to the size of the dataset at the start of optimization.

Source

conjugate-gradient.lisp.

Target Slot

batch-size.

Reader Method: batch-size ((gd-optimizer gd-optimizer))

After having gone through BATCH-SIZE number of
inputs, weights are updated. With BATCH-SIZE 1, one gets Stochastics Gradient Descent. With BATCH-SIZE equal to the number of instances in the dataset, one gets standard, ’batch’ gradient descent. With BATCH-SIZE between these two extremes, one gets the most practical ’mini-batch’ compromise.

Source

gradient-descent.lisp.

Target Slot

batch-size.

Generic Writer: (setf batch-size) (object)
Package

mgl-common.

Methods
Writer Method: (setf batch-size) ((cg-optimizer cg-optimizer))

After having gone through BATCH-SIZE number of
instances, weights are updated. Normally, CG operates on all available data, but it may be useful to introduce some noise into the optimization to reduce overfitting by using smaller batch sizes. If BATCH-SIZE is not set, it is initialized to the size of the dataset at the start of optimization.

Source

conjugate-gradient.lisp.

Target Slot

batch-size.

Writer Method: (setf batch-size) ((gd-optimizer gd-optimizer))

After having gone through BATCH-SIZE number of
inputs, weights are updated. With BATCH-SIZE 1, one gets Stochastics Gradient Descent. With BATCH-SIZE equal to the number of instances in the dataset, one gets standard, ’batch’ gradient descent. With BATCH-SIZE between these two extremes, one gets the most practical ’mini-batch’ compromise.

Source

gradient-descent.lisp.

Target Slot

batch-size.

Generic Reader: before-update-hook (object)
Generic Writer: (setf before-update-hook) (object)
Package

mgl-gd.

Methods
Reader Method: before-update-hook ((batch-gd-optimizer batch-gd-optimizer))
Writer Method: (setf before-update-hook) ((batch-gd-optimizer batch-gd-optimizer))

A list of functions of no parameters. Each
function is called just before a weight update takes place (after accumulated gradients have been divided the length of the batch). Convenient to hang some additional gradient accumulating code on.

Source

gradient-descent.lisp.

Target Slot

before-update-hook.

Generic Reader: bm (object)
Package

mgl-bm.

Methods
Reader Method: bm ((bm-learner bm-learner))

automatically generated reader method

Source

boltzmann-machine.lisp.

Target Slot

bm.

Generic Reader: bpn (object)
Package

mgl-bp.

Methods
Reader Method: bpn ((bp-learner bp-learner))

The BPN for which this BP-LEARNER provides the gradients.

Source

backprop.lisp.

Target Slot

bpn.

Generic Reader: cg-args (object)
Package

mgl-cg.

Methods
Reader Method: cg-args ((cg-optimizer cg-optimizer))

automatically generated reader method

Source

conjugate-gradient.lisp.

Target Slot

cg-args.

Generic Writer: (setf cg-args) (object)
Package

mgl-cg.

Methods
Writer Method: (setf cg-args) ((cg-optimizer cg-optimizer))

automatically generated writer method

Source

conjugate-gradient.lisp.

Target Slot

cg-args.

Generic Reader: chunk (object)
Package

mgl-bm.

Methods
Reader Method: chunk ((sparsity-gradient-source sparsity-gradient-source))

automatically generated reader method

Source

boltzmann-machine.lisp.

Target Slot

chunk.

Generic Reader: chunk1 (object)
Package

mgl-bm.

Methods
Reader Method: chunk1 ((cloud cloud))

automatically generated reader method

Source

boltzmann-machine.lisp.

Target Slot

chunk1.

Generic Reader: chunk2 (object)
Package

mgl-bm.

Methods
Reader Method: chunk2 ((cloud cloud))

automatically generated reader method

Source

boltzmann-machine.lisp.

Target Slot

chunk2.

Generic Function: chunks (object)
Package

mgl-bm.

Methods
Method: chunks ((dbn dbn))
Source

deep-belief-network.lisp.

Reader Method: chunks ((bm bm))

A list of all the chunks in this BM. It’s VISIBLE-CHUNKS and HIDDEN-CHUNKS appended.

Source

boltzmann-machine.lisp.

Target Slot

chunks.

Generic Reader: clamping-cache (object)
Package

mgl-unroll.

Methods
Reader Method: clamping-cache ((fnn-clamping-cache fnn-clamping-cache))

automatically generated reader method

Source

unroll.lisp.

Target Slot

clamping-cache.

Generic Reader: cloud (object)
Package

mgl-bm.

Methods
Reader Method: cloud ((sparsity-gradient-source sparsity-gradient-source))

automatically generated reader method

Source

boltzmann-machine.lisp.

Target Slot

cloud.

Generic Reader: cloud-a (object)
Package

mgl-bm.

Methods
Reader Method: cloud-a ((factored-cloud factored-cloud))

A full cloud whose visible chunk is the same as
the visible chunk of this cloud and whose hidden chunk is the same as the visible chunk of CLOUD-B.

Source

boltzmann-machine.lisp.

Target Slot

cloud-a.

Generic Reader: cloud-b (object)
Package

mgl-bm.

Methods
Reader Method: cloud-b ((factored-cloud factored-cloud))

A full cloud whose hidden chunk is the same as the
hidden chunk of this cloud and whose visible chunk is the same as the hidden chunk of CLOUD-A.

Source

boltzmann-machine.lisp.

Target Slot

cloud-b.

Generic Function: clouds (object)
Package

mgl-bm.

Methods
Method: clouds ((dbn dbn))
Source

deep-belief-network.lisp.

Reader Method: clouds ((bm bm))

Normally, a list of CLOUDS representing the
connections between chunks. During initialization cloud specs are allowed in the list.

Source

boltzmann-machine.lisp.

Target Slot

clouds.

Generic Reader: clouds-up-to-layers (object)
Package

mgl-bm.

Methods
Reader Method: clouds-up-to-layers ((dbm dbm))

Each element of this list is a list of clouds connected from below to the layer of the same index.

Source

boltzmann-machine.lisp.

Target Slot

clouds-up-to-layers.

Generic Reader: clumps (object)
Package

mgl-bp.

Methods
Reader Method: clumps ((bpn bpn))

A topological sorted adjustable array with a fill
pointer that holds the clumps that make up the network. Clumps are added to it by ADD-CLUMP or, more often, automatically when within a BUILD-FNN or BUILD-RNN. Rarely needed, FIND-CLUMP takes care of most uses.

Source

backprop.lisp.

Target Slot

clumps.

Generic Reader: concatenation-type (object)
Package

mgl-core.

Methods
Reader Method: concatenation-type ((concat-counter concat-counter))

A type designator suitable as the RESULT-TYPE argument to CONCATENATE.

Source

counter.lisp.

Target Slot

concatenation-type.

Generic Reader: conditioning-chunks (object)
Package

mgl-bm.

Methods
Reader Method: conditioning-chunks ((bm bm))

automatically generated reader method

Source

boltzmann-machine.lisp.

Target Slot

conditioning-chunks.

Generic Function: confusion-class-name (matrix class)

Name of CLASS for presentation purposes.

Package

mgl-core.

Source

classification.lisp.

Methods
Method: confusion-class-name ((matrix confusion-matrix) class)
Generic Function: confusion-count (matrix target prediction)
Package

mgl-core.

Source

classification.lisp.

Methods
Method: confusion-count ((matrix confusion-matrix) target prediction)
Generic Function: (setf confusion-count) (matrix target prediction)
Package

mgl-core.

Source

classification.lisp.

Methods
Method: (setf confusion-count) ((matrix confusion-matrix) target prediction)
Generic Function: confusion-matrix-classes (matrix)

A list of all classes. The default is to collect
classes from the counts. This can be overridden if, for instance, some classes are not present in the results.

Package

mgl-core.

Source

classification.lisp.

Methods
Method: confusion-matrix-classes ((matrix confusion-matrix))
Generic Function: copy (context object)

Make a deepish copy of OBJECT in CONTEXT.

Package

mgl-util.

Source

copy.lisp.

Methods
Method: copy :around (context object)
Method: copy (context object)
Method: copy (context (cons cons))
Method: copy (context (object standard-object))
Generic Function: copy-object-extra-initargs (context original-object)

Return a list of

Package

mgl-util.

Source

copy.lisp.

Methods
Method: copy-object-extra-initargs ((context (eql mgl-bm:pcd)) (chunk chunk))
Source

boltzmann-machine.lisp.

Method: copy-object-extra-initargs ((context (eql mgl-bm:dbm->dbn)) (chunk chunk))
Source

boltzmann-machine.lisp.

Method: copy-object-extra-initargs (context original-object)
Generic Function: copy-object-slot (context original-object slot-name value)

Return the value of the slot in the copied object
and T, or NIL as the second value if the slot need not be initialized.

Package

mgl-util.

Source

copy.lisp.

Methods
Method: copy-object-slot ((context (eql mgl-bm:pcd)) (original rbm) (slot-name (eql mgl-bm:dbn)) value)
Source

boltzmann-machine.lisp.

Method: copy-object-slot ((context (eql mgl-bm:pcd)) (original dbm) (slot-name (eql mgl-bm:hidden-chunks)) value)
Source

boltzmann-machine.lisp.

Method: copy-object-slot ((context (eql mgl-bm:pcd)) (original dbm) (slot-name (eql mgl-bm:visible-chunks)) value)
Source

boltzmann-machine.lisp.

Method: copy-object-slot ((context (eql mgl-bm:pcd)) (original bm) (slot-name (eql mgl-core:max-n-stripes)) value)
Source

boltzmann-machine.lisp.

Method: copy-object-slot ((context (eql mgl-bm:pcd)) (original bm) (slot-name (eql mgl-bm:chunks)) value)
Source

boltzmann-machine.lisp.

Method: copy-object-slot ((context (eql mgl-bm:pcd)) (original full-cloud) (slot-name (eql mgl-common:weights)) value)
Source

boltzmann-machine.lisp.

Method: copy-object-slot ((context (eql mgl-bm:pcd)) (original cloud) (slot-name (eql mgl-bm::cached-activations2)) value)
Source

boltzmann-machine.lisp.

Method: copy-object-slot ((context (eql mgl-bm:pcd)) (original cloud) (slot-name (eql mgl-bm::cached-activations1)) value)
Source

boltzmann-machine.lisp.

Method: copy-object-slot ((context (eql mgl-bm:pcd)) (original cloud) (slot-name (eql mgl-bm::cached-version2)) value)
Source

boltzmann-machine.lisp.

Method: copy-object-slot ((context (eql mgl-bm:pcd)) (original cloud) (slot-name (eql mgl-bm::cached-version1)) value)
Source

boltzmann-machine.lisp.

Method: copy-object-slot ((context (eql mgl-bm:pcd)) (original temporal-chunk) (slot-name (eql mgl-bm::has-inputs-p)) value)
Source

boltzmann-machine.lisp.

Method: copy-object-slot ((context (eql mgl-bm:pcd)) (original temporal-chunk) (slot-name (eql mgl-bm::next-node-inputs)) value)
Source

boltzmann-machine.lisp.

Method: copy-object-slot ((context (eql mgl-bm:pcd)) (original chunk) (slot-name (eql mgl-bm:indices-present)) value)
Source

boltzmann-machine.lisp.

Method: copy-object-slot ((context (eql mgl-bm:pcd)) (original chunk) (slot-name (eql mgl-bm:inputs)) value)
Source

boltzmann-machine.lisp.

Method: copy-object-slot ((context (eql mgl-bm:pcd)) (original chunk) (slot-name (eql mgl-bm::old-nodes)) value)
Source

boltzmann-machine.lisp.

Method: copy-object-slot ((context (eql mgl-bm:pcd)) (original chunk) (slot-name (eql mgl-bm:means)) value)
Source

boltzmann-machine.lisp.

Method: copy-object-slot ((context (eql mgl-bm:pcd)) (original chunk) (slot-name (eql mgl-common:nodes)) value)
Source

boltzmann-machine.lisp.

Method: copy-object-slot ((context (eql mgl-bm:dbm->dbn)) (original bm) (slot-name (eql mgl-core:max-n-stripes)) value)
Source

boltzmann-machine.lisp.

Method: copy-object-slot ((context (eql mgl-bm:dbm->dbn)) (original bm) (slot-name (eql mgl-bm:chunks)) value)
Source

boltzmann-machine.lisp.

Method: copy-object-slot ((context (eql mgl-bm:dbm->dbn)) (original full-cloud) (slot-name (eql mgl-common:weights)) value)
Source

boltzmann-machine.lisp.

Method: copy-object-slot ((context (eql mgl-bm:dbm->dbn)) (original cloud) (slot-name (eql mgl-bm::cached-activations2)) value)
Source

boltzmann-machine.lisp.

Method: copy-object-slot ((context (eql mgl-bm:dbm->dbn)) (original cloud) (slot-name (eql mgl-bm::cached-activations1)) value)
Source

boltzmann-machine.lisp.

Method: copy-object-slot ((context (eql mgl-bm:dbm->dbn)) (original cloud) (slot-name (eql mgl-bm::cached-version2)) value)
Source

boltzmann-machine.lisp.

Method: copy-object-slot ((context (eql mgl-bm:dbm->dbn)) (original cloud) (slot-name (eql mgl-bm::cached-version1)) value)
Source

boltzmann-machine.lisp.

Method: copy-object-slot ((context (eql mgl-bm:dbm->dbn)) (original temporal-chunk) (slot-name (eql mgl-bm::has-inputs-p)) value)
Source

boltzmann-machine.lisp.

Method: copy-object-slot ((context (eql mgl-bm:dbm->dbn)) (original temporal-chunk) (slot-name (eql mgl-bm::next-node-inputs)) value)
Source

boltzmann-machine.lisp.

Method: copy-object-slot ((context (eql mgl-bm:dbm->dbn)) (original chunk) (slot-name (eql mgl-bm:indices-present)) value)
Source

boltzmann-machine.lisp.

Method: copy-object-slot ((context (eql mgl-bm:dbm->dbn)) (original chunk) (slot-name (eql mgl-bm:inputs)) value)
Source

boltzmann-machine.lisp.

Method: copy-object-slot ((context (eql mgl-bm:dbm->dbn)) (original chunk) (slot-name (eql mgl-bm::old-nodes)) value)
Source

boltzmann-machine.lisp.

Method: copy-object-slot ((context (eql mgl-bm:dbm->dbn)) (original chunk) (slot-name (eql mgl-bm:means)) value)
Source

boltzmann-machine.lisp.

Method: copy-object-slot ((context (eql mgl-bm:dbm->dbn)) (original chunk) (slot-name (eql mgl-common:nodes)) value)
Source

boltzmann-machine.lisp.

Method: copy-object-slot (context original-object slot-name value)
Generic Function: cost (model)

Return the value of the cost function being
minimized. Calling this only makes sense in the context of an ongoing optimization (see MINIMIZE). The cost is that of a batch of instances.

Package

mgl-common.

Source

optimize.lisp.

Methods
Method: cost ((lump ->softmax-xe-loss))
Source

lumps.lisp.

Method: cost ((lump ->loss))
Source

lumps.lisp.

Method: cost ((rnn rnn))
Source

backprop.lisp.

Method: cost ((bpn bpn))
Source

backprop.lisp.

Reader Method: cost ((sparsity-gradient-source sparsity-gradient-source))

automatically generated reader method

Source

boltzmann-machine.lisp.

Target Slot

cost.

Generic Function: counter (monitor)

Return an object representing the state of MONITOR
or NIL, if it doesn’t have any (say because it’s a simple logging function). Most monitors have counters into which they accumulate results until they are printed and reset. See @MGL-COUNTER for more.

Package

mgl-core.

Source

monitor.lisp.

Methods
Reader Method: counter ((monitor monitor))

The COUNTER of a monitor carries out the
aggregation of results returned by MEASURER. The See @MGL-COUNTER for a library of counters.

Target Slot

counter.

Method: counter ((monitor function))
Method: counter ((monitor symbol))
Generic Function: counter-raw-values (counter)

Return any number of values representing the state
of COUNTER in such a way that passing the returned values as arguments ADD-TO-COUNTER on a fresh instance of the same type recreates the original state.

Package

mgl-core.

Source

counter.lisp.

Methods
Method: counter-raw-values ((counter concat-counter))
Method: counter-raw-values ((counter basic-counter))
Generic Function: counter-values (counter)

Return any number of values representing the state of COUNTER. See specialized methods for type specific documentation.

Package

mgl-core.

Source

counter.lisp.

Methods
Method: counter-values ((counter concat-counter))
Method: counter-values ((counter rmse-counter))
Method: counter-values ((counter basic-counter))
Generic Reader: covariance-lump-name (object)
Package

mgl-gp.

Methods
Reader Method: covariance-lump-name ((fnn-gp fnn-gp))

automatically generated reader method

Source

gaussian-process.lisp.

Target Slot

covariance-lump-name.

Generic Reader: cuda-window-start-time (object)
Generic Writer: (setf cuda-window-start-time) (object)
Package

mgl-bp.

Methods
Reader Method: cuda-window-start-time ((rnn rnn))
Writer Method: (setf cuda-window-start-time) ((rnn rnn))

Due to unfolding, the memory footprint of an RNN
is almost linear in the number of time steps (i.e. the max sequence length). For prediction, this is addressed by @MGL-RNN-TIME-WARP. For training, we cannot discard results of previous time steps because they are needed for backpropagation, but we can at least move them out of GPU memory if they are not going to be used for a while and copy them back before they are needed. Obviously, this is only relevant if CUDA is being used.

If CUDA-WINDOW-START-TIME is NIL, then this feature is turned off. Else, during training, at CUDA-WINDOW-START-TIME or later time steps, matrices belonging to non-weight lumps may be forced out of GPU memory and later brought back as neeeded.

This feature is implemented in terms of MGL-MAT:WITH-SYNCING-CUDA-FACETS that uses CUDA host memory (also known as _page-locked_ or _pinned memory_) to do asynchronous copies concurrently with normal computation. The consequence of this is that it is now main memory usage that’s unbounded which toghether with page-locking makes it a potent weapon to bring a machine to a halt. You were warned.

Source

backprop.lisp.

Target Slot

cuda-window-start-time.

Generic Reader: damping (object)
Package

mgl-bm.

Methods
Reader Method: damping ((sparsity-gradient-source sparsity-gradient-source))

automatically generated reader method

Source

boltzmann-machine.lisp.

Target Slot

damping.

Generic Reader: dbn (object)
Package

mgl-bm.

Methods
Reader Method: dbn ((rbm rbm))

automatically generated reader method

Source

boltzmann-machine.lisp.

Target Slot

dbn.

Generic Function: decode (decoder encoded)

Decode ENCODED with ENCODER. For an DECODER /
ENCODER pair, ‘(DECODE DECODER (ENCODE ENCODER OBJECT))‘ must be equal in some sense to ‘OBJECT‘.

If DECODER is a function designator, then it’s simply ‘FUNCALL‘ed with ENCODED.

Package

mgl-core.

Source

feature.lisp.

Methods
Method: decode ((indexer encoder/decoder) index)
Method: decode ((decoder symbol) encoded)
Method: decode ((decoder function) encoded)
Generic Function: default-mean-field-supervisor (bm)

Return a function suitable as the SUPERVISOR
argument for SETTLE-MEAN-FIELD. The default implementation

Package

mgl-bm.

Source

boltzmann-machine.lisp.

Methods
Method: default-mean-field-supervisor ((bm bm))
Generic Function: default-size (lump)

Return a default for the [SIZE][(reader lump)] of
LUMP if one is not supplied at instantiation. The value is often computed based on the sizes of the inputs. This function is for implementing new lump types.

Package

mgl-bp.

Source

lumps.lisp.

Methods
Method: default-size ((lump ->periodic))
Source

gaussian-process.lisp.

Method: default-size ((lump ->rough-exponential))
Source

gaussian-process.lisp.

Method: default-size ((lump ->stretch))
Source

gaussian-process.lisp.

Method: default-size ((lump ->rep))
Source

gaussian-process.lisp.

Method: default-size ((lump ->ref))
Source

gaussian-process.lisp.

Method: default-size ((lump ->gp))
Source

gaussian-process.lisp.

Method: default-size ((lump ->constant))
Source

unroll.lisp.

Method: default-size ((lump ->seq-barrier))
Method: default-size ((lump ->normalized))
Method: default-size ((lump ->exp))
Method: default-size ((lump ->sin))
Method: default-size ((lump ->abs))
Method: default-size ((lump ->*))
Method: default-size ((lump ->+))
Method: default-size ((lump ->v*m))
Method: default-size ((lump ->sample-binary))
Method: default-size ((lump ->softmax-xe-loss))
Method: default-size ((lump ->squared-difference))
Method: default-size ((lump ->sum))
Method: default-size ((lump ->max-channel))
Method: default-size ((lump ->min))
Method: default-size ((lump ->max))
Method: default-size ((lump ->relu))
Method: default-size ((lump ->scaled-tanh))
Method: default-size ((lump ->tanh))
Method: default-size ((lump ->embedding))
Method: default-size ((lump ->batch-normalization))
Method: default-size ((lump ->batch-normalized))
Method: default-size ((lump ->dropout))
Method: default-size (lump)
Generic Reader: default-value (object)
Package

mgl-common.

Source

common.lisp.

Methods
Reader Method: default-value ((lump lump))

Upon creation or resize the lump’s nodes get filled with this value.

Source

lumps.lisp.

Target Slot

default-value.

Reader Method: default-value ((constant-chunk constant-chunk))

automatically generated reader method

Source

boltzmann-machine.lisp.

Target Slot

default-value.

Generic Function: derivatives (clump)

Return the MAT object representing the partial
derivatives of the function CLUMP computes. The returned partial derivatives were accumulated by previous BACKWARD calls.

This matrix is shaped like the matrix returned by NODES.

Package

mgl-bp.

Source

backprop.lisp.

Methods
Reader Method: derivatives ((lump lump))

The derivatives computed in the backward pass are
stored here. This matrix is very much like [NODES][(reader lump)] in shape and size.

Source

lumps.lisp.

Target Slot

derivatives.

Method: derivatives ((bpn bpn))
Generic Reader: dimensions (object)
Package

mgl-bp.

Methods
Reader Method: dimensions ((->weight ->weight))

NODES and DERIVATIVES of this lump will be allocated with these dimensions.

Source

lumps.lisp.

Target Slot

dimensions.

Generic Reader: dropout (object)
Generic Writer: (setf dropout) (object)
Package

mgl-bp.

Methods
Reader Method: dropout ((->sigmoid ->sigmoid))
Writer Method: (setf dropout) ((->sigmoid ->sigmoid))

See [DROPOUT][(ACCESSOR ->DROPOUT)].

Source

lumps.lisp.

Target Slot

dropout.

Reader Method: dropout ((->input ->input))
Writer Method: (setf dropout) ((->input ->input))

See [DROPOUT][(ACCESSOR ->DROPOUT)].

Source

lumps.lisp.

Target Slot

dropout.

Reader Method: dropout ((->dropout ->dropout))
Writer Method: (setf dropout) ((->dropout ->dropout))

If non-NIL, then in the forward pass zero out each node in this chunk with DROPOUT probability.

Source

lumps.lisp.

Target Slot

dropout.

Generic Function: encode (encoder decoded)

Encode DECODED with ENCODER. This interface is
generic enough to be almost meaningless. See ENCODER/DECODER for a simple, MGL-NLP:BAG-OF-WORDS-ENCODER for a slightly more involved example.

If ENCODER is a function designator, then it’s simply ‘FUNCALL‘ed with DECODED.

Package

mgl-core.

Source

feature.lisp.

Methods
Method: encode ((encoder bag-of-words-encoder) decoded)
Source

nlp.lisp.

Method: encode ((indexer encoder/decoder) object)
Method: encode ((encoder symbol) decoded)
Method: encode ((encoder function) decoded)
Generic Reader: encoded-feature-test (object)
Package

mgl-nlp.

Methods
Reader Method: encoded-feature-test ((bag-of-words-encoder bag-of-words-encoder))

automatically generated reader method

Source

nlp.lisp.

Target Slot

encoded-feature-test.

Generic Reader: encoded-feature-type (object)
Package

mgl-nlp.

Methods
Reader Method: encoded-feature-type ((bag-of-words-encoder bag-of-words-encoder))

automatically generated reader method

Source

nlp.lisp.

Target Slot

encoded-feature-type.

Generic Reader: feature-encoder (object)
Package

mgl-nlp.

Methods
Reader Method: feature-encoder ((bag-of-words-encoder bag-of-words-encoder))

automatically generated reader method

Source

nlp.lisp.

Target Slot

feature-encoder.

Generic Reader: feature-mapper (object)
Package

mgl-nlp.

Methods
Reader Method: feature-mapper ((bag-of-words-encoder bag-of-words-encoder))

automatically generated reader method

Source

nlp.lisp.

Target Slot

feature-mapper.

Generic Function: find-chunk (name object &key errorp)

Find the chunk in OBJECT whose name is EQUAL to NAME. Signal an error if not found and ERRORP.

Package

mgl-bm.

Source

boltzmann-machine.lisp.

Methods
Method: find-chunk (name (dbn dbn) &key errorp)
Source

deep-belief-network.lisp.

Method: find-chunk (name (bm bm) &key errorp)
Generic Function: find-cloud (name object &key errorp)

Find the cloud in OBJECT whose name is EQUAL to NAME. Signal an error if not found and ERRORP.

Package

mgl-bm.

Source

boltzmann-machine.lisp.

Methods
Method: find-cloud (name (dbn dbn) &key errorp)
Source

deep-belief-network.lisp.

Method: find-cloud (name (bm bm) &key errorp)
Generic Function: finishedp (sampler)

See if SAMPLER has run out of examples.

Package

mgl-dataset.

Source

dataset.lisp.

Methods
Method: finishedp ((sampler function-sampler))
Generic Reader: fn (object)
Package

mgl-common.

Methods
Reader Method: fn ((diffun diffun))

A real valued lisp function. It may have any number of parameters.

Source

differentiable-function.lisp.

Target Slot

fn.

Reader Method: fn ((periodic-fn periodic-fn))

automatically generated reader method

Source

util.lisp.

Target Slot

fn.

Generic Function: forward (clump)

Compute the values of the function represented by
CLUMP for all stripes and place the results into NODES of CLUMP.

Package

mgl-bp.

Source

backprop.lisp.

Methods
Method: forward ((lump ->periodic))
Source

gaussian-process.lisp.

Method: forward ((lump ->rough-exponential))
Source

gaussian-process.lisp.

Method: forward ((lump ->stretch))
Source

gaussian-process.lisp.

Method: forward ((lump ->rep))
Source

gaussian-process.lisp.

Method: forward ((lump ->ref))
Source

gaussian-process.lisp.

Method: forward ((lump ->gp))
Source

gaussian-process.lisp.

Method: forward ((lump ->constant))
Source

unroll.lisp.

Method: forward ((lump ->seq-barrier))
Source

lumps.lisp.

Method: forward ((lump ->normalized))
Source

lumps.lisp.

Method: forward ((lump ->exp))
Source

lumps.lisp.

Method: forward ((lump ->sin))
Source

lumps.lisp.

Method: forward ((lump ->abs))
Source

lumps.lisp.

Method: forward ((lump ->*))
Source

lumps.lisp.

Method: forward ((lump ->+))
Source

lumps.lisp.

Method: forward ((lump ->v*m))
Source

lumps.lisp.

Method: forward ((lump ->sample-binary))
Source

lumps.lisp.

Method: forward ((lump ->gaussian-random))
Source

lumps.lisp.

Method: forward ((lump ->softmax-xe-loss))
Source

lumps.lisp.

Method: forward ((lump ->squared-difference))
Source

lumps.lisp.

Method: forward :around ((lump ->loss))
Source

lumps.lisp.

Method: forward ((lump ->sum))
Source

lumps.lisp.

Method: forward ((lump ->max-channel))
Source

lumps.lisp.

Method: forward ((lump ->min))
Source

lumps.lisp.

Method: forward ((lump ->max))
Source

lumps.lisp.

Method: forward ((lump ->relu))
Source

lumps.lisp.

Method: forward ((lump ->scaled-tanh))
Source

lumps.lisp.

Method: forward ((lump ->tanh))
Source

lumps.lisp.

Method: forward ((lump ->sigmoid))
Source

lumps.lisp.

Method: forward ((lump ->embedding))
Source

lumps.lisp.

Method: forward ((lump ->batch-normalized))
Source

lumps.lisp.

Method: forward ((lump ->input))
Source

lumps.lisp.

Method: forward ((lump ->dropout))
Source

lumps.lisp.

Method: forward ((lump ->weight))
Source

lumps.lisp.

Method: forward ((bpn bpn))
Method: forward :after (clump)
Generic Reader: generator (object)
Package

mgl-dataset.

Methods
Reader Method: generator ((function-sampler function-sampler))

A generator function of no arguments that returns the next sample.

Source

dataset.lisp.

Target Slot

generator.

Generic Function: gp-means (gp x)

Returns the vector of means for the vector of inputs X. X is a vector of arbitrary objects.

Package

mgl-gp.

Source

gaussian-process.lisp.

Methods
Method: gp-means ((fnn fnn-gp) x)
Method: gp-means ((gp posterior-gp) x)
Method: gp-means ((gp prior-gp) x)
Generic Function: gp-means-and-covariances* (gp x1 x2)

Returns two values: the means and the covariances as matrices.

Package

mgl-gp.

Source

gaussian-process.lisp.

Methods
Method: gp-means-and-covariances* ((fnn fnn-gp) x1 x2)
Method: gp-means-and-covariances* ((gp posterior-gp) x1 x2)
Method: gp-means-and-covariances* (gp x1 x2)
Generic Reader: group-size (object)
Package

mgl-common.

Source

common.lisp.

Methods
Reader Method: group-size ((->normalized ->normalized))

automatically generated reader method

Source

lumps.lisp.

Target Slot

group-size.

Reader Method: group-size ((->softmax-xe-loss ->softmax-xe-loss))

The number of elements in a softmax group. This is
the number of classes for classification. Often GROUP-SIZE is equal to SIZE (it is the default), but in general the only constraint is that SIZE is a multiple of GROUP-SIZE.

Source

lumps.lisp.

Target Slot

group-size.

Reader Method: group-size ((->max-channel ->max-channel))

The number of inputs in each group.

Source

lumps.lisp.

Target Slot

group-size.

Reader Method: group-size ((->min ->min))

The number of inputs in each group.

Source

lumps.lisp.

Target Slot

group-size.

Reader Method: group-size ((->max ->max))

The number of inputs in each group.

Source

lumps.lisp.

Target Slot

group-size.

Reader Method: group-size ((normalized-group-chunk normalized-group-chunk))

automatically generated reader method

Source

boltzmann-machine.lisp.

Target Slot

group-size.

Generic Function: hidden-chunks (object)
Package

mgl-bm.

Methods
Method: hidden-chunks ((dbn dbn))
Source

deep-belief-network.lisp.

Reader Method: hidden-chunks ((bm bm))

A list of CHUNKs that are not directly observed. Disjunct from VISIBLE-CHUNKS.

Source

boltzmann-machine.lisp.

Target Slot

hidden-chunks.

Generic Reader: hidden-sampling (object)
Generic Writer: (setf hidden-sampling) (object)
Package

mgl-bm.

Methods
Reader Method: hidden-sampling ((bm-mcmc-learner bm-mcmc-learner))
Writer Method: (setf hidden-sampling) ((bm-mcmc-learner bm-mcmc-learner))

Controls whether and how hidden nodes are sampled
during the learning or mean field is used instead. :HALF-HEARTED, the default value, samples the hiddens but uses the hidden means to calculate the effect of the positive and negative phases on the gradient. The default should almost always be preferable to T, as it is a less noisy estimate.

Source

boltzmann-machine.lisp.

Target Slot

hidden-sampling.

Generic Reader: importance (object)
Generic Writer: (setf importance) (object)
Package

mgl-bp.

Methods
Reader Method: importance ((->loss ->loss))
Writer Method: (setf importance) ((->loss ->loss))

This is to support weighted instances. That is
when not all training instances are equally important. If non-NIL, a 1d MAT with the importances of stripes of the batch. When IMPORTANCE is given (typically in SET-INPUT), then instead of adding 1 to the derivatives of all stripes, IMPORTANCE is added elemtwise.

Source

lumps.lisp.

Target Slot

importance.

Generic Reader: importances (object)
Package

mgl-bm.

Methods
Reader Method: importances ((bm bm))

automatically generated reader method

Source

boltzmann-machine.lisp.

Target Slot

importances.

Generic Writer: (setf importances) (object)
Package

mgl-bm.

Methods
Writer Method: (setf importances) ((bm bm))

automatically generated writer method

Source

boltzmann-machine.lisp.

Target Slot

importances.

Generic Reader: index (object)
Package

mgl-util.

Methods
Reader Method: index ((->ref ->ref))

automatically generated reader method

Source

gaussian-process.lisp.

Target Slot

index.

Generic Reader: indices-present (object)
Generic Writer: (setf indices-present) (object)
Package

mgl-bm.

Methods
Reader Method: indices-present ((chunk chunk))
Writer Method: (setf indices-present) ((chunk chunk))

NIL or a simple vector of array indices into the
layer’s NODES. Need not be ordered. SET-INPUT sets it. Note, that if it is non-NIL then N-STRIPES must be 1.

Source

boltzmann-machine.lisp.

Target Slot

indices-present.

Generic Function: initialize-gradient-source* (optimizer gradient-source weights dataset)

Called automatically before MINIMIZE* is called,
this function may be specialized if GRADIENT-SOURCE needs some kind of setup.

Package

mgl-opt.

Source

optimize.lisp.

Methods
Method: initialize-gradient-source* (optimizer (learner bp-learner) weights dataset)
Source

backprop.lisp.

Method: initialize-gradient-source* (optimizer (learner sparse-bm-learner) weights dataset)
Source

boltzmann-machine.lisp.

Method: initialize-gradient-source* (optimizer gradient-source weights dataset)

The default method does nothing.

Generic Function: initialize-optimizer* (optimizer gradient-source weights dataset)

Called automatically before training starts, this function sets up OPTIMIZER to be suitable for optimizing GRADIENT-SOURCE. It typically creates appropriately sized accumulators for the gradients.

Package

mgl-opt.

Source

optimize.lisp.

Methods
Method: initialize-optimizer* ((optimizer cg-optimizer) source weights dataset)
Source

conjugate-gradient.lisp.

Method: initialize-optimizer* ((optimizer segmented-gd-optimizer) source weights dataset)
Source

gradient-descent.lisp.

Method: initialize-optimizer* ((optimizer per-weight-batch-gd-optimizer) source weights dataset)
Source

gradient-descent.lisp.

Method: initialize-optimizer* ((optimizer normalized-batch-gd-optimizer) source weights dataset)
Source

gradient-descent.lisp.

Method: initialize-optimizer* ((optimizer adam-optimizer) source weights dataset)
Source

gradient-descent.lisp.

Method: initialize-optimizer* ((optimizer gd-optimizer) source weights dataset)
Source

gradient-descent.lisp.

Generic Reader: input-row-indices (object)
Generic Writer: (setf input-row-indices) (object)
Package

mgl-bp.

Methods
Reader Method: input-row-indices ((->embedding ->embedding))
Writer Method: (setf input-row-indices) ((->embedding ->embedding))

A sequence of batch size length of row indices. To be set in SET-INPUT.

Source

lumps.lisp.

Target Slot

input-row-indices.

Generic Reader: inputs (object)
Package

mgl-bm.

Methods
Reader Method: inputs ((chunk chunk))

This is where the after method of SET-INPUT saves
the input for later use by RECONSTRUCTION-ERROR, INPUTS->NODES. It is NIL in CONDITIONING-CHUNKS.

Source

boltzmann-machine.lisp.

Target Slot

inputs.

Generic Function: instance-to-executor-parameters (instance cache)

Return the parameters for an executor able to
handle INSTANCE. Called by MAP-OVER-EXECUTORS on CACHE (that’s a PARAMETERIZED-EXECUTOR-CACHE-MIXIN). The returned parameters are keys in an EQUAL parameters->executor hash table.

Package

mgl-core.

Source

core.lisp.

Methods
Method: instance-to-executor-parameters (sample (fnn-gp fnn-gp))
Source

gaussian-process.lisp.

Generic Function: label-index (instance)

Return the label of INSTANCE as a non-negative integer.

Package

mgl-core.

Source

classification.lisp.

Generic Function: label-index-distribution (instance)

Return a one dimensional array of probabilities
representing the distribution of labels. The probability of the label with LABEL-INDEX ‘I‘ is element at index ‘I‘ of the returned arrray.

Package

mgl-core.

Source

classification.lisp.

Generic Function: label-index-distributions (result)

Return a sequence of label index distributions for
RESULTS produced by some model for a batch of instances. This is akin to LABEL-INDEX-DISTRIBUTION.

Package

mgl-core.

Source

classification.lisp.

Methods
Method: label-index-distributions ((lump ->softmax-xe-loss))
Source

lumps.lisp.

Method: label-index-distributions ((chunk softmax-label-chunk))
Source

boltzmann-machine.lisp.

Generic Function: label-indices (results)

Return a sequence of label indices for RESULTS
produced by some model for a batch of instances. This is akin to LABEL-INDEX.

Package

mgl-core.

Source

classification.lisp.

Methods
Method: label-indices ((lump ->softmax-xe-loss))
Source

lumps.lisp.

Method: label-indices ((chunk softmax-label-chunk))
Source

boltzmann-machine.lisp.

Generic Reader: last-eval (object)
Package

mgl-util.

Methods
Reader Method: last-eval ((periodic-fn periodic-fn))

automatically generated reader method

Source

util.lisp.

Target Slot

last-eval.

Generic Writer: (setf last-eval) (object)
Package

mgl-util.

Methods
Writer Method: (setf last-eval) ((periodic-fn periodic-fn))

automatically generated writer method

Source

util.lisp.

Target Slot

last-eval.

Generic Reader: layers (object)
Package

mgl-bm.

Methods
Reader Method: layers ((dbm dbm))

A list of layers from bottom up. A layer is a list
of chunks. The layers partition the set of all chunks in the BM. Chunks with no connections to layers below are visible (including constant and conditioning) chunks. The layered structure is used in the single, bottom-up, approximate inference pass. When instantiating a DBM, VISIBLE-CHUNKS and HIDDEN-CHUNKS are inferred from LAYERS and CLOUDS.

Source

boltzmann-machine.lisp.

Target Slot

layers.

Generic Reader: learning-rate (object)
Generic Writer: (setf learning-rate) (object)
Package

mgl-gd.

Methods
Reader Method: learning-rate ((adam-optimizer adam-optimizer))
Writer Method: (setf learning-rate) ((adam-optimizer adam-optimizer))

Same thing as [LEARNING-RATE][(ACCESSOR
GD-OPTIMIZER)] but with the default suggested by the Adam paper.

Source

gradient-descent.lisp.

Target Slot

learning-rate.

Reader Method: learning-rate ((gd-optimizer gd-optimizer))
Writer Method: (setf learning-rate) ((gd-optimizer gd-optimizer))

This is the step size along the gradient. Decrease
it if optimization diverges, increase it if it doesn’t make progress.

Source

gradient-descent.lisp.

Target Slot

learning-rate.

Generic Function: log-cg-batch-done (optimizer gradient-source instances best-w best-f n-line-searches n-succesful-line-searches n-evaluations)

This is a function can be added to
ON-CG-BATCH-DONE. The default implementation simply logs the event arguments.

Package

mgl-cg.

Source

conjugate-gradient.lisp.

Methods
Method: log-cg-batch-done (optimizer gradient-source instances best-w best-f n-line-searches n-succesful-line-searches n-evaluations)
Generic Function: make-classification-accuracy-monitors* (model operation-mode label-index-fn attributes)

Identical to MAKE-CLASSIFICATION-ACCURACY-MONITORS
bar the keywords arguments. Specialize this to add to support for new model types. The default implementation also allows for some extensibility: if LABEL-INDICES is defined on MODEL, then it will be used to extract label indices from model results.

Package

mgl-core.

Source

classification.lisp.

Methods
Method: make-classification-accuracy-monitors* ((bpn bpn) operation-mode label-index-fn attributes)
Source

backprop.lisp.

Method: make-classification-accuracy-monitors* ((dbn dbn) operation-mode label-index-fn attributes)
Source

deep-belief-network.lisp.

Method: make-classification-accuracy-monitors* ((bm bm) operation-mode label-index-fn attributes)
Source

boltzmann-machine.lisp.

Method: make-classification-accuracy-monitors* (object operation-mode label-index-fn attributes)
Generic Function: make-cost-monitors* (model operation-mode attributes)

Identical to MAKE-COST-MONITORS bar the keywords
arguments. Specialize this to add to support for new model types.

Package

mgl-opt.

Source

optimize.lisp.

Methods
Method: make-cost-monitors* (object operation-mode attributes)
Generic Function: make-cross-entropy-monitors* (model operation-mode label-index-distribution-fn attributes)

Identical to MAKE-CROSS-ENTROPY-MONITORS bar the
keywords arguments. Specialize this to add to support for new model types. The default implementation also allows for some extensibility: if LABEL-INDEX-DISTRIBUTIONS is defined on MODEL, then it will be used to extract label distributions from model results.

Package

mgl-core.

Source

classification.lisp.

Methods
Method: make-cross-entropy-monitors* ((bpn bpn) operation-mode label-index-distribution-fn attributes)
Source

backprop.lisp.

Method: make-cross-entropy-monitors* ((dbn dbn) operation-mode label-index-distribution-fn attributes)
Source

deep-belief-network.lisp.

Method: make-cross-entropy-monitors* ((bm bm) operation-mode label-index-distribution-fn attributes)
Source

boltzmann-machine.lisp.

Method: make-cross-entropy-monitors* (object operation-mode label-index-distribution-fn attributes)
Generic Function: make-executor-with-parameters (parameters cache)

Create a new executor for PARAMETERS. CACHE is a PARAMETERIZED-EXECUTOR-CACHE-MIXIN. In the BPN gaussian process example, PARAMETERS would be a list of input dimensions.

Package

mgl-core.

Source

core.lisp.

Generic Function: make-reconstruction-monitors* (model operation-mode attributes)
Package

mgl-bm.

Source

boltzmann-machine.lisp.

Methods
Method: make-reconstruction-monitors* ((dbn dbn) operation-mode attributes)
Source