| Safe Haskell | None |
|---|---|
| Language | GHC2024 |
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
- newtype Task p e r = Task {
- measure :: p -> e -> r
- newtype Experience (f :: k -> Type) (e :: k) = Experience {
- set :: f e
- newtype Progress p e = Progress {
- step :: e -> p -> p
- newtype Learn (f :: k -> Type) (e :: k) p = Learn {
- change :: Experience f e -> p -> p
- learn :: forall (f :: Type -> Type) p e. Foldable f => Progress p e -> Experience f e -> p -> p
- improve :: (Foldable f, Functor f, Ord r) => (f r -> r) -> Progress p e -> Experience f e -> Task p e r -> p -> p
- sgd :: Double -> ([Double] -> e -> [Double]) -> Progress [Double] e
Core vocabulary
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.
newtype Experience (f :: k -> Type) (e :: k) Source #
An experience is a container of training examples.
Constructors
| Experience | |
Fields
| |
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.
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
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.