circuits-learn
Safe HaskellNone
LanguageGHC2024

Circuit.Learn.Ephemeral

Description

Ephemeral learning vocabulary adapted to the circuits-learn interface.

Based on ideas from the ephemeral package: a learning step is a Progress that transduces a parameterised Task given an Experience. Folding progress over an experience set is learn; choosing the better resulting task is improve.

Synopsis

Core vocabulary

newtype Task p e r Source #

A task is a parameterised measurement: given parameters p and an experience e, produce a performance value r.

This is the circuits-learn reading of ephemeral's Task e p, with the parameter block p made explicit so it can be updated by Progress.

Constructors

Task 

Fields

newtype Experience (f :: k -> Type) (e :: k) Source #

An experience is a container of training examples.

Constructors

Experience 

Fields

newtype Progress p e Source #

A progress step updates parameters from one experience.

In the original ephemeral vocabulary this transduces the task itself; here the task is fixed and the parameters that define it are changed.

Constructors

Progress 

Fields

  • step :: e -> p -> p
     

newtype Learn (f :: k -> Type) (e :: k) p Source #

A learn folds a Progress over an Experience set.

Constructors

Learn 

Fields

Learning as folding progress

learn :: forall (f :: Type -> Type) p e. Foldable f => Progress p e -> Experience f e -> p -> p Source #

Fold a progress step over all experiences in a set.

improve :: (Foldable f, Functor f, Ord r) => (f r -> r) -> Progress p e -> Experience f e -> Task p e r -> p -> p Source #

Apply a learn to a task and choose the better parameters.

Performance is summarised by a user-supplied function f (r) -> r (for example sum or mean) so that two parameter blocks can be compared.

Simple gradient descent progress

sgd Source #

Arguments

:: Double

learning rate

-> ([Double] -> e -> [Double])

gradient of the task at parameters and example

-> Progress [Double] e 

Plain stochastic-gradient-descent progress for vector parameters.

sgd rate grad takes one example, computes the gradient grad params e, and steps the parameters in the negative direction.