kwta

package
v1.1.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 4, 2020 License: BSD-3-Clause Imports: 7 Imported by: 23

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

Constants

This section is empty.

Variables

View Source
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 {
	On         bool        `desc:"whether to run kWTA or not"`
	Iters      int         `desc:"maximum number of iterations to perform"`
	DelActThr  float32     `def:"0.005" desc:"threshold on delta-activation (change in activation) for stopping updating of activations"`
	LayFFFB    fffb.Params `view:"inline" desc:"layer-level feedforward & feedback inhibition -- applied over entire set of values"`
	PoolFFFB   fffb.Params `` /* 177-byte string literal not displayed */
	XX1        nxx1.Params `view:"inline" desc:"Noisy X/X+1 rate code activation function parameters"`
	ActTau     float32     `def:"3" desc:"time constant for integrating activation"`
	Gbar       chans.Chans `view:"inline" desc:"[Defaults: 1, .2, 1, 1] maximal conductances levels for channels"`
	Erev       chans.Chans `view:"inline" desc:"[Defaults: 1, .3, .25, .1] reversal potentials for each channel"`
	ErevSubThr chans.Chans `inactive:"+" view:"-" desc:"Erev - Act.Thr 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"`
	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) ActFmG

func (kwta *KWTA) ActFmG(geThr, ge, act float32) (nwAct, delAct float32)

ActFmG computes rate-coded activation Act from conductances Ge and Gi

func (*KWTA) Defaults

func (kwta *KWTA) Defaults()

func (*KWTA) GeThrFmG

func (kwta *KWTA) GeThrFmG(gi float32) float32

GeThrFmG computes the threshold for Ge based on other conductances

func (*KWTA) KWTALayer

func (kwta *KWTA) KWTALayer(raw, act, extGi *etensor.Float32)

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

func (kwta *KWTA) KWTAPool(raw, act *etensor.Float32, inhib *[]fffb.Inhib, extGi *etensor.Float32)

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.

func (*KWTA) Update

func (kwta *KWTA) Update()

Update must be called after any changes to parameters

type NeighInhib

type NeighInhib struct {
	On bool    `desc:"use neighborhood inhibition"`
	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)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL