Documentation ¶
Overview ¶
Package axon provides the basic reference axon implementation, for rate-coded activations and standard error-driven learning. Other packages provide spiking or deep axon, PVLV, PBWM, etc.
The overall design seeks an "optimal" tradeoff between simplicity, transparency, ability to flexibly recombine and extend elements, and avoiding having to rewrite a bunch of stuff.
The *Stru elements handle the core structural components of the network, and hold emer.* interface pointers to elements such as emer.Layer, which provides a very minimal interface for these elements. Interfaces are automatically pointers, so think of these as generic pointers to your specific Layers etc.
This design means the same *Stru infrastructure can be re-used across different variants of the algorithm. Because we're keeping this infrastructure minimal and algorithm-free it should be much less confusing than dealing with the multiple levels of inheritance in C++ emergent. The actual algorithm-specific code is now fully self-contained, and largely orthogonalized from the infrastructure.
One specific cost of this is the need to cast the emer.* interface pointers into the specific types of interest, when accessing via the *Stru infrastructure.
The *Params elements contain all the (meta)parameters and associated methods for computing various functions. They are the equivalent of Specs from original emergent, but unlike specs they are local to each place they are used, and styling is used to apply common parameters across multiple layers etc. Params seems like a more explicit, recognizable name compared to specs, and this also helps avoid confusion about their different nature than old specs. Pars is shorter but confusable with "Parents" so "Params" is more unambiguous.
Params are organized into four major categories, which are more clearly functionally labeled as opposed to just structurally so, to keep things clearer and better organized overall: * ActParams -- activation params, at the Neuron level (in act.go) * InhibParams -- inhibition params, at the Layer / Pool level (in inhib.go) * LearnNeurParams -- learning parameters at the Neuron level (running-averages that drive learning) * LearnSynParams -- learning parameters at the Synapse level (both in learn.go)
The levels of structure and state are: * Network * .Layers * .Pools: pooled inhibition state -- 1 for layer plus 1 for each sub-pool (unit group) with inhibition * .RecvPrjns: receiving projections from other sending layers * .SendPrjns: sending projections from other receiving layers * .Neurons: neuron state variables
There are methods on the Network that perform initialization and overall computation, by iterating over layers and calling methods there. This is typically how most users will run their models.
Parallel computation across multiple CPU cores (threading) is achieved through persistent worker go routines that listen for functions to run on thread-specific channels. Each layer has a designated thread number, so you can experiment with different ways of dividing up the computation. Timing data is kept for per-thread time use -- see TimeReport() on the network.
The Layer methods directly iterate over Neurons, Pools, and Prjns, and there is no finer-grained level of computation (e.g., at the individual Neuron level), except for the *Params methods that directly compute relevant functions. Thus, looking directly at the layer.go code should provide a clear sense of exactly how everything is computed -- you may need to the refer to act.go, learn.go etc to see the relevant details but at least the overall organization should be clear in layer.go.
Computational methods are generally named: VarFmVar to specifically name what variable is being computed from what other input variables. e.g., ActFmG computes activation from conductances G.
The Pools (type Pool, in pool.go) hold state used for computing pooled inhibition, but also are used to hold overall aggregate pooled state variables -- the first element in Pools applies to the layer itself, and subsequent ones are for each sub-pool (4D layers). These pools play the same role as the AxonUnGpState structures in C++ emergent.
Prjns directly support all synapse-level computation, and hold the LearnSynParams and iterate directly over all of their synapses. It is the exact same Prjn object that lives in the RecvPrjns of the receiver-side, and the SendPrjns of the sender-side, and it maintains and coordinates both sides of the state. This clarifies and simplifies a lot of code. There is no separate equivalent of AxonConSpec / AxonConState at the level of connection groups per unit per projection.
The pattern of connectivity between units is specified by the prjn.Pattern interface and all the different standard options are avail in that prjn package. The Pattern code generates a full tensor bitmap of binary 1's and 0's for connected (1's) and not (0's) units, and can use any method to do so. This full lookup-table approach is not the most memory-efficient, but it is fully general and shouldn't be too-bad memory-wise overall (fully bit-packed arrays are used, and these bitmaps don't need to be retained once connections have been established). This approach allows patterns to just focus on patterns, and they don't care at all how they are used to allocate actual connections.
Index ¶
- Constants
- Variables
- func JsonToParams(b []byte) string
- func NeuronVarIdxByName(varNm string) (int, error)
- func SigFun(w, gain, off float32) float32
- func SigFun61(w float32) float32
- func SigInvFun(w, gain, off float32) float32
- func SigInvFun61(w float32) float32
- func SynapseVarByName(varNm string) (int, error)
- type ActAvg
- type ActAvgParams
- type ActInitParams
- type ActNoiseParams
- type ActNoiseType
- type ActParams
- func (ac *ActParams) ActFmG(nrn *Neuron)
- func (ac *ActParams) DecayState(nrn *Neuron, decay float32)
- func (ac *ActParams) Defaults()
- func (ac *ActParams) GeFmRaw(nrn *Neuron, geRaw float32)
- func (ac *ActParams) GiFmRaw(nrn *Neuron, giRaw float32)
- func (ac *ActParams) HardClamp(nrn *Neuron)
- func (ac *ActParams) HasHardClamp(nrn *Neuron) bool
- func (ac *ActParams) InetFmG(vm, ge, gi, gk float32) float32
- func (ac *ActParams) InitActQs(nrn *Neuron)
- func (ac *ActParams) InitActs(nrn *Neuron)
- func (ac *ActParams) Update()
- func (ac *ActParams) VmFmG(nrn *Neuron)
- type AxonLayer
- type AxonNetwork
- type AxonPrjn
- type ClampParams
- type CosDiffParams
- type CosDiffStats
- type DtParams
- type InhibParams
- type LayFunChan
- type Layer
- func (ly *Layer) ActFmG(ltime *Time)
- func (ly *Layer) AllParams() string
- func (ly *Layer) AlphaCycInit()
- func (ly *Layer) ApplyExt(ext etensor.Tensor)
- func (ly *Layer) ApplyExt1D(ext []float64)
- func (ly *Layer) ApplyExt1D32(ext []float32)
- func (ly *Layer) ApplyExt1DTsr(ext etensor.Tensor)
- func (ly *Layer) ApplyExt2D(ext etensor.Tensor)
- func (ly *Layer) ApplyExt2Dto4D(ext etensor.Tensor)
- func (ly *Layer) ApplyExt4D(ext etensor.Tensor)
- func (ly *Layer) ApplyExtFlags() (clrmsk, setmsk int32, toTarg bool)
- func (ly *Layer) AsAxon() *Layer
- func (ly *Layer) AvgGeM(ltime *Time)
- func (ly *Layer) AvgMaxAct(ltime *Time)
- func (ly *Layer) AvgMaxGe(ltime *Time)
- func (ly *Layer) Build() error
- func (ly *Layer) BuildPools(nu int) error
- func (ly *Layer) BuildPrjns() error
- func (ly *Layer) BuildSubPools()
- func (ly *Layer) CosDiffFmActs()
- func (ly *Layer) CostEst() (neur, syn, tot int)
- func (ly *Layer) CyclePost(ltime *Time)
- func (ly *Layer) DWt()
- func (ly *Layer) DWtSubMean()
- func (ly *Layer) DecayState(decay float32)
- func (ly *Layer) DecayStatePool(pool int, decay float32)
- func (ly *Layer) Defaults()
- func (ly *Layer) GFmInc(ltime *Time)
- func (ly *Layer) GFmIncNeur(ltime *Time)
- func (ly *Layer) GScaleFmAvgAct()
- func (ly *Layer) GenNoise()
- func (ly *Layer) HardClamp()
- func (ly *Layer) InhibFmGeAct(ltime *Time)
- func (ly *Layer) InhibFmPool(ltime *Time)
- func (ly *Layer) InitActAvg()
- func (ly *Layer) InitActs()
- func (ly *Layer) InitExt()
- func (ly *Layer) InitWtSym()
- func (ly *Layer) InitWts()
- func (ly *Layer) IsTarget() bool
- func (ly *Layer) LesionNeurons(prop float32) int
- func (ly *Layer) LrateMult(mult float32)
- func (ly *Layer) PctUnitErr() float64
- func (ly *Layer) Pool(idx int) *Pool
- func (ly *Layer) PoolInhibFmGeAct(ltime *Time)
- func (ly *Layer) PoolTry(idx int) (*Pool, error)
- func (ly *Layer) QuarterFinal(ltime *Time)
- func (ly *Layer) ReadWtsJSON(r io.Reader) error
- func (ly *Layer) RecvGInc(ltime *Time)
- func (ly *Layer) RecvPrjnVals(vals *[]float32, varNm string, sendLay emer.Layer, sendIdx1D int, ...) error
- func (ly *Layer) SendPrjnVals(vals *[]float32, varNm string, recvLay emer.Layer, recvIdx1D int, ...) error
- func (ly *Layer) SendSpike(ltime *Time)
- func (ly *Layer) SetWts(lw *weights.Layer) error
- func (ly *Layer) SynScale()
- func (ly *Layer) UnLesionNeurons()
- func (ly *Layer) UnitVal(varNm string, idx []int) float32
- func (ly *Layer) UnitVal1D(varIdx int, idx int) float32
- func (ly *Layer) UnitVals(vals *[]float32, varNm string) error
- func (ly *Layer) UnitValsTensor(tsr etensor.Tensor, varNm string) error
- func (ly *Layer) UnitVarIdx(varNm string) (int, error)
- func (ly *Layer) UnitVarNames() []string
- func (ly *Layer) UnitVarNum() int
- func (ly *Layer) UnitVarProps() map[string]string
- func (ly *Layer) UpdateExtFlags()
- func (ly *Layer) UpdateParams()
- func (ly *Layer) VarRange(varNm string) (min, max float32, err error)
- func (ly *Layer) WriteWtsJSON(w io.Writer, depth int)
- func (ly *Layer) WtFmDWt()
- type LayerStru
- func (ls *LayerStru) ApplyParams(pars *params.Sheet, setMsg bool) (bool, error)
- func (ls *LayerStru) Class() string
- func (ls *LayerStru) Config(shape []int, typ emer.LayerType)
- func (ls *LayerStru) Idx4DFrom2D(x, y int) ([]int, bool)
- func (ls *LayerStru) Index() int
- func (ls *LayerStru) InitName(lay emer.Layer, name string, net emer.Network)
- func (ls *LayerStru) Is2D() bool
- func (ls *LayerStru) Is4D() bool
- func (ls *LayerStru) IsOff() bool
- func (ls *LayerStru) Label() string
- func (ls *LayerStru) NPools() int
- func (ls *LayerStru) NRecvPrjns() int
- func (ls *LayerStru) NSendPrjns() int
- func (ls *LayerStru) Name() string
- func (ls *LayerStru) NonDefaultParams() string
- func (ls *LayerStru) Pos() mat32.Vec3
- func (ls *LayerStru) RecipToSendPrjn(spj emer.Prjn) (emer.Prjn, bool)
- func (ls *LayerStru) RecvPrjn(idx int) emer.Prjn
- func (ls *LayerStru) RecvPrjns() *emer.Prjns
- func (ls *LayerStru) RelPos() relpos.Rel
- func (ls *LayerStru) SendPrjn(idx int) emer.Prjn
- func (ls *LayerStru) SendPrjns() *emer.Prjns
- func (ls *LayerStru) SetClass(cls string)
- func (ls *LayerStru) SetIndex(idx int)
- func (ls *LayerStru) SetName(nm string)
- func (ls *LayerStru) SetOff(off bool)
- func (ls *LayerStru) SetPos(pos mat32.Vec3)
- func (ls *LayerStru) SetRelPos(rel relpos.Rel)
- func (ls *LayerStru) SetShape(shape []int)
- func (ls *LayerStru) SetThread(thr int)
- func (ls *LayerStru) SetType(typ emer.LayerType)
- func (ls *LayerStru) Shape() *etensor.Shape
- func (ls *LayerStru) Size() mat32.Vec2
- func (ls *LayerStru) Thread() int
- func (ls *LayerStru) Type() emer.LayerType
- func (ls *LayerStru) TypeName() string
- type LearnNeurParams
- type LearnSynParams
- func (ls *LearnSynParams) CHLdWt(suAvgSLrn, suAvgM, ruAvgSLrn, ruAvgM float32) float32
- func (ls *LearnSynParams) Defaults()
- func (ls *LearnSynParams) LWtFmWt(syn *Synapse)
- func (ls *LearnSynParams) Update()
- func (ls *LearnSynParams) WtFmDWt(dwt, wt, lwt *float32, scale float32)
- func (ls *LearnSynParams) WtFmLWt(syn *Synapse)
- type LrnActAvgParams
- type NMDAPrjn
- type Network
- func (nt *Network) ActFmG(ltime *Time)
- func (nt *Network) AlphaCycInit()
- func (nt *Network) AlphaCycInitImpl()
- func (nt *Network) AsAxon() *Network
- func (nt *Network) AvgMaxAct(ltime *Time)
- func (nt *Network) AvgMaxGe(ltime *Time)
- func (nt *Network) CollectDWts(dwts *[]float32, nwts int) bool
- func (nt *Network) Cycle(ltime *Time)
- func (nt *Network) CycleImpl(ltime *Time)
- func (nt *Network) CyclePost(ltime *Time)
- func (nt *Network) CyclePostImpl(ltime *Time)
- func (nt *Network) DWt()
- func (nt *Network) DWtImpl()
- func (nt *Network) DecayState(decay float32)
- func (nt *Network) Defaults()
- func (nt *Network) GScaleFmAvgAct()
- func (nt *Network) InhibFmGeAct(ltime *Time)
- func (nt *Network) InitActs()
- func (nt *Network) InitExt()
- func (nt *Network) InitTopoScales()
- func (nt *Network) InitWts()
- func (nt *Network) LayersSetOff(off bool)
- func (nt *Network) LrateMult(mult float32)
- func (nt *Network) NewLayer() emer.Layer
- func (nt *Network) NewPrjn() emer.Prjn
- func (nt *Network) QuarterFinal(ltime *Time)
- func (nt *Network) QuarterFinalImpl(ltime *Time)
- func (nt *Network) SendSpike(ltime *Time)
- func (nt *Network) SetDWts(dwts []float32)
- func (nt *Network) SizeReport() string
- func (nt *Network) SynScale()
- func (nt *Network) SynVarNames() []string
- func (nt *Network) SynVarProps() map[string]string
- func (nt *Network) ThreadAlloc(nThread int) string
- func (nt *Network) ThreadReport() string
- func (nt *Network) UnLesionNeurons()
- func (nt *Network) UnitVarNames() []string
- func (nt *Network) UnitVarProps() map[string]string
- func (nt *Network) UpdateExtFlags()
- func (nt *Network) UpdateParams()
- func (nt *Network) WtFmDWt()
- func (nt *Network) WtFmDWtImpl()
- type NetworkStru
- func (nt *NetworkStru) AddLayer(name string, shape []int, typ emer.LayerType) emer.Layer
- func (nt *NetworkStru) AddLayer2D(name string, shapeY, shapeX int, typ emer.LayerType) emer.Layer
- func (nt *NetworkStru) AddLayer4D(name string, nPoolsY, nPoolsX, nNeurY, nNeurX int, typ emer.LayerType) emer.Layer
- func (nt *NetworkStru) AddLayerInit(ly emer.Layer, name string, shape []int, typ emer.LayerType)
- func (nt *NetworkStru) AllParams() string
- func (nt *NetworkStru) AllWtScales() string
- func (nt *NetworkStru) ApplyParams(pars *params.Sheet, setMsg bool) (bool, error)
- func (nt *NetworkStru) BidirConnectLayerNames(low, high string, pat prjn.Pattern) (lowlay, highlay emer.Layer, fwdpj, backpj emer.Prjn, err error)
- func (nt *NetworkStru) BidirConnectLayers(low, high emer.Layer, pat prjn.Pattern) (fwdpj, backpj emer.Prjn)
- func (nt *NetworkStru) BidirConnectLayersPy(low, high emer.Layer, pat prjn.Pattern)
- func (nt *NetworkStru) Bounds() (min, max mat32.Vec3)
- func (nt *NetworkStru) BoundsUpdt()
- func (nt *NetworkStru) Build() error
- func (nt *NetworkStru) BuildThreads()
- func (nt *NetworkStru) ConnectLayerNames(send, recv string, pat prjn.Pattern, typ emer.PrjnType) (rlay, slay emer.Layer, pj emer.Prjn, err error)
- func (nt *NetworkStru) ConnectLayers(send, recv emer.Layer, pat prjn.Pattern, typ emer.PrjnType) emer.Prjn
- func (nt *NetworkStru) ConnectLayersPrjn(send, recv emer.Layer, pat prjn.Pattern, typ emer.PrjnType, pj emer.Prjn) emer.Prjn
- func (nt *NetworkStru) FunTimerStart(fun string)
- func (nt *NetworkStru) FunTimerStop(fun string)
- func (nt *NetworkStru) InitName(net emer.Network, name string)
- func (nt *NetworkStru) Label() string
- func (nt *NetworkStru) LateralConnectLayer(lay emer.Layer, pat prjn.Pattern) emer.Prjn
- func (nt *NetworkStru) LateralConnectLayerPrjn(lay emer.Layer, pat prjn.Pattern, pj emer.Prjn) emer.Prjn
- func (nt *NetworkStru) Layer(idx int) emer.Layer
- func (nt *NetworkStru) LayerByName(name string) emer.Layer
- func (nt *NetworkStru) LayerByNameTry(name string) (emer.Layer, error)
- func (nt *NetworkStru) Layout()
- func (nt *NetworkStru) MakeLayMap()
- func (nt *NetworkStru) NLayers() int
- func (nt *NetworkStru) Name() string
- func (nt *NetworkStru) NonDefaultParams() string
- func (nt *NetworkStru) OpenWtsCpp(filename gi.FileName) error
- func (nt *NetworkStru) OpenWtsJSON(filename gi.FileName) error
- func (nt *NetworkStru) ReadWtsCpp(r io.Reader) error
- func (nt *NetworkStru) ReadWtsJSON(r io.Reader) error
- func (nt *NetworkStru) SaveWtsJSON(filename gi.FileName) error
- func (nt *NetworkStru) SetWts(nw *weights.Network) error
- func (nt *NetworkStru) StartThreads()
- func (nt *NetworkStru) StdVertLayout()
- func (nt *NetworkStru) StopThreads()
- func (nt *NetworkStru) ThrLayFun(fun func(ly AxonLayer), funame string)
- func (nt *NetworkStru) ThrTimerReset()
- func (nt *NetworkStru) ThrWorker(tt int)
- func (nt *NetworkStru) TimerReport()
- func (nt *NetworkStru) VarRange(varNm string) (min, max float32, err error)
- func (nt *NetworkStru) WriteWtsJSON(w io.Writer) error
- type NeurFlags
- type Neuron
- func (nrn *Neuron) ClearFlag(flag NeurFlags)
- func (nrn *Neuron) ClearMask(mask int32)
- func (nrn *Neuron) HasFlag(flag NeurFlags) bool
- func (nrn *Neuron) IsOff() bool
- func (nrn *Neuron) SetFlag(flag NeurFlags)
- func (nrn *Neuron) SetMask(mask int32)
- func (nrn *Neuron) VarByIndex(idx int) float32
- func (nrn *Neuron) VarByName(varNm string) (float32, error)
- func (nrn *Neuron) VarNames() []string
- type Pool
- type Prjn
- func (pj *Prjn) AllParams() string
- func (pj *Prjn) AsAxon() *Prjn
- func (pj *Prjn) Build() error
- func (pj *Prjn) DWt()
- func (pj *Prjn) DWtSubMean()
- func (pj *Prjn) Defaults()
- func (pj *Prjn) InitGbuf()
- func (pj *Prjn) InitWtSym(rpjp AxonPrjn)
- func (pj *Prjn) InitWts()
- func (pj *Prjn) InitWtsSyn(syn *Synapse)
- func (pj *Prjn) LrateMult(mult float32)
- func (pj *Prjn) ReadWtsJSON(r io.Reader) error
- func (pj *Prjn) RecvGInc()
- func (pj *Prjn) SendSpike(si int)
- func (pj *Prjn) SetClass(cls string) emer.Prjn
- func (pj *Prjn) SetPattern(pat prjn.Pattern) emer.Prjn
- func (pj *Prjn) SetScalesFunc(scaleFun func(si, ri int, send, recv *etensor.Shape) float32)
- func (pj *Prjn) SetScalesRPool(scales etensor.Tensor)
- func (pj *Prjn) SetSynVal(varNm string, sidx, ridx int, val float32) error
- func (pj *Prjn) SetType(typ emer.PrjnType) emer.Prjn
- func (pj *Prjn) SetWts(pw *weights.Prjn) error
- func (pj *Prjn) SetWtsFunc(wtFun func(si, ri int, send, recv *etensor.Shape) float32)
- func (pj *Prjn) SynIdx(sidx, ridx int) int
- func (pj *Prjn) SynScale()
- func (pj *Prjn) SynVal(varNm string, sidx, ridx int) float32
- func (pj *Prjn) SynVal1D(varIdx int, synIdx int) float32
- func (pj *Prjn) SynVals(vals *[]float32, varNm string) error
- func (pj *Prjn) SynVarIdx(varNm string) (int, error)
- func (pj *Prjn) SynVarNames() []string
- func (pj *Prjn) SynVarNum() int
- func (pj *Prjn) SynVarProps() map[string]string
- func (pj *Prjn) UpdateParams()
- func (pj *Prjn) WriteWtsJSON(w io.Writer, depth int)
- func (pj *Prjn) WtFmDWt()
- type PrjnStru
- func (ps *PrjnStru) ApplyParams(pars *params.Sheet, setMsg bool) (bool, error)
- func (ps *PrjnStru) BuildStru() error
- func (ps *PrjnStru) Class() string
- func (ps *PrjnStru) Connect(slay, rlay emer.Layer, pat prjn.Pattern, typ emer.PrjnType)
- func (ps *PrjnStru) Init(prjn emer.Prjn)
- func (ps *PrjnStru) IsOff() bool
- func (ps *PrjnStru) Label() string
- func (ps *PrjnStru) Name() string
- func (ps *PrjnStru) NonDefaultParams() string
- func (ps *PrjnStru) Pattern() prjn.Pattern
- func (ps *PrjnStru) PrjnTypeName() string
- func (ps *PrjnStru) RecvLay() emer.Layer
- func (ps *PrjnStru) SendLay() emer.Layer
- func (ps *PrjnStru) SetNIdxSt(n *[]int32, avgmax *minmax.AvgMax32, idxst *[]int32, tn *etensor.Int32) int32
- func (ps *PrjnStru) SetOff(off bool)
- func (ps *PrjnStru) String() string
- func (ps *PrjnStru) Type() emer.PrjnType
- func (ps *PrjnStru) TypeName() string
- func (ps *PrjnStru) Validate(logmsg bool) error
- type PrjnType
- type Quarters
- func (qt *Quarters) Clear(qtr int)
- func (i *Quarters) FromString(s string) error
- func (qt Quarters) Has(qtr int) bool
- func (qt Quarters) HasNext(qtr int) bool
- func (qt Quarters) HasPrev(qtr int) bool
- func (qt Quarters) MarshalJSON() ([]byte, error)
- func (qt *Quarters) Set(qtr int)
- func (i Quarters) String() string
- func (qt *Quarters) UnmarshalJSON(b []byte) error
- type SelfInhibParams
- type SpikeParams
- type SynComParams
- type SynScaleParams
- type Synapse
- type Time
- type TimeScales
- type WtInitParams
- type WtScaleParams
- type WtSigParams
- type XCalParams
Constants ¶
const ( Version = "v1.2.27" GitCommit = "e735ee4" // the commit JUST BEFORE the release VersionDate = "2021-05-10 11:48" // UTC )
const ( // NMDAPrjn are projections that have strong NMDA channels supporting maintenance NMDA emer.PrjnType = emer.PrjnType(emer.PrjnTypeN) + iota )
The GLong prjn types
const NeuronVarStart = 8
NeuronVarStart is the byte offset of fields in the Neuron structure where the float32 named variables start. Note: all non-float32 infrastructure variables must be at the start!
Variables ¶
var KiT_ActNoiseType = kit.Enums.AddEnum(ActNoiseTypeN, kit.NotBitFlag, nil)
var KiT_Layer = kit.Types.AddType(&Layer{}, LayerProps)
var KiT_NMDAPrjn = kit.Types.AddType(&NMDAPrjn{}, PrjnProps)
var KiT_Network = kit.Types.AddType(&Network{}, NetworkProps)
var KiT_NeurFlags = kit.Enums.AddEnum(NeurFlagsN, kit.BitFlag, nil)
var KiT_Prjn = kit.Types.AddType(&Prjn{}, PrjnProps)
var KiT_PrjnType = kit.Enums.AddEnumExt(emer.KiT_PrjnType, PrjnTypeN, kit.NotBitFlag, nil)
var KiT_TimeScales = kit.Enums.AddEnum(TimeScalesN, kit.NotBitFlag, nil)
var LayerProps = ki.Props{ "ToolBar": ki.PropSlice{ {"Defaults", ki.Props{ "icon": "reset", "desc": "return all parameters to their intial default values", }}, {"InitWts", ki.Props{ "icon": "update", "desc": "initialize the layer's weight values according to prjn parameters, for all *sending* projections out of this layer", }}, {"InitActs", ki.Props{ "icon": "update", "desc": "initialize the layer's activation values", }}, {"sep-act", ki.BlankProp{}}, {"LesionNeurons", ki.Props{ "icon": "close", "desc": "Lesion (set the Off flag) for given proportion of neurons in the layer (number must be 0 -- 1, NOT percent!)", "Args": ki.PropSlice{ {"Proportion", ki.Props{ "desc": "proportion (0 -- 1) of neurons to lesion", }}, }, }}, {"UnLesionNeurons", ki.Props{ "icon": "reset", "desc": "Un-Lesion (reset the Off flag) for all neurons in the layer", }}, }, }
var NetworkProps = ki.Props{ "ToolBar": ki.PropSlice{ {"SaveWtsJSON", ki.Props{ "label": "Save Wts...", "icon": "file-save", "desc": "Save json-formatted weights", "Args": ki.PropSlice{ {"Weights File Name", ki.Props{ "default-field": "WtsFile", "ext": ".wts,.wts.gz", }}, }, }}, {"OpenWtsJSON", ki.Props{ "label": "Open Wts...", "icon": "file-open", "desc": "Open json-formatted weights", "Args": ki.PropSlice{ {"Weights File Name", ki.Props{ "default-field": "WtsFile", "ext": ".wts,.wts.gz", }}, }, }}, {"sep-file", ki.BlankProp{}}, {"Build", ki.Props{ "icon": "update", "desc": "build the network's neurons and synapses according to current params", }}, {"InitWts", ki.Props{ "icon": "update", "desc": "initialize the network weight values according to prjn parameters", }}, {"InitActs", ki.Props{ "icon": "update", "desc": "initialize the network activation values", }}, {"sep-act", ki.BlankProp{}}, {"AddLayer", ki.Props{ "label": "Add Layer...", "icon": "new", "desc": "add a new layer to network", "Args": ki.PropSlice{ {"Layer Name", ki.Props{}}, {"Layer Shape", ki.Props{ "desc": "shape of layer, typically 2D (Y, X) or 4D (Pools Y, Pools X, Units Y, Units X)", }}, {"Layer Type", ki.Props{ "desc": "type of layer -- used for determining how inputs are applied", }}, }, }}, {"ConnectLayerNames", ki.Props{ "label": "Connect Layers...", "icon": "new", "desc": "add a new connection between layers in the network", "Args": ki.PropSlice{ {"Send Layer Name", ki.Props{}}, {"Recv Layer Name", ki.Props{}}, {"Pattern", ki.Props{ "desc": "pattern to connect with", }}, {"Prjn Type", ki.Props{ "desc": "type of projection -- direction, or other more specialized factors", }}, }, }}, {"AllWtScales", ki.Props{ "icon": "file-sheet", "desc": "AllWtScales returns a listing of all WtScale parameters in the Network in all Layers, Recv projections. These are among the most important and numerous of parameters (in larger networks) -- this helps keep track of what they all are set to.", "show-return": true, }}, }, }
var NeuronVarProps = map[string]string{
"Vm": `min:"0" max:"1"`,
"VmDend": `min:"0" max:"1"`,
"ISI": `auto-scale:"+"`,
"ISIAvg": `auto-scale:"+"`,
"Gi": `auto-scale:"+"`,
"Gk": `auto-scale:"+"`,
"ActDel": `auto-scale:"+"`,
"ActDif": `auto-scale:"+"`,
"AvgPct": `min:"-2" max:"2"`,
"TrgAvg": `min:"-2" max:"2"`,
"GknaFast": `auto-scale:"+"`,
"GknaMed": `auto-scale:"+"`,
"GknaSlow": `auto-scale:"+"`,
"Gnmda": `auto-scale:"+"`,
"NMDA": `auto-scale:"+"`,
"GgabaB": `auto-scale:"+"`,
"GABAB": `auto-scale:"+"`,
"GABABx": `auto-scale:"+"`,
}
var NeuronVars = []string{"Spike", "ISI", "ISIAvg", "Act", "ActLrn", "Ge", "Gi", "Gk", "Inet", "Vm", "VmDend", "Targ", "Ext", "AvgSS", "AvgS", "AvgM", "AvgSLrn", "ActQ0", "ActQ1", "ActQ2", "ActM", "ActP", "ActDif", "ActDel", "ActAvg", "AvgPct", "TrgAvg", "AvgDif", "Noise", "GiSyn", "GiSelf", "GeRaw", "GiRaw", "GeM", "GknaFast", "GknaMed", "GknaSlow", "Gnmda", "NMDA", "NMDASyn", "GgabaB", "GABAB", "GABABx"}
var NeuronVarsMap map[string]int
var PrjnProps = ki.Props{ "EnumType:Typ": KiT_PrjnType, }
var SynapseVarProps = map[string]string{
"DWt": `auto-scale:"+"`,
}
var SynapseVars = []string{"Wt", "LWt", "DWt", "Scale"}
var SynapseVarsMap map[string]int
Functions ¶
func JsonToParams ¶
JsonToParams reformates json output to suitable params display output
func NeuronVarIdxByName ¶
NeuronVarIdxByName returns the index of the variable in the Neuron, or error
func SigFun61 ¶
SigFun61 is the sigmoid function for value w in 0-1 range, with default gain = 6, offset = 1 params
func SigInvFun61 ¶
SigInvFun61 is the inverse of the sigmoid function, with default gain = 6, offset = 1 params
func SynapseVarByName ¶
SynapseVarByName returns the index of the variable in the Synapse, or error
Types ¶
type ActAvg ¶
type ActAvg struct { ActMAvg float32 `desc:"running-average minus-phase activity -- used for adapting inhibition -- see ActAvgParams.Tau for time constant etc"` ActPAvg float32 `desc:"running-average plus-phase activity -- used for synaptic input scaling -- see ActAvgParams.Tau for time constant etc"` ActPAvgEff float32 `desc:"ActPAvg * ActAvgParams.Adjust -- adjusted effective layer activity directly used in synaptic input scaling"` }
ActAvg are running-average activation levels used for netinput scaling and adaptive inhibition
type ActAvgParams ¶
type ActAvgParams struct { Init float32 `` /* 462-byte string literal not displayed */ Fixed bool `` /* 190-byte string literal not displayed */ UseExtAct bool `` /* 343-byte string literal not displayed */ UseFirst bool `` /* 166-byte string literal not displayed */ Tau float32 `` /* 177-byte string literal not displayed */ Adjust float32 `` /* 576-byte string literal not displayed */ Dt float32 `inactive:"+" view:"-" json:"-" xml:"-" desc:"rate = 1 / tau"` }
ActAvgParams represents expected average activity levels in the layer. Used for computing running-average computation that is then used for netinput scaling. Also specifies time constant for updating average and for the target value for adapting inhibition in inhib_adapt.
func (*ActAvgParams) AvgFmAct ¶
func (aa *ActAvgParams) AvgFmAct(avg *float32, act float32)
AvgFmAct updates the running-average activation given average activity level in layer
func (*ActAvgParams) Defaults ¶
func (aa *ActAvgParams) Defaults()
func (*ActAvgParams) EffFmAvg ¶
func (aa *ActAvgParams) EffFmAvg(eff *float32, avg float32)
EffFmAvg updates the effective value from the running-average value
func (*ActAvgParams) EffInit ¶
func (aa *ActAvgParams) EffInit() float32
EffInit returns the initial value applied during InitWts for the AvgPAvgEff effective layer activity
func (*ActAvgParams) Update ¶
func (aa *ActAvgParams) Update()
type ActInitParams ¶
type ActInitParams struct { Decay float32 `` /* 214-byte string literal not displayed */ KnaDecay float32 `` /* 137-byte string literal not displayed */ Vm float32 `def:"0.3" desc:"initial membrane potential -- see Erev.L for the resting potential (typically .3)"` Act float32 `def:"0" desc:"initial activation value -- typically 0"` Ge float32 `` /* 268-byte string literal not displayed */ Gi float32 `` /* 235-byte string literal not displayed */ }
ActInitParams are initial values for key network state variables. Initialized at start of trial with Init_Acts or DecayState.
func (*ActInitParams) Defaults ¶
func (ai *ActInitParams) Defaults()
func (*ActInitParams) Update ¶
func (ai *ActInitParams) Update()
type ActNoiseParams ¶
type ActNoiseParams struct { erand.RndParams Type ActNoiseType `desc:"where and how to add processing noise"` Fixed bool `` /* 227-byte string literal not displayed */ }
ActNoiseParams contains parameters for activation-level noise
func (*ActNoiseParams) Defaults ¶
func (an *ActNoiseParams) Defaults()
func (*ActNoiseParams) Update ¶
func (an *ActNoiseParams) Update()
type ActNoiseType ¶
type ActNoiseType int
ActNoiseType are different types / locations of random noise for activations
const ( // NoNoise means no noise added NoNoise ActNoiseType = iota // VmNoise means noise is added to the membrane potential. VmNoise // GeNoise means noise is added to the excitatory conductance (Ge). GeNoise // ActNoise means noise is added to the final rate code activation ActNoise // GeMultNoise means that noise is multiplicative on the Ge excitatory conductance values GeMultNoise ActNoiseTypeN )
The activation noise types
func (*ActNoiseType) FromString ¶
func (i *ActNoiseType) FromString(s string) error
func (ActNoiseType) MarshalJSON ¶
func (ev ActNoiseType) MarshalJSON() ([]byte, error)
func (ActNoiseType) String ¶
func (i ActNoiseType) String() string
func (*ActNoiseType) UnmarshalJSON ¶
func (ev *ActNoiseType) UnmarshalJSON(b []byte) error
type ActParams ¶
type ActParams struct { Spike SpikeParams `view:"inline" desc:"Spiking function parameters"` Init ActInitParams `` /* 127-byte string literal not displayed */ Dt DtParams `view:"inline" desc:"time and rate constants for temporal derivatives / updating of activation state"` 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"` Clamp ClampParams `view:"inline" desc:"how external inputs drive neural activations"` Noise ActNoiseParams `view:"inline" desc:"how, where, when, and how much noise to add"` VmRange minmax.F32 `` /* 165-byte string literal not displayed */ KNa knadapt.Params `` /* 252-byte string literal not displayed */ NMDA glong.NMDAParams `view:"inline" desc:"NMDA channel parameters plus more general params"` GABAB glong.GABABParams `view:"inline" desc:"GABA-B / GIRK channel parameters"` }
axon.ActParams contains all the activation computation params and functions for basic Axon, at the neuron level . This is included in axon.Layer to drive the computation.
func (*ActParams) DecayState ¶
DecayState decays the activation state toward initial values in proportion to given decay parameter Called with ac.Init.Decay by Layer during AlphaCycInit
func (*ActParams) GeFmRaw ¶
GeFmRaw integrates Ge excitatory conductance from GeRaw value (can add other terms to geRaw prior to calling this)
func (*ActParams) GiFmRaw ¶
GiFmRaw integrates GiSyn inhibitory synaptic conductance from GiRaw value (can add other terms to geRaw prior to calling this)
func (*ActParams) HardClamp ¶
HardClamp drives Poisson rate spiking according to external input. Also adds any Noise *if* noise is set to ActNoise.
func (*ActParams) HasHardClamp ¶
HasHardClamp returns true if this neuron has external input that should be hard clamped
func (*ActParams) InitActQs ¶
InitActQs initializes quarter-based activation states in neuron (ActQ0-2, ActM, ActP, ActDif) Called from InitActs, which is called from InitWts, but otherwise not automatically called (DecayState is used instead)
func (*ActParams) InitActs ¶
InitActs initializes activation state in neuron -- called during InitWts but otherwise not automatically called (DecayState is used instead)
type AxonLayer ¶
type AxonLayer interface { emer.Layer // AsAxon returns this layer as a axon.Layer -- so that the AxonLayer // interface does not need to include accessors to all the basic stuff AsAxon() *Layer // InitWts initializes the weight values in the network, i.e., resetting learning // Also calls InitActs InitWts() // InitActAvg initializes the running-average activation values that drive learning. InitActAvg() // InitActs fully initializes activation state -- only called automatically during InitWts InitActs() // InitWtsSym initializes the weight symmetry -- higher layers copy weights from lower layers InitWtSym() // InitExt initializes external input state -- called prior to apply ext InitExt() // ApplyExt applies external input in the form of an etensor.Tensor // If the layer is a Target or Compare layer type, then it goes in Targ // otherwise it goes in Ext. ApplyExt(ext etensor.Tensor) // ApplyExt1D applies external input in the form of a flat 1-dimensional slice of floats // If the layer is a Target or Compare layer type, then it goes in Targ // otherwise it goes in Ext ApplyExt1D(ext []float64) // UpdateExtFlags updates the neuron flags for external input based on current // layer Type field -- call this if the Type has changed since the last // ApplyExt* method call. UpdateExtFlags() // IsTarget returns true if this layer is a Target layer. // By default, returns true for layers of Type == emer.Target // Other Target layers include the TRCLayer in deep predictive learning. // This is used for turning off BCM hebbian learning, // in CosDiffFmActs to set the CosDiff.ModAvgLLrn value // for error-modulated level of hebbian learning. // It is also used in SynScale to not apply it to target layers. // In both cases, Target layers are purely error-driven. IsTarget() bool // AlphaCycInit handles all initialization at start of new input pattern, // including computing netinput scaling from running average activation etc. // should already have presented the external input to the network at this point. AlphaCycInit() // GScaleFmAvgAct computes the scaling factor for synaptic conductance input // based on sending layer average activation. // This attempts to automatically adjust for overall differences in raw // activity coming into the units to achieve a general target // of around .5 to 1 for the integrated G values. GScaleFmAvgAct() // GenNoise generates random noise for all neurons GenNoise() // DecayState decays activation state by given proportion (default is on ly.Act.Init.Decay) DecayState(decay float32) // HardClamp hard-clamps the activations in the layer -- called during AlphaCycInit // for hard-clamped Input layers HardClamp() // SendSpike sends spike to receivers SendSpike(ltime *Time) // GFmInc integrates new synaptic conductances from increments sent during last SendGDelta GFmInc(ltime *Time) // AvgMaxGe computes the average and max Ge stats, used in inhibition AvgMaxGe(ltime *Time) // InhibiFmGeAct computes inhibition Gi from Ge and Act averages within relevant Pools InhibFmGeAct(ltime *Time) // ActFmG computes rate-code activation from Ge, Gi, Gl conductances // and updates learning running-average activations from that Act ActFmG(ltime *Time) // AvgMaxAct computes the average and max Act stats, used in inhibition AvgMaxAct(ltime *Time) // CyclePost is called after the standard Cycle update, as a separate // network layer loop. // This is reserved for any kind of special ad-hoc types that // need to do something special after Act is finally computed. // For example, sending a neuromodulatory signal such as dopamine. CyclePost(ltime *Time) // QuarterFinal does updating after end of a quarter QuarterFinal(ltime *Time) // CosDiffFmActs computes the cosine difference in activation state // between minus and plus phases. // This is also used for modulating the amount of BCM hebbian learning CosDiffFmActs() // DWt computes the weight change (learning) -- calls DWt method on sending projections DWt() // DWtSubMean subtracts a portion of the mean recv DWt per projection DWtSubMean() // WtFmDWt updates the weights from delta-weight changes -- on the sending projections WtFmDWt() // SynScale performs synaptic scaling based on running average activation vs. targets SynScale() // LrateMult sets the new Lrate parameter for Prjns to LrateInit * mult. // Useful for implementing learning rate schedules. LrateMult(mult float32) }
AxonLayer defines the essential algorithmic API for Axon, at the layer level. These are the methods that the axon.Network calls on its layers at each step of processing. Other Layer types can selectively re-implement (override) these methods to modify the computation, while inheriting the basic behavior for non-overridden methods.
All of the structural API is in emer.Layer, which this interface also inherits for convenience.
type AxonNetwork ¶
type AxonNetwork interface { emer.Network // AsAxon returns this network as a axon.Network -- so that the // AxonNetwork interface does not need to include accessors // to all the basic stuff AsAxon() *Network // AlphaCycInitImpl handles all initialization at start of new input pattern, including computing // input scaling from running average activation etc. AlphaCycInitImpl() // CycleImpl runs one cycle of activation updating: // * Sends Ge increments from sending to receiving layers // * Average and Max Ge stats // * Inhibition based on Ge stats and Act Stats (computed at end of Cycle) // * Activation from Ge, Gi, and Gl // * Average and Max Act stats // This basic version doesn't use the time info, but more specialized types do, and we // want to keep a consistent API for end-user code. CycleImpl(ltime *Time) // CyclePostImpl is called after the standard Cycle update, and calls CyclePost // on Layers -- this is reserved for any kind of special ad-hoc types that // need to do something special after Act is finally computed. // For example, sending a neuromodulatory signal such as dopamine. CyclePostImpl(ltime *Time) // QuarterFinalImpl does updating after end of a quarter QuarterFinalImpl(ltime *Time) // DWtImpl computes the weight change (learning) based on current // running-average activation values DWtImpl() // WtFmDWtImpl updates the weights from delta-weight changes. // Also calls SynScale every Interval times WtFmDWtImpl() }
AxonNetwork defines the essential algorithmic API for Axon, at the network level. These are the methods that the user calls in their Sim code: * AlphaCycInit * Cycle * QuarterFinal * DWt * WtFmDwt Because we don't want to have to force the user to use the interface cast in calling these methods, we provide Impl versions here that are the implementations which the user-facing method calls.
Typically most changes in algorithm can be accomplished directly in the Layer or Prjn level, but sometimes (e.g., in deep) additional full-network passes are required.
All of the structural API is in emer.Network, which this interface also inherits for convenience.
type AxonPrjn ¶
type AxonPrjn interface { emer.Prjn // AsAxon returns this prjn as a axon.Prjn -- so that the AxonPrjn // interface does not need to include accessors to all the basic stuff. AsAxon() *Prjn // InitWts initializes weight values according to Learn.WtInit params InitWts() // InitWtSym initializes weight symmetry -- is given the reciprocal projection where // the Send and Recv layers are reversed. InitWtSym(rpj AxonPrjn) // InitGbuf initializes the per-projection synaptic conductance buffers. // This is not typically needed (called during InitWts, InitActs) // but can be called when needed. InitGbuf() // SendSpike sends a spike from sending neuron index si, // to add to buffer on receivers. SendSpike(si int) // RecvGInc increments the receiver's synaptic conductances from those of all the projections. RecvGInc() // DWt computes the weight change (learning) -- on sending projections DWt() // DWtSubMean subtracts a portion of the mean recv DWt per projection DWtSubMean() // WtFmDWt updates the synaptic weight values from delta-weight changes -- on sending projections WtFmDWt() // SynScale performs synaptic scaling based on running average activation vs. targets SynScale() // LrateMult sets the new Lrate parameter for Prjns to LrateInit * mult. // Useful for implementing learning rate schedules. LrateMult(mult float32) }
AxonPrjn defines the essential algorithmic API for Axon, at the projection level. These are the methods that the axon.Layer calls on its prjns at each step of processing. Other Prjn types can selectively re-implement (override) these methods to modify the computation, while inheriting the basic behavior for non-overridden methods.
All of the structural API is in emer.Prjn, which this interface also inherits for convenience.
type ClampParams ¶
type ClampParams struct { ErrThr float32 `def:"0.5" desc:"threshold on neuron Act activity to count as active for computing error relative to target in PctErr method"` Hard bool `def:"true" desc:"whether to hard clamp inputs where spiking rate is set to Poisson noise with external input * Rate factor"` Rate float32 `def:"180" desc:"maximum spiking rate in Hz for Poisson spike generator (multiplies clamped input value to get rate)"` Gain float32 `viewif:"!Hard" def:"0.02:0.5" desc:"soft clamp gain factor (Ge += Gain * Ext)"` Avg bool `` /* 181-byte string literal not displayed */ AvgGain float32 `` /* 145-byte string literal not displayed */ }
ClampParams are for specifying how external inputs are clamped onto network activation values
func (*ClampParams) AvgGe ¶
func (cp *ClampParams) AvgGe(ext, ge float32) float32
AvgGe computes Avg-based Ge clamping value if using that option.
func (*ClampParams) Defaults ¶
func (cp *ClampParams) Defaults()
func (*ClampParams) Update ¶
func (cp *ClampParams) Update()
type CosDiffParams ¶
type CosDiffParams struct { Tau float32 `` /* 588-byte string literal not displayed */ Dt float32 `inactive:"+" view:"-" json:"-" xml:"-" desc:"rate constant = 1 / Tau"` DtC float32 `inactive:"+" view:"-" json:"-" xml:"-" desc:"complement of rate constant = 1 - Dt"` }
CosDiffParams specify how to integrate cosine of difference between plus and minus phase activations Used to modulate amount of hebbian learning, and overall learning rate.
func (*CosDiffParams) AvgVarFmCos ¶
func (cd *CosDiffParams) AvgVarFmCos(avg, vr *float32, cos float32)
AvgVarFmCos updates the average and variance from current cosine diff value
func (*CosDiffParams) Defaults ¶
func (cd *CosDiffParams) Defaults()
func (*CosDiffParams) Update ¶
func (cd *CosDiffParams) Update()
type CosDiffStats ¶
type CosDiffStats struct { Cos float32 `` /* 185-byte string literal not displayed */ Avg float32 `` /* 234-byte string literal not displayed */ Var float32 `` /* 193-byte string literal not displayed */ }
CosDiffStats holds cosine-difference statistics at the layer level
func (*CosDiffStats) Init ¶
func (cd *CosDiffStats) Init()
type DtParams ¶
type DtParams struct { Integ float32 `` /* 649-byte string literal not displayed */ VmTau float32 `` /* 322-byte string literal not displayed */ VmDendTau float32 `def:"5" min:"1" desc:"dendritic membrane potential integration time constant"` GeTau float32 `def:"5" min:"1" desc:"time constant for decay of excitatory AMPA receptor conductance."` GiTau float32 `def:"7" min:"1" desc:"time constant for decay of inhibitory GABAa receptor conductance."` MTau float32 `` /* 333-byte string literal not displayed */ VmDt float32 `view:"-" json:"-" xml:"-" desc:"nominal rate = Integ / tau"` VmDendDt float32 `view:"-" json:"-" xml:"-" desc:"nominal rate = Integ / tau"` GeDt float32 `view:"-" json:"-" xml:"-" desc:"rate = Integ / tau"` GiDt float32 `view:"-" json:"-" xml:"-" desc:"rate = Integ / tau"` MDt float32 `view:"-" json:"-" xml:"-" desc:"rate = Integ / tau"` }
DtParams are time and rate constants for temporal derivatives in Axon (Vm, G)
func (*DtParams) GeFmRaw ¶
GeFmRaw updates ge from raw input, decaying with time constant, back to min baseline value
type InhibParams ¶
type InhibParams struct { Layer fffb.Params `view:"inline" desc:"inhibition across the entire layer"` Pool fffb.Params `view:"inline" desc:"inhibition across sub-pools of units, for layers with 4D shape"` Self SelfInhibParams `` /* 161-byte string literal not displayed */ ActAvg ActAvgParams `` /* 144-byte string literal not displayed */ Adapt fffb.Adapt `view:"inline" desc:"adaptive inhibition multiplier"` }
axon.InhibParams contains all the inhibition computation params and functions for basic Axon This is included in axon.Layer to support computation. This also includes other misc layer-level params such as running-average activation in the layer which is used for netinput rescaling and potentially for adapting inhibition over time
func (*InhibParams) Defaults ¶
func (ip *InhibParams) Defaults()
func (*InhibParams) Update ¶
func (ip *InhibParams) Update()
type LayFunChan ¶
type LayFunChan chan func(ly AxonLayer)
LayFunChan is a channel that runs AxonLayer functions
type Layer ¶
type Layer struct { LayerStru Act ActParams `view:"add-fields" desc:"Activation parameters and methods for computing activations"` Inhib InhibParams `view:"add-fields" desc:"Inhibition parameters and methods for computing layer-level inhibition"` Learn LearnNeurParams `view:"add-fields" desc:"Learning parameters and methods that operate at the neuron level"` Neurons []Neuron `` /* 133-byte string literal not displayed */ Pools []Pool `` /* 234-byte string literal not displayed */ GiMult float32 `inactive:"+" desc:"multiplier on inhibition -- adapted to maintain target activity level"` GiAdaptCtr int `inactive:"+" desc:"counter for how long it has been since last adapting inhibition"` CosDiff CosDiffStats `desc:"cosine difference between ActM, ActP stats"` }
axon.Layer has parameters for running a basic rate-coded Axon layer
func (*Layer) ActFmG ¶
ActFmG computes rate-code activation from Ge, Gi, Gl conductances and updates learning running-average activations from that Act
func (*Layer) AlphaCycInit ¶
func (ly *Layer) AlphaCycInit()
AlphaCycInit handles all initialization at start of new input pattern, including computing input scaling from running average activation etc. should already have presented the external input to the network at this point.
func (*Layer) ApplyExt ¶
ApplyExt applies external input in the form of an etensor.Float32. If dimensionality of tensor matches that of layer, and is 2D or 4D, then each dimension is iterated separately, so any mismatch preserves dimensional structure. Otherwise, the flat 1D view of the tensor is used. If the layer is a Target or Compare layer type, then it goes in Targ otherwise it goes in Ext
func (*Layer) ApplyExt1D ¶
ApplyExt1D applies external input in the form of a flat 1-dimensional slice of floats If the layer is a Target or Compare layer type, then it goes in Targ otherwise it goes in Ext
func (*Layer) ApplyExt1D32 ¶
ApplyExt1D32 applies external input in the form of a flat 1-dimensional slice of float32s. If the layer is a Target or Compare layer type, then it goes in Targ otherwise it goes in Ext
func (*Layer) ApplyExt1DTsr ¶
ApplyExt1DTsr applies external input using 1D flat interface into tensor. If the layer is a Target or Compare layer type, then it goes in Targ otherwise it goes in Ext
func (*Layer) ApplyExt2D ¶
ApplyExt2D applies 2D tensor external input
func (*Layer) ApplyExt2Dto4D ¶
ApplyExt2Dto4D applies 2D tensor external input to a 4D layer
func (*Layer) ApplyExt4D ¶
ApplyExt4D applies 4D tensor external input
func (*Layer) ApplyExtFlags ¶
ApplyExtFlags gets the clear mask and set mask for updating neuron flags based on layer type, and whether input should be applied to Targ (else Ext)
func (*Layer) AsAxon ¶
AsAxon returns this layer as a axon.Layer -- all derived layers must redefine this to return the base Layer type, so that the AxonLayer interface does not need to include accessors to all the basic stuff
func (*Layer) BuildPools ¶
BuildPools builds the inhibitory pools structures -- nu = number of units in layer
func (*Layer) BuildPrjns ¶
BuildPrjns builds the projections, recv-side
func (*Layer) BuildSubPools ¶
func (ly *Layer) BuildSubPools()
BuildSubPools initializes neuron start / end indexes for sub-pools
func (*Layer) CosDiffFmActs ¶
func (ly *Layer) CosDiffFmActs()
CosDiffFmActs computes the cosine difference in activation state between minus and plus phases. this is also used for modulating the amount of BCM hebbian learning
func (*Layer) CostEst ¶
CostEst returns the estimated computational cost associated with this layer, separated by neuron-level and synapse-level, in arbitrary units where cost per synapse is 1. Neuron-level computation is more expensive but there are typically many fewer neurons, so in larger networks, synaptic costs tend to dominate. Neuron cost is estimated from TimerReport output for large networks.
func (*Layer) CyclePost ¶
CyclePost is called after the standard Cycle update, as a separate network layer loop. This is reserved for any kind of special ad-hoc types that need to do something special after Act is finally computed. For example, sending a neuromodulatory signal such as dopamine.
func (*Layer) DWt ¶
func (ly *Layer) DWt()
DWt computes the weight change (learning) -- calls DWt method on sending projections
func (*Layer) DWtSubMean ¶ added in v1.2.23
func (ly *Layer) DWtSubMean()
DWtSubMean subtracts a portion of the mean recv DWt per projection
func (*Layer) DecayState ¶
DecayState decays activation state by given proportion (default is on ly.Act.Init.Decay). This does *not* call InitGInc -- must call that separately at start of AlphaCyc
func (*Layer) DecayStatePool ¶
DecayStatePool decays activation state by given proportion in given sub-pool index (0 based)
func (*Layer) GFmInc ¶
GFmInc integrates new synaptic conductances from increments sent during last Spike
func (*Layer) GFmIncNeur ¶
GFmIncNeur is the neuron-level code for GFmInc that integrates overall Ge, Gi values from their G*Raw accumulators.
func (*Layer) GScaleFmAvgAct ¶
func (ly *Layer) GScaleFmAvgAct()
GScaleFmAvgAct computes the scaling factor for synaptic input conductances G, based on sending layer average activation. This attempts to automatically adjust for overall differences in raw activity coming into the units to achieve a general target of around .5 to 1 for the integrated Ge value.
func (*Layer) GenNoise ¶
func (ly *Layer) GenNoise()
GenNoise generates random noise for all neurons
func (*Layer) HardClamp ¶
func (ly *Layer) HardClamp()
HardClamp hard-clamps the activations in the layer -- called during AlphaCycInit for hard-clamped Input layers
func (*Layer) InhibFmGeAct ¶
InhibFmGeAct computes inhibition Gi from Ge and Act averages within relevant Pools
func (*Layer) InhibFmPool ¶
InhibFmPool computes inhibition Gi from Pool-level aggregated inhibition, including self and syn
func (*Layer) InitActAvg ¶
func (ly *Layer) InitActAvg()
InitActAvg initializes the running-average activation values that drive learning. and the longer time averaging values.
func (*Layer) InitActs ¶
func (ly *Layer) InitActs()
InitActs fully initializes activation state -- only called automatically during InitWts
func (*Layer) InitExt ¶
func (ly *Layer) InitExt()
InitExt initializes external input state -- called prior to apply ext
func (*Layer) InitWtSym ¶
func (ly *Layer) InitWtSym()
InitWtsSym initializes the weight symmetry -- higher layers copy weights from lower layers
func (*Layer) InitWts ¶
func (ly *Layer) InitWts()
InitWts initializes the weight values in the network, i.e., resetting learning Also calls InitActs
func (*Layer) IsTarget ¶
IsTarget returns true if this layer is a Target layer. By default, returns true for layers of Type == emer.Target Other Target layers include the TRCLayer in deep predictive learning. This is used for turning off BCM hebbian learning, in CosDiffFmActs to set the CosDiff.ModAvgLLrn value for error-modulated level of hebbian learning. It is also used in SynScale to not apply it to target layers. In both cases, Target layers are purely error-driven.
func (*Layer) LesionNeurons ¶
LesionNeurons lesions (sets the Off flag) for given proportion (0-1) of neurons in layer returns number of neurons lesioned. Emits error if prop > 1 as indication that percent might have been passed
func (*Layer) LrateMult ¶
LrateMult sets the new Lrate parameter for Prjns to LrateInit * mult. Useful for implementing learning rate schedules.
func (*Layer) PctUnitErr ¶
PctUnitErr returns the proportion of units where the thresholded value of Targ (Target or Compare types) or ActP does not match that of ActM. If Act > ly.Act.Clamp.ErrThr, effective activity = 1 else 0 robust to noisy activations.
func (*Layer) PoolInhibFmGeAct ¶
PoolInhibFmGeAct computes inhibition Gi from Ge and Act averages within relevant Pools
func (*Layer) QuarterFinal ¶
QuarterFinal does updating after end of a quarter
func (*Layer) ReadWtsJSON ¶
ReadWtsJSON reads the weights from this layer from the receiver-side perspective in a JSON text format. This is for a set of weights that were saved *for one layer only* and is not used for the network-level ReadWtsJSON, which reads into a separate structure -- see SetWts method.
func (*Layer) RecvGInc ¶
RecvGInc calls RecvGInc on receiving projections to collect Neuron-level G*Inc values. This is called by GFmInc overall method, but separated out for cases that need to do something different.
func (*Layer) RecvPrjnVals ¶
func (ly *Layer) RecvPrjnVals(vals *[]float32, varNm string, sendLay emer.Layer, sendIdx1D int, prjnType string) error
RecvPrjnVals fills in values of given synapse variable name, for projection into given sending layer and neuron 1D index, for all receiving neurons in this layer, into given float32 slice (only resized if not big enough). prjnType is the string representation of the prjn type -- used if non-empty, useful when there are multiple projections between two layers. Returns error on invalid var name. If the receiving neuron is not connected to the given sending layer or neuron then the value is set to mat32.NaN(). Returns error on invalid var name or lack of recv prjn (vals always set to nan on prjn err).
func (*Layer) SendPrjnVals ¶
func (ly *Layer) SendPrjnVals(vals *[]float32, varNm string, recvLay emer.Layer, recvIdx1D int, prjnType string) error
SendPrjnVals fills in values of given synapse variable name, for projection into given receiving layer and neuron 1D index, for all sending neurons in this layer, into given float32 slice (only resized if not big enough). prjnType is the string representation of the prjn type -- used if non-empty, useful when there are multiple projections between two layers. Returns error on invalid var name. If the sending neuron is not connected to the given receiving layer or neuron then the value is set to mat32.NaN(). Returns error on invalid var name or lack of recv prjn (vals always set to nan on prjn err).
func (*Layer) SynScale ¶ added in v1.2.23
func (ly *Layer) SynScale()
SynScale performs synaptic scaling based on running average activation vs. targets
func (*Layer) UnLesionNeurons ¶
func (ly *Layer) UnLesionNeurons()
UnLesionNeurons unlesions (clears the Off flag) for all neurons in the layer
func (*Layer) UnitVal ¶
UnitVal returns value of given variable name on given unit, using shape-based dimensional index
func (*Layer) UnitVal1D ¶
UnitVal1D returns value of given variable index on given unit, using 1-dimensional index. returns NaN on invalid index. This is the core unit var access method used by other methods, so it is the only one that needs to be updated for derived layer types.
func (*Layer) UnitVals ¶
UnitVals fills in values of given variable name on unit, for each unit in the layer, into given float32 slice (only resized if not big enough). Returns error on invalid var name.
func (*Layer) UnitValsTensor ¶
UnitValsTensor returns values of given variable name on unit for each unit in the layer, as a float32 tensor in same shape as layer units.
func (*Layer) UnitVarIdx ¶
UnitVarIdx returns the index of given variable within the Neuron, according to *this layer's* UnitVarNames() list (using a map to lookup index), or -1 and error message if not found.
func (*Layer) UnitVarNames ¶
UnitVarNames returns a list of variable names available on the units in this layer
func (*Layer) UnitVarNum ¶
UnitVarNum returns the number of Neuron-level variables for this layer. This is needed for extending indexes in derived types.
func (*Layer) UnitVarProps ¶
UnitVarProps returns properties for variables
func (*Layer) UpdateExtFlags ¶
func (ly *Layer) UpdateExtFlags()
UpdateExtFlags updates the neuron flags for external input based on current layer Type field -- call this if the Type has changed since the last ApplyExt* method call.
func (*Layer) UpdateParams ¶
func (ly *Layer) UpdateParams()
UpdateParams updates all params given any changes that might have been made to individual values including those in the receiving projections of this layer
func (*Layer) VarRange ¶
VarRange returns the min / max values for given variable todo: support r. s. projection values
func (*Layer) WriteWtsJSON ¶
WriteWtsJSON writes the weights from this layer from the receiver-side perspective in a JSON text format. We build in the indentation logic to make it much faster and more efficient.
type LayerStru ¶
type LayerStru struct { AxonLay AxonLayer `` /* 297-byte string literal not displayed */ Network emer.Network `` /* 141-byte string literal not displayed */ Nm string `` /* 151-byte string literal not displayed */ Cls string `desc:"Class is for applying parameter styles, can be space separated multple tags"` Off bool `desc:"inactivate this layer -- allows for easy experimentation"` Shp etensor.Shape `` /* 219-byte string literal not displayed */ Typ emer.LayerType `` /* 161-byte string literal not displayed */ Thr int `` /* 216-byte string literal not displayed */ Rel relpos.Rel `view:"inline" desc:"Spatial relationship to other layer, determines positioning"` Ps mat32.Vec3 `` /* 154-byte string literal not displayed */ Idx int `` /* 256-byte string literal not displayed */ RcvPrjns emer.Prjns `desc:"list of receiving projections into this layer from other layers"` SndPrjns emer.Prjns `desc:"list of sending projections from this layer to other layers"` }
axon.LayerStru manages the structural elements of the layer, which are common to any Layer type
func (*LayerStru) ApplyParams ¶
ApplyParams applies given parameter style Sheet to this layer and its recv projections. Calls UpdateParams on anything set to ensure derived parameters are all updated. If setMsg is true, then a message is printed to confirm each parameter that is set. it always prints a message if a parameter fails to be set. returns true if any params were set, and error if there were any errors.
func (*LayerStru) InitName ¶
InitName MUST be called to initialize the layer's pointer to itself as an emer.Layer which enables the proper interface methods to be called. Also sets the name, and the parent network that this layer belongs to (which layers may want to retain).
func (*LayerStru) NPools ¶
NPools returns the number of unit sub-pools according to the shape parameters. Currently supported for a 4D shape, where the unit pools are the first 2 Y,X dims and then the units within the pools are the 2nd 2 Y,X dims
func (*LayerStru) NRecvPrjns ¶
func (*LayerStru) NSendPrjns ¶
func (*LayerStru) NonDefaultParams ¶
NonDefaultParams returns a listing of all parameters in the Layer that are not at their default values -- useful for setting param styles etc.
func (*LayerStru) RecipToSendPrjn ¶
RecipToSendPrjn finds the reciprocal projection relative to the given sending projection found within the SendPrjns of this layer. This is then a recv prjn within this layer:
S=A -> R=B recip: R=A <- S=B -- ly = A -- we are the sender of srj and recv of rpj.
returns false if not found.
type LearnNeurParams ¶
type LearnNeurParams struct { ActAvg LrnActAvgParams `view:"inline" desc:"parameters for computing running average activations that drive learning"` CosDiff CosDiffParams `view:"inline" desc:"parameters for computing cosine diff between minus and plus phase"` SynScale SynScaleParams `` /* 126-byte string literal not displayed */ }
axon.LearnNeurParams manages learning-related parameters at the neuron-level. This is mainly the running average activations that drive learning
func (*LearnNeurParams) AvgsFmAct ¶
func (ln *LearnNeurParams) AvgsFmAct(nrn *Neuron)
AvgsFmAct updates the running averages based on current learning activation. Computed after new activation for current cycle is updated.
func (*LearnNeurParams) Defaults ¶
func (ln *LearnNeurParams) Defaults()
func (*LearnNeurParams) InitActAvg ¶
func (ln *LearnNeurParams) InitActAvg(nrn *Neuron)
InitActAvg initializes the running-average activation values that drive learning. Called by InitWts (at start of learning).
func (*LearnNeurParams) Update ¶
func (ln *LearnNeurParams) Update()
type LearnSynParams ¶
type LearnSynParams struct { Learn bool `desc:"enable learning for this projection"` Lrate float32 `desc:"current effective learning rate (multiplies DWt values, determining rate of change of weights)"` LrateInit float32 `` /* 194-byte string literal not displayed */ XCal XCalParams `view:"inline" desc:"parameters for the XCal learning rule"` WtSig WtSigParams `view:"inline" desc:"parameters for the sigmoidal contrast weight enhancement"` }
axon.LearnSynParams manages learning-related parameters at the synapse-level.
func (*LearnSynParams) CHLdWt ¶
func (ls *LearnSynParams) CHLdWt(suAvgSLrn, suAvgM, ruAvgSLrn, ruAvgM float32) float32
CHLdWt returns the error-driven weight change component for the temporally eXtended Contrastive Attractor Learning (XCAL), CHL version
func (*LearnSynParams) Defaults ¶
func (ls *LearnSynParams) Defaults()
func (*LearnSynParams) LWtFmWt ¶
func (ls *LearnSynParams) LWtFmWt(syn *Synapse)
LWtFmWt updates the linear weight value based on the current effective Wt value. effective weight is sigmoidally contrast-enhanced relative to the linear weight.
func (*LearnSynParams) Update ¶
func (ls *LearnSynParams) Update()
func (*LearnSynParams) WtFmDWt ¶
func (ls *LearnSynParams) WtFmDWt(dwt, wt, lwt *float32, scale float32)
WtFmDWt updates the synaptic weights from accumulated weight changes wbInc and wbDec are the weight balance factors, wt is the sigmoidal contrast-enhanced weight and lwt is the linear weight value
func (*LearnSynParams) WtFmLWt ¶
func (ls *LearnSynParams) WtFmLWt(syn *Synapse)
WtFmLWt updates the effective weight value based on the current linear Wt value. effective weight is sigmoidally contrast-enhanced relative to the linear weight.
type LrnActAvgParams ¶
type LrnActAvgParams struct { SpikeG float32 `def:"8" desc:"gain multiplier on spike: how much spike drives AvgSS value"` SSTau float32 `` /* 526-byte string literal not displayed */ STau float32 `` /* 376-byte string literal not displayed */ MTau float32 `` /* 515-byte string literal not displayed */ LrnM float32 `` /* 618-byte string literal not displayed */ Init float32 `def:"0.15" min:"0" max:"1" desc:"initial value for average"` SSDt float32 `view:"-" json:"-" xml:"-" inactive:"+" desc:"rate = 1 / tau"` SDt float32 `view:"-" json:"-" xml:"-" inactive:"+" desc:"rate = 1 / tau"` MDt float32 `view:"-" json:"-" xml:"-" inactive:"+" desc:"rate = 1 / tau"` LrnS float32 `view:"-" json:"-" xml:"-" inactive:"+" desc:"1-LrnM"` }
LrnActAvgParams has rate constants for averaging over activations at different time scales, to produce the running average activation values that then drive learning in the XCAL learning rules. Is driven directly by spikes that increment running-average at super-short timescale. Time cycle of 50 msec quarters / theta window learning works Cyc:50, SS:35 S:8, M:40 (best) Cyc:25, SS:20, S:4, M:20
func (*LrnActAvgParams) AvgsFmAct ¶
func (aa *LrnActAvgParams) AvgsFmAct(act float32, avgSS, avgS, avgM, avgSLrn *float32)
AvgsFmAct computes averages based on current act
func (*LrnActAvgParams) Defaults ¶
func (aa *LrnActAvgParams) Defaults()
func (*LrnActAvgParams) Update ¶
func (aa *LrnActAvgParams) Update()
type NMDAPrjn ¶
type NMDAPrjn struct {
Prjn // access as .Prjn
}
NMDAPrjn is a projection with NMDA maintenance channels. It marks a projection for special treatment in a MaintLayer which actually does the NMDA computations. Excitatory conductance is aggregated separately for this projection.
func (*NMDAPrjn) PrjnTypeName ¶
func (*NMDAPrjn) UpdateParams ¶
func (pj *NMDAPrjn) UpdateParams()
type Network ¶
type Network struct { NetworkStru SynScaleInterval int `def:"100" desc:"how frequently to perform synaptic scaling -- long enough for meaningful changes"` SynScaleCtr int `inactive:"+" desc:"counter for how long it has been since last SynScale"` }
axon.Network has parameters for running a basic rate-coded Axon network
func (*Network) AlphaCycInit ¶
func (nt *Network) AlphaCycInit()
AlphaCycInit handles all initialization at start of new input pattern, including computing input scaling from running average activation etc.
func (*Network) AlphaCycInitImpl ¶
func (nt *Network) AlphaCycInitImpl()
AlphaCycInitImpl handles all initialization at start of new input pattern, including computing input scaling from running average activation etc.
func (*Network) CollectDWts ¶
CollectDWts writes all of the synaptic DWt values to given dwts slice which is pre-allocated to given nwts size if dwts is nil, in which case the method returns true so that the actual length of dwts can be passed next time around. Used for MPI sharing of weight changes across processors.
func (*Network) Cycle ¶
Cycle runs one cycle of activation updating: * Sends Ge increments from sending to receiving layers * Average and Max Ge stats * Inhibition based on Ge stats and Act Stats (computed at end of Cycle) * Activation from Ge, Gi, and Gl * Average and Max Act stats This basic version doesn't use the time info, but more specialized types do, and we want to keep a consistent API for end-user code.
func (*Network) CycleImpl ¶
CycleImpl runs one cycle of activation updating: * Sends Ge increments from sending to receiving layers * Average and Max Ge stats * Inhibition based on Ge stats and Act Stats (computed at end of Cycle) * Activation from Ge, Gi, and Gl * Average and Max Act stats This basic version doesn't use the time info, but more specialized types do, and we want to keep a consistent API for end-user code.
func (*Network) CyclePost ¶
CyclePost is called after the standard Cycle update, and calls CyclePost on Layers -- this is reserved for any kind of special ad-hoc types that need to do something special after Act is finally computed. For example, sending a neuromodulatory signal such as dopamine.
func (*Network) CyclePostImpl ¶
CyclePostImpl is called after the standard Cycle update, and calls CyclePost on Layers -- this is reserved for any kind of special ad-hoc types that need to do something special after Act is finally computed. For example, sending a neuromodulatory signal such as dopamine.
func (*Network) DWt ¶
func (nt *Network) DWt()
DWt computes the weight change (learning) based on current running-average activation values
func (*Network) DWtImpl ¶
func (nt *Network) DWtImpl()
DWtImpl computes the weight change (learning) based on current running-average activation values
func (*Network) DecayState ¶
DecayState decays activation state by given proportion e.g., 1 = decay completely, and 0 = decay not at all This is called automatically in AlphaCycInit, but is avail here for ad-hoc decay cases.
func (*Network) Defaults ¶
func (nt *Network) Defaults()
Defaults sets all the default parameters for all layers and projections
func (*Network) GScaleFmAvgAct ¶
func (nt *Network) GScaleFmAvgAct()
GScaleFmAvgAct computes the scaling factor for synaptic input conductances G, based on sending layer average activation. This attempts to automatically adjust for overall differences in raw activity coming into the units to achieve a general target of around .5 to 1 for the integrated Ge value. This is automatically done during AlphaCycInit, but if scaling parameters are changed at any point thereafter during AlphaCyc, this must be called.
func (*Network) InhibFmGeAct ¶
InhibiFmGeAct computes inhibition Gi from Ge and Act stats within relevant Pools
func (*Network) InitActs ¶
func (nt *Network) InitActs()
InitActs fully initializes activation state -- not automatically called
func (*Network) InitExt ¶
func (nt *Network) InitExt()
InitExt initializes external input state -- call prior to applying external inputs to layers
func (*Network) InitTopoScales ¶
func (nt *Network) InitTopoScales()
InitTopoScales initializes synapse-specific scale parameters from prjn types that support them, with flags set to support it, includes: prjn.PoolTile prjn.Circle. call before InitWts if using Topo wts
func (*Network) InitWts ¶
func (nt *Network) InitWts()
InitWts initializes synaptic weights and all other associated long-term state variables including running-average state values (e.g., layer running average activations etc)
func (*Network) LayersSetOff ¶
LayersSetOff sets the Off flag for all layers to given setting
func (*Network) LrateMult ¶
LrateMult sets the new Lrate parameter for Prjns to LrateInit * mult. Useful for implementing learning rate schedules.
func (*Network) QuarterFinal ¶
QuarterFinal does updating after end of a quarter
func (*Network) QuarterFinalImpl ¶
QuarterFinalImpl does updating after end of a quarter
func (*Network) SendSpike ¶
SendSpike sends change in activation since last sent, if above thresholds and integrates sent deltas into GeRaw and time-integrated Ge values
func (*Network) SetDWts ¶
SetDWts sets the DWt weight changes from given array of floats, which must be correct size
func (*Network) SizeReport ¶
SizeReport returns a string reporting the size of each layer and projection in the network, and total memory footprint.
func (*Network) SynScale ¶ added in v1.2.23
func (nt *Network) SynScale()
SynScale performs synaptic scaling, receiver based
func (*Network) SynVarNames ¶
SynVarNames returns the names of all the variables on the synapses in this network. Not all projections need to support all variables, but must safely return 0's for unsupported ones. The order of this list determines NetView variable display order. This is typically a global list so do not modify!
func (*Network) SynVarProps ¶
SynVarProps returns properties for variables
func (*Network) ThreadAlloc ¶
ThreadAlloc allocates layers to given number of threads, attempting to evenly divide computation. Returns report of thread allocations and estimated computational cost per thread.
func (*Network) ThreadReport ¶
ThreadReport returns report of thread allocations and estimated computational cost per thread.
func (*Network) UnLesionNeurons ¶
func (nt *Network) UnLesionNeurons()
UnLesionNeurons unlesions neurons in all layers in the network. Provides a clean starting point for subsequent lesion experiments.
func (*Network) UnitVarNames ¶
UnitVarNames returns a list of variable names available on the units in this network. Not all layers need to support all variables, but must safely return 0's for unsupported ones. The order of this list determines NetView variable display order. This is typically a global list so do not modify!
func (*Network) UnitVarProps ¶
UnitVarProps returns properties for variables
func (*Network) UpdateExtFlags ¶
func (nt *Network) UpdateExtFlags()
UpdateExtFlags updates the neuron flags for external input based on current layer Type field -- call this if the Type has changed since the last ApplyExt* method call.
func (*Network) UpdateParams ¶
func (nt *Network) UpdateParams()
UpdateParams updates all the derived parameters if any have changed, for all layers and projections
func (*Network) WtFmDWt ¶
func (nt *Network) WtFmDWt()
WtFmDWt updates the weights from delta-weight changes. Also calls SynScale every Interval times
func (*Network) WtFmDWtImpl ¶
func (nt *Network) WtFmDWtImpl()
WtFmDWtImpl updates the weights from delta-weight changes.
type NetworkStru ¶
type NetworkStru struct { EmerNet emer.Network `` /* 274-byte string literal not displayed */ Nm string `desc:"overall name of network -- helps discriminate if there are multiple"` Layers emer.Layers `desc:"list of layers"` WtsFile string `desc:"filename of last weights file loaded or saved"` LayMap map[string]emer.Layer `view:"-" desc:"map of name to layers -- layer names must be unique"` MinPos mat32.Vec3 `view:"-" desc:"minimum display position in network"` MaxPos mat32.Vec3 `view:"-" desc:"maximum display position in network"` MetaData map[string]string `` /* 194-byte string literal not displayed */ NThreads int `` /* 203-byte string literal not displayed */ LockThreads bool `` /* 165-byte string literal not displayed */ ThrLay [][]emer.Layer `` /* 179-byte string literal not displayed */ ThrChans []LayFunChan `view:"-" desc:"layer function channels, per thread"` ThrTimes []timer.Time `view:"-" desc:"timers for each thread, so you can see how evenly the workload is being distributed"` FunTimes map[string]*timer.Time `view:"-" desc:"timers for each major function (step of processing)"` WaitGp sync.WaitGroup `view:"-" desc:"network-level wait group for synchronizing threaded layer calls"` }
axon.NetworkStru holds the basic structural components of a network (layers)
func (*NetworkStru) AddLayer ¶
AddLayer adds a new layer with given name and shape to the network. 2D and 4D layer shapes are generally preferred but not essential -- see AddLayer2D and 4D for convenience methods for those. 4D layers enable pool (unit-group) level inhibition in Axon networks, for example. shape is in row-major format with outer-most dimensions first: e.g., 4D 3, 2, 4, 5 = 3 rows (Y) of 2 cols (X) of pools, with each unit group having 4 rows (Y) of 5 (X) units.
func (*NetworkStru) AddLayer2D ¶
AddLayer2D adds a new layer with given name and 2D shape to the network. 2D and 4D layer shapes are generally preferred but not essential.
func (*NetworkStru) AddLayer4D ¶
func (nt *NetworkStru) AddLayer4D(name string, nPoolsY, nPoolsX, nNeurY, nNeurX int, typ emer.LayerType) emer.Layer
AddLayer4D adds a new layer with given name and 4D shape to the network. 4D layers enable pool (unit-group) level inhibition in Axon networks, for example. shape is in row-major format with outer-most dimensions first: e.g., 4D 3, 2, 4, 5 = 3 rows (Y) of 2 cols (X) of pools, with each pool having 4 rows (Y) of 5 (X) neurons.
func (*NetworkStru) AddLayerInit ¶
AddLayerInit is implementation routine that takes a given layer and adds it to the network, and initializes and configures it properly.
func (*NetworkStru) AllParams ¶
func (nt *NetworkStru) AllParams() string
AllParams returns a listing of all parameters in the Network.
func (*NetworkStru) AllWtScales ¶
func (nt *NetworkStru) AllWtScales() string
AllWtScales returns a listing of all WtScale parameters in the Network in all Layers, Recv projections. These are among the most important and numerous of parameters (in larger networks) -- this helps keep track of what they all are set to.
func (*NetworkStru) ApplyParams ¶
ApplyParams applies given parameter style Sheet to layers and prjns in this network. Calls UpdateParams to ensure derived parameters are all updated. If setMsg is true, then a message is printed to confirm each parameter that is set. it always prints a message if a parameter fails to be set. returns true if any params were set, and error if there were any errors.
func (*NetworkStru) BidirConnectLayerNames ¶
func (nt *NetworkStru) BidirConnectLayerNames(low, high string, pat prjn.Pattern) (lowlay, highlay emer.Layer, fwdpj, backpj emer.Prjn, err error)
BidirConnectLayerNames establishes bidirectional projections between two layers, referenced by name, with low = the lower layer that sends a Forward projection to the high layer, and receives a Back projection in the opposite direction. Returns error if not successful. Does not yet actually connect the units within the layers -- that requires Build.
func (*NetworkStru) BidirConnectLayers ¶
func (nt *NetworkStru) BidirConnectLayers(low, high emer.Layer, pat prjn.Pattern) (fwdpj, backpj emer.Prjn)
BidirConnectLayers establishes bidirectional projections between two layers, with low = lower layer that sends a Forward projection to the high layer, and receives a Back projection in the opposite direction. Does not yet actually connect the units within the layers -- that requires Build.
func (*NetworkStru) BidirConnectLayersPy ¶
func (nt *NetworkStru) BidirConnectLayersPy(low, high emer.Layer, pat prjn.Pattern)
BidirConnectLayersPy establishes bidirectional projections between two layers, with low = lower layer that sends a Forward projection to the high layer, and receives a Back projection in the opposite direction. Does not yet actually connect the units within the layers -- that requires Build. Py = python version with no return vals.
func (*NetworkStru) Bounds ¶
func (nt *NetworkStru) Bounds() (min, max mat32.Vec3)
func (*NetworkStru) BoundsUpdt ¶
func (nt *NetworkStru) BoundsUpdt()
BoundsUpdt updates the Min / Max display bounds for 3D display
func (*NetworkStru) Build ¶
func (nt *NetworkStru) Build() error
Build constructs the layer and projection state based on the layer shapes and patterns of interconnectivity
func (*NetworkStru) BuildThreads ¶
func (nt *NetworkStru) BuildThreads()
BuildThreads constructs the layer thread allocation based on Thread setting in the layers
func (*NetworkStru) ConnectLayerNames ¶
func (nt *NetworkStru) ConnectLayerNames(send, recv string, pat prjn.Pattern, typ emer.PrjnType) (rlay, slay emer.Layer, pj emer.Prjn, err error)
ConnectLayerNames establishes a projection between two layers, referenced by name adding to the recv and send projection lists on each side of the connection. Returns error if not successful. Does not yet actually connect the units within the layers -- that requires Build.
func (*NetworkStru) ConnectLayers ¶
func (nt *NetworkStru) ConnectLayers(send, recv emer.Layer, pat prjn.Pattern, typ emer.PrjnType) emer.Prjn
ConnectLayers establishes a projection between two layers, adding to the recv and send projection lists on each side of the connection. Does not yet actually connect the units within the layers -- that requires Build.
func (*NetworkStru) ConnectLayersPrjn ¶
func (nt *NetworkStru) ConnectLayersPrjn(send, recv emer.Layer, pat prjn.Pattern, typ emer.PrjnType, pj emer.Prjn) emer.Prjn
ConnectLayersPrjn makes connection using given projection between two layers, adding given prjn to the recv and send projection lists on each side of the connection. Does not yet actually connect the units within the layers -- that requires Build.
func (*NetworkStru) FunTimerStart ¶
func (nt *NetworkStru) FunTimerStart(fun string)
FunTimerStart starts function timer for given function name -- ensures creation of timer
func (*NetworkStru) FunTimerStop ¶
func (nt *NetworkStru) FunTimerStop(fun string)
FunTimerStop stops function timer -- timer must already exist
func (*NetworkStru) InitName ¶
func (nt *NetworkStru) InitName(net emer.Network, name string)
InitName MUST be called to initialize the network's pointer to itself as an emer.Network which enables the proper interface methods to be called. Also sets the name.
func (*NetworkStru) Label ¶
func (nt *NetworkStru) Label() string
func (*NetworkStru) LateralConnectLayer ¶
LateralConnectLayer establishes a self-projection within given layer. Does not yet actually connect the units within the layers -- that requires Build.
func (*NetworkStru) LateralConnectLayerPrjn ¶
func (nt *NetworkStru) LateralConnectLayerPrjn(lay emer.Layer, pat prjn.Pattern, pj emer.Prjn) emer.Prjn
LateralConnectLayerPrjn makes lateral self-projection using given projection. Does not yet actually connect the units within the layers -- that requires Build.
func (*NetworkStru) LayerByName ¶
func (nt *NetworkStru) LayerByName(name string) emer.Layer
LayerByName returns a layer by looking it up by name in the layer map (nil if not found). Will create the layer map if it is nil or a different size than layers slice, but otherwise needs to be updated manually.
func (*NetworkStru) LayerByNameTry ¶
func (nt *NetworkStru) LayerByNameTry(name string) (emer.Layer, error)
LayerByNameTry returns a layer by looking it up by name -- emits a log error message if layer is not found
func (*NetworkStru) Layout ¶
func (nt *NetworkStru) Layout()
Layout computes the 3D layout of layers based on their relative position settings
func (*NetworkStru) MakeLayMap ¶
func (nt *NetworkStru) MakeLayMap()
MakeLayMap updates layer map based on current layers
func (*NetworkStru) NLayers ¶
func (nt *NetworkStru) NLayers() int
func (*NetworkStru) NonDefaultParams ¶
func (nt *NetworkStru) NonDefaultParams() string
NonDefaultParams returns a listing of all parameters in the Network that are not at their default values -- useful for setting param styles etc.
func (*NetworkStru) OpenWtsCpp ¶
func (nt *NetworkStru) OpenWtsCpp(filename gi.FileName) error
OpenWtsCpp opens network weights (and any other state that adapts with learning) from old C++ emergent format. If filename has .gz extension, then file is gzip uncompressed.
func (*NetworkStru) OpenWtsJSON ¶
func (nt *NetworkStru) OpenWtsJSON(filename gi.FileName) error
OpenWtsJSON opens network weights (and any other state that adapts with learning) from a JSON-formatted file. If filename has .gz extension, then file is gzip uncompressed.
func (*NetworkStru) ReadWtsCpp ¶
func (nt *NetworkStru) ReadWtsCpp(r io.Reader) error
ReadWtsCpp reads the weights from old C++ emergent format. Reads entire file into a temporary weights.Weights structure that is then passed to Layers etc using SetWts method.
func (*NetworkStru) ReadWtsJSON ¶
func (nt *NetworkStru) ReadWtsJSON(r io.Reader) error
ReadWtsJSON reads network weights from the receiver-side perspective in a JSON text format. Reads entire file into a temporary weights.Weights structure that is then passed to Layers etc using SetWts method.
func (*NetworkStru) SaveWtsJSON ¶
func (nt *NetworkStru) SaveWtsJSON(filename gi.FileName) error
SaveWtsJSON saves network weights (and any other state that adapts with learning) to a JSON-formatted file. If filename has .gz extension, then file is gzip compressed.
func (*NetworkStru) SetWts ¶
func (nt *NetworkStru) SetWts(nw *weights.Network) error
SetWts sets the weights for this network from weights.Network decoded values
func (*NetworkStru) StartThreads ¶
func (nt *NetworkStru) StartThreads()
StartThreads starts up the computation threads, which monitor the channels for work
func (*NetworkStru) StdVertLayout ¶
func (nt *NetworkStru) StdVertLayout()
StdVertLayout arranges layers in a standard vertical (z axis stack) layout, by setting the Rel settings
func (*NetworkStru) StopThreads ¶
func (nt *NetworkStru) StopThreads()
StopThreads stops the computation threads
func (*NetworkStru) ThrLayFun ¶
func (nt *NetworkStru) ThrLayFun(fun func(ly AxonLayer), funame string)
ThrLayFun calls function on layer, using threaded (go routine worker) computation if NThreads > 1 and otherwise just iterates over layers in the current thread.
func (*NetworkStru) ThrTimerReset ¶
func (nt *NetworkStru) ThrTimerReset()
ThrTimerReset resets the per-thread timers
func (*NetworkStru) ThrWorker ¶
func (nt *NetworkStru) ThrWorker(tt int)
ThrWorker is the worker function run by the worker threads
func (*NetworkStru) TimerReport ¶
func (nt *NetworkStru) TimerReport()
TimerReport reports the amount of time spent in each function, and in each thread
func (*NetworkStru) VarRange ¶
func (nt *NetworkStru) VarRange(varNm string) (min, max float32, err error)
VarRange returns the min / max values for given variable todo: support r. s. projection values
func (*NetworkStru) WriteWtsJSON ¶
func (nt *NetworkStru) WriteWtsJSON(w io.Writer) error
WriteWtsJSON writes the weights from this layer from the receiver-side perspective in a JSON text format. We build in the indentation logic to make it much faster and more efficient.
type NeurFlags ¶
type NeurFlags int32
NeurFlags are bit-flags encoding relevant binary state for neurons
const ( // NeurOff flag indicates that this neuron has been turned off (i.e., lesioned) NeurOff NeurFlags = iota // NeurHasExt means the neuron has external input in its Ext field NeurHasExt // NeurHasTarg means the neuron has external target input in its Targ field NeurHasTarg // NeurHasCmpr means the neuron has external comparison input in its Targ field -- used for computing // comparison statistics but does not drive neural activity ever NeurHasCmpr NeurFlagsN )
The neuron flags
func (*NeurFlags) FromString ¶
func (NeurFlags) MarshalJSON ¶
func (*NeurFlags) UnmarshalJSON ¶
type Neuron ¶
type Neuron struct { Flags NeurFlags `desc:"bit flags for binary state variables"` SubPool int32 `` /* 214-byte string literal not displayed */ Spike float32 `desc:"whether neuron has spiked or not on this cycle (0 or 1)"` ISI float32 `desc:"current inter-spike-interval -- counts up since last spike. Starts at -1 when initialized."` ISIAvg float32 `` /* 204-byte string literal not displayed */ Act float32 `` /* 477-byte string literal not displayed */ ActLrn float32 `` /* 436-byte string literal not displayed */ Ge float32 `desc:"total excitatory synaptic conductance -- the net excitatory input to the neuron -- does *not* include Gbar.E"` Gi float32 `desc:"total inhibitory synaptic conductance -- the net inhibitory input to the neuron -- does *not* include Gbar.I"` Gk float32 `` /* 148-byte string literal not displayed */ Inet float32 `desc:"net current produced by all channels -- drives update of Vm"` Vm float32 `desc:"membrane potential -- integrates Inet current over time"` VmDend float32 `desc:"dendritic membrane potential -- subject to multiplier"` Targ float32 `desc:"target value: drives learning to produce this activation value"` Ext float32 `desc:"external input: drives activation of unit from outside influences (e.g., sensory input)"` AvgSS float32 `` /* 254-byte string literal not displayed */ AvgS float32 `` /* 190-byte string literal not displayed */ AvgM float32 `` /* 148-byte string literal not displayed */ AvgSLrn float32 `` /* 414-byte string literal not displayed */ ActQ0 float32 `desc:"the activation state at start of current alpha cycle (same as the state at end of previous cycle)"` ActQ1 float32 `desc:"the activation state at end of first quarter of current alpha cycle"` ActQ2 float32 `desc:"the activation state at end of second quarter of current alpha cycle"` ActM float32 `desc:"the activation state at end of third quarter, which is the traditional posterior-cortical minus phase activation"` ActP float32 `desc:"the activation state at end of fourth quarter, which is the traditional posterior-cortical plus_phase activation"` ActDif float32 `` /* 164-byte string literal not displayed */ ActDel float32 `desc:"delta activation: change in Act from one cycle to next -- can be useful to track where changes are taking place"` ActAvg float32 `` /* 213-byte string literal not displayed */ AvgPct float32 `` /* 163-byte string literal not displayed */ TrgAvg float32 `` /* 169-byte string literal not displayed */ AvgDif float32 `` /* 178-byte string literal not displayed */ Noise float32 `desc:"noise value added to unit (ActNoiseParams determines distribution, and when / where it is added)"` GiSyn float32 `` /* 168-byte string literal not displayed */ GiSelf float32 `desc:"total amount of self-inhibition -- time-integrated to avoid oscillations"` GeRaw float32 `desc:"raw excitatory conductance (net input) received from sending units (send delta's are added to this value)"` GiRaw float32 `desc:"raw inhibitory conductance (net input) received from sending units (send delta's are added to this value)"` GeM float32 `` /* 165-byte string literal not displayed */ GknaFast float32 `` /* 130-byte string literal not displayed */ GknaMed float32 `` /* 131-byte string literal not displayed */ GknaSlow float32 `` /* 129-byte string literal not displayed */ Gnmda float32 `desc:"net NMDA conductance, after Vm gating and Gbar -- added directly to Ge as it has the same reversal potential."` NMDA float32 `desc:"NMDA channel activation -- underlying time-integrated value with decay"` NMDASyn float32 `desc:"synaptic NMDA activation directly from projection(s)"` GgabaB float32 `desc:"net GABA-B conductance, after Vm gating and Gbar + Gbase -- set to Gk for GIRK, with .1 reversal potential."` GABAB float32 `desc:"GABA-B / GIRK activation -- time-integrated value with rise and decay time constants"` GABABx float32 `desc:"GABA-B / GIRK internal drive variable -- gets the raw activation and decays"` }
axon.Neuron holds all of the neuron (unit) level variables -- this is the most basic version with rate-code only and no optional features at all. All variables accessible via Unit interface must be float32 and start at the top, in contiguous order
func (*Neuron) VarByIndex ¶
VarByIndex returns variable using index (0 = first variable in NeuronVars list)
type Pool ¶
type Pool struct {
StIdx, EdIdx int `desc:"starting and ending (exlusive) indexes for the list of neurons in this pool"`
Inhib fffb.Inhib `desc:"FFFB inhibition computed values, including Ge and Act AvgMax which drive inhibition"`
ActM minmax.AvgMax32 `desc:"minus phase average and max Act activation values, for ActAvg updt"`
ActP minmax.AvgMax32 `desc:"plus phase average and max Act activation values, for ActAvg updt"`
GeM minmax.AvgMax32 `desc:"stats for GeM minus phase averaged Ge values"`
AvgDif minmax.AvgMax32 `desc:"absolute value of AvgDif differences from actual neuron ActPct relative to TrgAvg"`
ActAvg ActAvg `desc:"running-average activation levels used for netinput scaling and adaptive inhibition"`
}
Pool contains computed values for FFFB inhibition, and various other state values for layers and pools (unit groups) that can be subject to inhibition, including: * average / max stats on Ge and Act that drive inhibition * average activity overall that is used for normalizing netin (at layer level)
type Prjn ¶
type Prjn struct { PrjnStru Com SynComParams `view:"inline" desc:"synaptic communication parameters: delay, probability of failure"` WtInit WtInitParams `view:"inline" desc:"initial random weight distribution"` WtScale WtScaleParams `` /* 130-byte string literal not displayed */ Learn LearnSynParams `view:"add-fields" desc:"synaptic-level learning parameters"` Syns []Synapse `desc:"synaptic state values, ordered by the sending layer units which owns them -- one-to-one with SConIdx array"` // misc state variables below: GScale float32 `` /* 158-byte string literal not displayed */ Gidx ringidx.FIx `` /* 201-byte string literal not displayed */ Gbuf []float32 `` /* 173-byte string literal not displayed */ }
axon.Prjn is a basic Axon projection with synaptic learning parameters
func (*Prjn) AsAxon ¶
AsAxon returns this prjn as a axon.Prjn -- all derived prjns must redefine this to return the base Prjn type, so that the AxonPrjn interface does not need to include accessors to all the basic stuff.
func (*Prjn) Build ¶
Build constructs the full connectivity among the layers as specified in this projection. Calls PrjnStru.BuildStru and then allocates the synaptic values in Syns accordingly.
func (*Prjn) DWt ¶
func (pj *Prjn) DWt()
DWt computes the weight change (learning) -- on sending projections
func (*Prjn) DWtSubMean ¶ added in v1.2.23
func (pj *Prjn) DWtSubMean()
DWtSubMean subtracts a portion of the mean recv DWt per projection
func (*Prjn) InitWtSym ¶
InitWtSym initializes weight symmetry -- is given the reciprocal projection where the Send and Recv layers are reversed.
func (*Prjn) InitWts ¶
func (pj *Prjn) InitWts()
InitWts initializes weight values according to Learn.WtInit params
func (*Prjn) InitWtsSyn ¶
InitWtsSyn initializes weight values based on WtInit randomness parameters for an individual synapse. It also updates the linear weight value based on the sigmoidal weight value.
func (*Prjn) LrateMult ¶
LrateMult sets the new Lrate parameter for Prjns to LrateInit * mult. Useful for implementing learning rate schedules.
func (*Prjn) ReadWtsJSON ¶
ReadWtsJSON reads the weights from this projection from the receiver-side perspective in a JSON text format. This is for a set of weights that were saved *for one prjn only* and is not used for the network-level ReadWtsJSON, which reads into a separate structure -- see SetWts method.
func (*Prjn) RecvGInc ¶
func (pj *Prjn) RecvGInc()
RecvGInc increments the receiver's GeRaw or GiRaw from that of all the projections.
func (*Prjn) SendSpike ¶
SendSpike sends a spike from sending neuron index si, to add to buffer on receivers.
func (*Prjn) SetScalesFunc ¶
SetScalesFunc initializes synaptic Scale values using given function based on receiving and sending unit indexes.
func (*Prjn) SetScalesRPool ¶
SetScalesRPool initializes synaptic Scale values using given tensor of values which has unique values for each recv neuron within a given pool.
func (*Prjn) SetSynVal ¶
SetSynVal sets value of given variable name on the synapse between given send, recv unit indexes (1D, flat indexes) returns error for access errors.
func (*Prjn) SetWtsFunc ¶
SetWtsFunc initializes synaptic Wt value using given function based on receiving and sending unit indexes.
func (*Prjn) SynIdx ¶
SynIdx returns the index of the synapse between given send, recv unit indexes (1D, flat indexes). Returns -1 if synapse not found between these two neurons. Requires searching within connections for receiving unit.
func (*Prjn) SynScale ¶ added in v1.2.23
func (pj *Prjn) SynScale()
SynScale performs synaptic scaling based on running average activation vs. targets
func (*Prjn) SynVal ¶
SynVal returns value of given variable name on the synapse between given send, recv unit indexes (1D, flat indexes). Returns mat32.NaN() for access errors (see SynValTry for error message)
func (*Prjn) SynVal1D ¶
SynVal1D returns value of given variable index (from SynVarIdx) on given SynIdx. Returns NaN on invalid index. This is the core synapse var access method used by other methods, so it is the only one that needs to be updated for derived layer types.
func (*Prjn) SynVals ¶
SynVals sets values of given variable name for each synapse, using the natural ordering of the synapses (sender based for Axon), into given float32 slice (only resized if not big enough). Returns error on invalid var name.
func (*Prjn) SynVarIdx ¶
SynVarIdx returns the index of given variable within the synapse, according to *this prjn's* SynVarNames() list (using a map to lookup index), or -1 and error message if not found.
func (*Prjn) SynVarNames ¶
func (*Prjn) SynVarNum ¶
SynVarNum returns the number of synapse-level variables for this prjn. This is needed for extending indexes in derived types.
func (*Prjn) SynVarProps ¶
SynVarProps returns properties for variables
func (*Prjn) UpdateParams ¶
func (pj *Prjn) UpdateParams()
UpdateParams updates all params given any changes that might have been made to individual values
func (*Prjn) WriteWtsJSON ¶
WriteWtsJSON writes the weights from this projection from the receiver-side perspective in a JSON text format. We build in the indentation logic to make it much faster and more efficient.
type PrjnStru ¶
type PrjnStru struct { AxonPrj AxonPrjn `` /* 267-byte string literal not displayed */ Off bool `desc:"inactivate this projection -- allows for easy experimentation"` Cls string `desc:"Class is for applying parameter styles, can be space separated multple tags"` Notes string `desc:"can record notes about this projection here"` Send emer.Layer `desc:"sending layer for this projection"` Recv emer.Layer `` /* 167-byte string literal not displayed */ Pat prjn.Pattern `desc:"pattern of connectivity"` Typ emer.PrjnType `` /* 154-byte string literal not displayed */ RConN []int32 `view:"-" desc:"number of recv connections for each neuron in the receiving layer, as a flat list"` RConNAvgMax minmax.AvgMax32 `inactive:"+" desc:"average and maximum number of recv connections in the receiving layer"` RConIdxSt []int32 `view:"-" desc:"starting index into ConIdx list for each neuron in receiving layer -- just a list incremented by ConN"` RConIdx []int32 `` /* 213-byte string literal not displayed */ RSynIdx []int32 `` /* 185-byte string literal not displayed */ SConN []int32 `view:"-" desc:"number of sending connections for each neuron in the sending layer, as a flat list"` SConNAvgMax minmax.AvgMax32 `inactive:"+" desc:"average and maximum number of sending connections in the sending layer"` SConIdxSt []int32 `view:"-" desc:"starting index into ConIdx list for each neuron in sending layer -- just a list incremented by ConN"` SConIdx []int32 `` /* 213-byte string literal not displayed */ }
PrjnStru contains the basic structural information for specifying a projection of synaptic connections between two layers, and maintaining all the synaptic connection-level data. The exact same struct object is added to the Recv and Send layers, and it manages everything about the connectivity, and methods on the Prjn handle all the relevant computation.
func (*PrjnStru) ApplyParams ¶
ApplyParams applies given parameter style Sheet to this projection. Calls UpdateParams if anything set to ensure derived parameters are all updated. If setMsg is true, then a message is printed to confirm each parameter that is set. it always prints a message if a parameter fails to be set. returns true if any params were set, and error if there were any errors.
func (*PrjnStru) BuildStru ¶
BuildStru constructs the full connectivity among the layers as specified in this projection. Calls Validate and returns false if invalid. Pat.Connect is called to get the pattern of the connection. Then the connection indexes are configured according to that pattern.
func (*PrjnStru) Connect ¶
Connect sets the connectivity between two layers and the pattern to use in interconnecting them
func (*PrjnStru) Init ¶
Init MUST be called to initialize the prjn's pointer to itself as an emer.Prjn which enables the proper interface methods to be called.
func (*PrjnStru) NonDefaultParams ¶
NonDefaultParams returns a listing of all parameters in the Layer that are not at their default values -- useful for setting param styles etc.
func (*PrjnStru) PrjnTypeName ¶
func (*PrjnStru) SetNIdxSt ¶
func (ps *PrjnStru) SetNIdxSt(n *[]int32, avgmax *minmax.AvgMax32, idxst *[]int32, tn *etensor.Int32) int32
SetNIdxSt sets the *ConN and *ConIdxSt values given n tensor from Pat. Returns total number of connections for this direction.
type PrjnType ¶
PrjnType has the GLong extensions to the emer.PrjnType types, for gui
func StringToPrjnType ¶
type Quarters ¶
type Quarters int32
Quarters are the different alpha trial quarters, as a bitflag, for use in relevant timing parameters where quarters need to be specified. The Q1..4 defined values are integer *bit positions* -- use Set, Has etc methods to set bits from these bit positions.
const ( // Q1 is the first quarter, which, due to 0-based indexing, shows up as Quarter = 0 in timer Q1 Quarters = iota Q2 Q3 Q4 QuartersN )
The quarters
func (*Quarters) FromString ¶
func (Quarters) HasNext ¶
HasNext returns true if the quarter after given quarter is set. This wraps around from Q4 to Q1. (qtr = 0..3 = same as Quarters)
func (Quarters) HasPrev ¶
HasPrev returns true if the quarter before given quarter is set. This wraps around from Q1 to Q4. (qtr = 0..3 = same as Quarters)
func (Quarters) MarshalJSON ¶
func (*Quarters) Set ¶
Set sets given quarter bit (adds to any existing) (qtr = 0..3 = same as Quarters)
func (*Quarters) UnmarshalJSON ¶
type SelfInhibParams ¶
type SelfInhibParams struct { On bool `desc:"enable neuron self-inhibition"` Gi float32 `` /* 247-byte string literal not displayed */ Tau float32 `` /* 373-byte string literal not displayed */ Dt float32 `inactive:"+" view:"-" json:"-" xml:"-" desc:"rate = 1 / tau"` }
SelfInhibParams defines parameters for Neuron self-inhibition -- activation of the neuron directly feeds back to produce a proportional additional contribution to Gi
func (*SelfInhibParams) Defaults ¶
func (si *SelfInhibParams) Defaults()
func (*SelfInhibParams) Inhib ¶
func (si *SelfInhibParams) Inhib(self *float32, act float32)
Inhib updates the self inhibition value based on current unit activation
func (*SelfInhibParams) Update ¶
func (si *SelfInhibParams) Update()
type SpikeParams ¶
type SpikeParams struct { Thr float32 `` /* 152-byte string literal not displayed */ VmR float32 `` /* 201-byte string literal not displayed */ Tr int `` /* 127-byte string literal not displayed */ Exp bool `` /* 274-byte string literal not displayed */ ExpSlope float32 `` /* 325-byte string literal not displayed */ ExpThr float32 `viewif:"Exp" def:"1" desc:"membrane potential threshold for actually triggering a spike when using the exponential mechanism"` MaxHz float32 `` /* 265-byte string literal not displayed */ RateTau float32 `def:"5" min:"1" desc:"constant for integrating the spiking interval in estimating spiking rate"` RateDt float32 `view:"-" desc:"rate = 1 / tau"` }
SpikeParams contains spiking activation function params. Implements a basic thresholded Vm model, and optionally the AdEx adaptive exponential function (adapt is KNaAdapt)
func (*SpikeParams) ActFmISI ¶
func (sk *SpikeParams) ActFmISI(isi, timeInc, integ float32) float32
ActFmISI computes rate-code activation from estimated spiking interval
func (*SpikeParams) ActToISI ¶
func (sk *SpikeParams) ActToISI(act, timeInc, integ float32) float32
ActToISI compute spiking interval from a given rate-coded activation, based on time increment (.001 = 1msec default), Act.Dt.Integ
func (*SpikeParams) AvgFmISI ¶
func (sk *SpikeParams) AvgFmISI(avg *float32, isi float32)
AvgFmISI updates spiking ISI from current isi interval value
func (*SpikeParams) Defaults ¶
func (sk *SpikeParams) Defaults()
func (*SpikeParams) Update ¶
func (sk *SpikeParams) Update()
type SynComParams ¶
type SynComParams struct { Delay int `desc:"synaptic delay for inputs arriving at this projection -- IMPORTANT: if you change this, you must rebuild network!"` PFail float32 `` /* 146-byte string literal not displayed */ PFailWtMax float32 `` /* 273-byte string literal not displayed */ }
/ SynComParams are synaptic communication parameters: delay and probability of failure
func (*SynComParams) Defaults ¶
func (sc *SynComParams) Defaults()
func (*SynComParams) Fail ¶
func (sc *SynComParams) Fail(wt *float32)
Fail updates failure status of given weight
func (*SynComParams) Update ¶
func (sc *SynComParams) Update()
func (*SynComParams) WtFail ¶
func (sc *SynComParams) WtFail(wt float32) bool
WtFail returns true if synapse should fail
func (*SynComParams) WtFailP ¶
func (sc *SynComParams) WtFailP(wt float32) float32
WtFailP returns probability of weight (synapse) failure given current weight value
type SynScaleParams ¶ added in v1.2.23
type SynScaleParams struct { ErrLrate float32 `def:"0.05" desc:"learning rate for adjustments to Trg value based on unit-level error signal"` TrgRange minmax.F32 `` /* 176-byte string literal not displayed */ Permute bool `` /* 224-byte string literal not displayed */ AvgTau float32 `` /* 180-byte string literal not displayed */ Rate float32 `` /* 179-byte string literal not displayed */ AvgDt float32 `view:"-" json:"-" xml:"-" desc:"rate = 1 / tau"` }
SynScaleParams govern the synaptic scaling to maintain target level of overall long-term average activity in neurons. Weights are rescaled in proportion to avg diff -- larger weights affected in proportion.
func (*SynScaleParams) Defaults ¶ added in v1.2.23
func (ss *SynScaleParams) Defaults()
func (*SynScaleParams) Update ¶ added in v1.2.23
func (ss *SynScaleParams) Update()
type Synapse ¶
type Synapse struct { Wt float32 `desc:"synaptic weight value -- sigmoid contrast-enhanced"` LWt float32 `` /* 216-byte string literal not displayed */ DWt float32 `desc:"change in synaptic weight, from learning"` Scale float32 `` /* 445-byte string literal not displayed */ }
axon.Synapse holds state for the synaptic connection between neurons
func (*Synapse) SetVarByIndex ¶
func (*Synapse) SetVarByName ¶
SetVarByName sets synapse variable to given value
func (*Synapse) VarByIndex ¶
VarByIndex returns variable using index (0 = first variable in SynapseVars list)
type Time ¶
type Time struct { Time float32 `desc:"accumulated amount of time the network has been running, in simulation-time (not real world time), in seconds"` Cycle int `` /* 217-byte string literal not displayed */ CycleTot int `` /* 151-byte string literal not displayed */ Quarter int `` /* 224-byte string literal not displayed */ PlusPhase bool `desc:"true if this is the plus phase (final quarter = 3) -- else minus phase"` TimePerCyc float32 `def:"0.001" desc:"amount of time to increment per cycle"` CycPerQtr int `def:"25" desc:"number of cycles per quarter to run -- 25 = standard 100 msec alpha-cycle"` }
axon.Time contains all the timing state and parameter information for running a model
func (*Time) AlphaCycStart ¶
func (tm *Time) AlphaCycStart()
AlphaCycStart starts a new alpha-cycle (set of 4 quarters)
func (*Time) QuarterCycle ¶
QuarterCycle returns the number of cycles into current quarter
func (*Time) QuarterInc ¶
func (tm *Time) QuarterInc()
QuarterInc increments at the quarter level, updating Quarter and PlusPhase
type TimeScales ¶
type TimeScales int32
TimeScales are the different time scales associated with overall simulation running, and can be used to parameterize the updating and control flow of simulations at different scales. The definitions become increasingly subjective imprecise as the time scales increase. This is not used directly in the algorithm code -- all control is responsibility of the end simulation. This list is designed to standardize terminology across simulations and establish a common conceptual framework for time -- it can easily be extended in specific simulations to add needed additional levels, although using one of the existing standard values is recommended wherever possible.
const ( // Cycle is the finest time scale -- typically 1 msec -- a single activation update. Cycle TimeScales = iota // FastSpike is typically 10 cycles = 10 msec (100hz) = the fastest spiking time // generally observed in the brain. This can be useful for visualizing updates // at a granularity in between Cycle and Quarter. FastSpike // Quarter is typically 25 cycles = 25 msec (40hz) = 1/4 of the 100 msec alpha trial // This is also the GammaCycle (gamma = 40hz), but we use Quarter functionally // by virtue of there being 4 per AlphaCycle. Quarter // Phase is either Minus or Plus phase -- Minus = first 3 quarters, Plus = last quarter Phase // BetaCycle is typically 50 cycles = 50 msec (20 hz) = one beta-frequency cycle. // Gating in the basal ganglia and associated updating in prefrontal cortex // occurs at this frequency. BetaCycle // AlphaCycle is typically 100 cycles = 100 msec (10 hz) = one alpha-frequency cycle, // which is the fundamental unit of learning in posterior cortex. AlphaCycle // ThetaCycle is typically 200 cycles = 200 msec (5 hz) = two alpha-frequency cycles. // This is the modal duration of a saccade, the update frequency of medial temporal lobe // episodic memory, and the minimal predictive learning cycle (perceive an Alpha 1, predict on 2). ThetaCycle // Event is the smallest unit of naturalistic experience that coheres unto itself // (e.g., something that could be described in a sentence). // Typically this is on the time scale of a few seconds: e.g., reaching for // something, catching a ball. Event // Trial is one unit of behavior in an experiment -- it is typically environmentally // defined instead of endogenously defined in terms of basic brain rhythms. // In the minimal case it could be one AlphaCycle, but could be multiple, and // could encompass multiple Events (e.g., one event is fixation, next is stimulus, // last is response) Trial // Tick is one step in a sequence -- often it is useful to have Trial count // up throughout the entire Epoch but also include a Tick to count trials // within a Sequence Tick // Sequence is a sequential group of Trials (not always needed). Sequence // Condition is a collection of Blocks that share the same set of parameters. // This is intermediate between Block and Run levels. Condition // Block is a collection of Trials, Sequences or Events, often used in experiments // when conditions are varied across blocks. Block // Epoch is used in two different contexts. In machine learning, it represents a // collection of Trials, Sequences or Events that constitute a "representative sample" // of the environment. In the simplest case, it is the entire collection of Trials // used for training. In electrophysiology, it is a timing window used for organizing // the analysis of electrode data. Epoch // Run is a complete run of a model / subject, from training to testing, etc. // Often multiple runs are done in an Expt to obtain statistics over initial // random weights etc. Run // Expt is an entire experiment -- multiple Runs through a given protocol / set of // parameters. Expt // Scene is a sequence of events that constitutes the next larger-scale coherent unit // of naturalistic experience corresponding e.g., to a scene in a movie. // Typically consists of events that all take place in one location over // e.g., a minute or so. This could be a paragraph or a page or so in a book. Scene // Episode is a sequence of scenes that constitutes the next larger-scale unit // of naturalistic experience e.g., going to the grocery store or eating at a // restaurant, attending a wedding or other "event". // This could be a chapter in a book. Episode TimeScalesN )
The time scales
func (*TimeScales) FromString ¶
func (i *TimeScales) FromString(s string) error
func (TimeScales) MarshalJSON ¶
func (ev TimeScales) MarshalJSON() ([]byte, error)
func (TimeScales) String ¶
func (i TimeScales) String() string
func (*TimeScales) UnmarshalJSON ¶
func (ev *TimeScales) UnmarshalJSON(b []byte) error
type WtInitParams ¶
type WtInitParams struct { erand.RndParams Sym bool `` /* 130-byte string literal not displayed */ }
WtInitParams are weight initialization parameters -- basically the random distribution parameters but also Symmetry flag
func (*WtInitParams) Defaults ¶
func (wp *WtInitParams) Defaults()
type WtScaleParams ¶
type WtScaleParams struct { Abs float32 `def:"1" min:"0" desc:"absolute scaling, which is not subject to normalization: directly multiplies weight values"` Rel float32 `` /* 169-byte string literal not displayed */ }
/ WtScaleParams are weight scaling parameters: modulates overall strength of projection, using both absolute and relative factors
func (*WtScaleParams) Defaults ¶
func (ws *WtScaleParams) Defaults()
func (*WtScaleParams) FullScale ¶
func (ws *WtScaleParams) FullScale(savg, snu, ncon float32) float32
FullScale returns full scaling factor, which is product of Abs * Rel * SLayActScale
func (*WtScaleParams) SLayActScale ¶
func (ws *WtScaleParams) SLayActScale(savg, snu, ncon float32) float32
SLayActScale computes scaling factor based on sending layer activity level (savg), number of units in sending layer (snu), and number of recv connections (ncon). Uses a fixed sem_extra standard-error-of-the-mean (SEM) extra value of 2 to add to the average expected number of active connections to receive, for purposes of computing scaling factors with partial connectivity For 25% layer activity, binomial SEM = sqrt(p(1-p)) = .43, so 3x = 1.3 so 2 is a reasonable default.
func (*WtScaleParams) Update ¶
func (ws *WtScaleParams) Update()
type WtSigParams ¶
type WtSigParams struct { Gain float32 `def:"1,6" min:"0" desc:"gain (contrast, sharpness) of the weight contrast function (1 = linear)"` Off float32 `def:"1" min:"0" desc:"offset of the function (1=centered at .5, >1=higher, <1=lower) -- 1 is standard for XCAL"` }
WtSigParams are sigmoidal weight contrast enhancement function parameters
func (*WtSigParams) Defaults ¶
func (ws *WtSigParams) Defaults()
func (*WtSigParams) LinFmSigWt ¶
func (ws *WtSigParams) LinFmSigWt(sw float32) float32
LinFmSigWt returns linear weight from sigmoidal contrast-enhanced weight
func (*WtSigParams) SigFmLinWt ¶
func (ws *WtSigParams) SigFmLinWt(lw float32) float32
SigFmLinWt returns sigmoidal contrast-enhanced weight from linear weight
func (*WtSigParams) Update ¶
func (ws *WtSigParams) Update()
type XCalParams ¶
type XCalParams struct { SubMean float32 `def:"0.8" desc:"amount of the mean dWt to subtract -- 1.0 = full zero-sum dWt"` DRev float32 `` /* 270-byte string literal not displayed */ DThr float32 `` /* 139-byte string literal not displayed */ LrnThr float32 `` /* 338-byte string literal not displayed */ DRevRatio float32 `` /* 131-byte string literal not displayed */ }
XCalParams are parameters for temporally eXtended Contrastive Attractor Learning function (XCAL) which is the standard learning equation for axon .
func (*XCalParams) DWt ¶
func (xc *XCalParams) DWt(srval, thrP float32) float32
DWt is the XCAL function for weight change -- the "check mark" function -- no DGain, no ThrPMin
func (*XCalParams) Defaults ¶
func (xc *XCalParams) Defaults()
func (*XCalParams) Update ¶
func (xc *XCalParams) Update()