Documentation
¶
Overview ¶
package kwta provides the Leabra k-Winners-Take-All inhibition function in a form that can be applied to an etensor of float32 values as computed by visual (or other modality) filtering routines.
The inhibition is computed using the FFFB feedforward-feedback function along with standard noisy-X-over-X+1 (NXX1) function that computes a resulting activation based on the inhibition.
Index ¶
- Variables
- type KWTA
- func (kwta *KWTA) ActFmG(geThr, ge, act float32) (nwAct, delAct float32)
- func (kwta *KWTA) Defaults()
- func (kwta *KWTA) GeThrFmG(gi float32) float32
- func (kwta *KWTA) KWTALayer(raw, act, extGi *etensor.Float32)
- func (kwta *KWTA) KWTAPool(raw, act *etensor.Float32, inhib *fffb.Inhibs, extGi *etensor.Float32)
- func (kwta *KWTA) Update()
- type NeighInhib
Constants ¶
This section is empty.
Variables ¶
var ( // ortho neighbor coordinates for 4 angles, also uses negated version // . // --- = (0,1) (X,Y) // . / // / = (-1,1) // | . = (1,0) // \ // . \ = (-1,-1) Neigh4X = []int{0, -1, 1, -1} Neigh4Y = []int{1, 1, 0, -1} )
Functions ¶
This section is empty.
Types ¶
type KWTA ¶
type KWTA struct {
// whether to run kWTA or not
On bool `desc:"whether to run kWTA or not"`
// maximum number of iterations to perform
Iters int `desc:"maximum number of iterations to perform"`
// [def: 0.005] threshold on delta-activation (change in activation) for stopping updating of activations
DelActThr float32 `def:"0.005" desc:"threshold on delta-activation (change in activation) for stopping updating of activations"`
// [view: inline] layer-level feedforward & feedback inhibition -- applied over entire set of values
LayFFFB fffb.Params `view:"inline" desc:"layer-level feedforward & feedback inhibition -- applied over entire set of values"`
// [view: inline] pool-level (feature groups) feedforward and feedback inhibition -- applied within inner-most dimensions inside outer 2 dimensions (if Pool method is called)
PoolFFFB fffb.Params `` /* 177-byte string literal not displayed */
// [view: inline] Noisy X/X+1 rate code activation function parameters
XX1 nxx1.Params `view:"inline" desc:"Noisy X/X+1 rate code activation function parameters"`
// [def: 3] time constant for integrating activation
ActTau float32 `def:"3" desc:"time constant for integrating activation"`
// [view: inline] [Defaults: 1, .2, 1, 1] maximal conductances levels for channels
Gbar chans.Chans `view:"inline" desc:"[Defaults: 1, .2, 1, 1] maximal conductances levels for channels"`
// [view: inline] [Defaults: 1, .3, .25, .1] reversal potentials for each channel
Erev chans.Chans `view:"inline" desc:"[Defaults: 1, .3, .25, .1] reversal potentials for each channel"`
// [view: -] Erev - Act.Thr for each channel -- used in computing GeThrFmG among others
ErevSubThr chans.Chans `inactive:"+" view:"-" desc:"Erev - Act.Thr for each channel -- used in computing GeThrFmG among others"`
// [view: -] Act.Thr - Erev for each channel -- used in computing GeThrFmG among others
ThrSubErev chans.Chans `inactive:"+" view:"-" json:"-" xml:"-" desc:"Act.Thr - Erev for each channel -- used in computing GeThrFmG among others"`
// [view: -]
ActDt float32 `view:"-"; json"-" xml"-" desc:"integration rate = 1/ tau"`
}
KWTA contains all the parameters needed for computing FFFB (feedforward & feedback) inhibition that results in roughly k-Winner-Take-All behavior.
func (*KWTA) KWTALayer ¶
KWTALayer computes k-Winner-Take-All activation values from raw inputs. act output tensor is set to same shape as raw inputs if not already. This version just computes a "layer" level of inhibition across the entire set of tensor values. extGi is extra / external Gi inhibition per unit -- e.g. from neighbor inhib -- must be size of raw, act.
func (*KWTA) KWTAPool ¶
KWTAPool computes k-Winner-Take-All activation values from raw inputs act output tensor is set to same shape as raw inputs if not already. This version computes both Layer and Pool (feature-group) level inibition -- tensors must be 4 dimensional -- outer 2D is Y, X Layer and inner 2D are features (pools) per location. The inhib slice is required for pool-level inhibition and will be automatically sized to outer X,Y dims if not big enough. For best performance store this and reuse to avoid memory allocations. extGi is extra / external Gi inhibition per unit -- e.g. from neighbor inhib -- must be size of raw, act.
type NeighInhib ¶
type NeighInhib struct {
// use neighborhood inhibition
On bool `desc:"use neighborhood inhibition"`
// [def: 0.6] overall value of the inhibition -- this is what is added into the unit Gi inhibition level
Gi float32 `def:"0.6" desc:"overall value of the inhibition -- this is what is added into the unit Gi inhibition level"`
}
NeighInhib adds an additional inhibition factor based on the same feature along an orthogonal angle -- assumes inner-most X axis represents angle of gabor or related feature. This helps reduce redundancy of feature code.
func (*NeighInhib) Defaults ¶
func (ni *NeighInhib) Defaults()
func (*NeighInhib) Inhib4 ¶
func (ni *NeighInhib) Inhib4(act, extGi *etensor.Float32)
Inhib4 computes the neighbor inhibition on activations into extGi. If extGi is not same shape as act, it will be made so (most efficient to re-use same structure). Act must be a 4D tensor with features as inner 2D. 4 version ONLY works with 4 angles (inner-most feature dimension)