kwta

package
v2.0.0-dev0.0.10 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2024 License: BSD-3-Clause Imports: 6 Imported by: 1

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 Chans

type Chans struct {

	// excitatory sodium (Na) AMPA channels activated by synaptic glutamate
	E float32

	// constant leak (potassium, K+) channels -- determines resting potential (typically higher than resting potential of K)
	L float32

	// inhibitory chloride (Cl-) channels activated by synaptic GABA
	I float32

	// gated / active potassium channels -- typically hyperpolarizing relative to leak / rest
	K float32
}

Chans are ion channels used in computing point-neuron activation function

func (*Chans) SetAll

func (ch *Chans) SetAll(e, l, i, k float32)

SetAll sets all the values

func (*Chans) SetFromMinusOther

func (ch *Chans) SetFromMinusOther(minus float32, oth Chans)

SetFromMinusOther sets all the values from given value minus other Chans

func (*Chans) SetFromOtherMinus

func (ch *Chans) SetFromOtherMinus(oth Chans, minus float32)

SetFromOtherMinus sets all the values from other Chans minus given value

type KWTA

type KWTA struct {

	// whether to run kWTA or not
	On bool

	// maximum number of iterations to perform
	Iters int

	// threshold on delta-activation (change in activation) for stopping updating of activations
	DelActThr float32 `default:"0.005"`

	// layer-level feedforward & feedback inhibition -- applied over entire set of values
	LayFFFB fffb.Params `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 `view:"inline"`

	// Noisy X/X+1 rate code activation function parameters
	XX1 nxx1.Params `view:"inline"`

	// time constant for integrating activation
	ActTau float32 `default:"3"`

	// maximal conductances levels for channels
	Gbar Chans `view:"inline"`

	// reversal potentials for each channel
	Erev Chans `view:"inline"`

	// Erev - Act.Thr for each channel -- used in computing GeThrFromG among others
	ErevSubThr Chans `edit:"-" view:"-"`

	// Act.Thr - Erev for each channel -- used in computing GeThrFromG among others
	ThrSubErev Chans `edit:"-" view:"-" json:"-" xml:"-"`

	//
	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) ActFromG

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

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

func (*KWTA) Defaults

func (kwta *KWTA) Defaults()

func (*KWTA) GeThrFromG

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

GeThrFromG 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.Inhibs, 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 {

	// use neighborhood inhibition
	On bool

	// overall value of the inhibition -- this is what is added into the unit Gi inhibition level
	Gi float32 `default:"0.6"`
}

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