Skip to content

Commit

Permalink
update to v2
Browse files Browse the repository at this point in the history
  • Loading branch information
rcoreilly committed Dec 9, 2023
1 parent b6620fe commit 6659f5d
Show file tree
Hide file tree
Showing 111 changed files with 2,532 additions and 2,603 deletions.
336 changes: 168 additions & 168 deletions axon/act.go

Large diffs are not rendered by default.

28 changes: 14 additions & 14 deletions axon/act_prjn.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ package axon
import (
"log"

"github.com/emer/emergent/erand"
"github.com/emer/emergent/v2/erand"
"github.com/goki/gosl/slbool"
"github.com/goki/ki/ints"
"github.com/goki/ki/kit"
"github.com/goki/mat32"
"goki.dev/mat32/v2"
)

//go:generate stringer -type=PrjnGTypes
Expand Down Expand Up @@ -63,22 +63,22 @@ const (
type SynComParams struct {

// type of conductance (G) communicated by this projection
GType PrjnGTypes `desc:"type of conductance (G) communicated by this projection"`
GType PrjnGTypes

// [def: 2] [min: 0] additional synaptic delay in msec for inputs arriving at this projection. Must be <= MaxDelay which is set during network building based on MaxDelay of any existing Prjn in the network. Delay = 0 means a spike reaches receivers in the next Cycle, which is the minimum time (1 msec). Biologically, subtract 1 from biological synaptic delay values to set corresponding Delay value.
Delay uint32 `min:"0" def:"2" desc:"additional synaptic delay in msec for inputs arriving at this projection. Must be <= MaxDelay which is set during network building based on MaxDelay of any existing Prjn in the network. Delay = 0 means a spike reaches receivers in the next Cycle, which is the minimum time (1 msec). Biologically, subtract 1 from biological synaptic delay values to set corresponding Delay value."`
// additional synaptic delay in msec for inputs arriving at this projection. Must be <= MaxDelay which is set during network building based on MaxDelay of any existing Prjn in the network. Delay = 0 means a spike reaches receivers in the next Cycle, which is the minimum time (1 msec). Biologically, subtract 1 from biological synaptic delay values to set corresponding Delay value.
Delay uint32 `min:"0" def:"2"`

// maximum value of Delay -- based on MaxDelay values when the BuildGBuf function was called when the network was built -- cannot set it longer than this, except by calling BuildGBuf on network after changing MaxDelay to a larger value in any projection in the network.
MaxDelay uint32 `inactive:"+" desc:"maximum value of Delay -- based on MaxDelay values when the BuildGBuf function was called when the network was built -- cannot set it longer than this, except by calling BuildGBuf on network after changing MaxDelay to a larger value in any projection in the network."`
MaxDelay uint32 `inactive:"+"`

// probability of synaptic transmission failure -- if > 0, then weights are turned off at random as a function of PFail (times 1-SWt if PFailSwt)
PFail float32 `desc:"probability of synaptic transmission failure -- if > 0, then weights are turned off at random as a function of PFail (times 1-SWt if PFailSwt)"`
PFail float32

// if true, then probability of failure is inversely proportional to SWt structural / slow weight value (i.e., multiply PFail * (1-SWt)))
PFailSWt slbool.Bool `desc:"if true, then probability of failure is inversely proportional to SWt structural / slow weight value (i.e., multiply PFail * (1-SWt)))"`
PFailSWt slbool.Bool

// [view: -] delay length = actual length of the GBuf buffer per neuron = Delay+1 -- just for speed
DelLen uint32 `view:"-" desc:"delay length = actual length of the GBuf buffer per neuron = Delay+1 -- just for speed"`
// delay length = actual length of the GBuf buffer per neuron = Delay+1 -- just for speed
DelLen uint32 `view:"-"`

pad, pad1 float32
}
Expand Down Expand Up @@ -222,11 +222,11 @@ func (sc *SynComParams) Fail(ctx *Context, syni uint32, swt float32) {
// using both absolute and relative factors.
type PrjnScaleParams struct {

// [min: 0] [Defaults: Forward=1, Back=0.2] relative scaling that shifts balance between different projections -- this is subject to normalization across all other projections into receiving neuron, and determines the GScale.Target for adapting scaling
Rel float32 `min:"0" desc:"[Defaults: Forward=1, Back=0.2] relative scaling that shifts balance between different projections -- this is subject to normalization across all other projections into receiving neuron, and determines the GScale.Target for adapting scaling"`
// relative scaling that shifts balance between different projections -- this is subject to normalization across all other projections into receiving neuron, and determines the GScale.Target for adapting scaling
Rel float32 `min:"0"`

// [def: 1] [min: 0] absolute multiplier adjustment factor for the prjn scaling -- can be used to adjust for idiosyncrasies not accommodated by the standard scaling based on initial target activation level and relative scaling factors -- any adaptation operates by directly adjusting scaling factor from the initially computed value
Abs float32 `def:"1" min:"0" desc:"absolute multiplier adjustment factor for the prjn scaling -- can be used to adjust for idiosyncrasies not accommodated by the standard scaling based on initial target activation level and relative scaling factors -- any adaptation operates by directly adjusting scaling factor from the initially computed value"`
// absolute multiplier adjustment factor for the prjn scaling -- can be used to adjust for idiosyncrasies not accommodated by the standard scaling based on initial target activation level and relative scaling factors -- any adaptation operates by directly adjusting scaling factor from the initially computed value
Abs float32 `def:"1" min:"0"`

pad, pad1 float32
}
Expand Down
2 changes: 1 addition & 1 deletion axon/act_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ package axon
import (
"testing"

"github.com/goki/mat32"
"goki.dev/mat32/v2"
)

// TOLERANCE is the numerical difference tolerance for comparing vs. target values
Expand Down
2 changes: 1 addition & 1 deletion axon/axon.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
package axon

import (
"github.com/emer/emergent/emer"
"github.com/emer/emergent/v2/emer"
)

// AxonNetwork defines the essential algorithmic API for Axon, at the network level.
Expand Down
12 changes: 6 additions & 6 deletions axon/basic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ import (
"strings"
"testing"

"github.com/emer/emergent/erand"
"github.com/emer/emergent/etime"
"github.com/emer/emergent/params"
"github.com/emer/emergent/prjn"
"github.com/emer/etable/etensor"
"github.com/emer/emergent/v2/erand"
"github.com/emer/emergent/v2/etime"
"github.com/emer/emergent/v2/params"
"github.com/emer/emergent/v2/prjn"
"github.com/goki/ki/kit"
"github.com/goki/mat32"
"goki.dev/etable/v2/etensor"
"goki.dev/mat32/v2"
"golang.org/x/exp/maps"
)

Expand Down
102 changes: 51 additions & 51 deletions axon/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ package axon
import (
"math"

"github.com/emer/emergent/etime"
"github.com/emer/emergent/v2/etime"
"github.com/goki/gosl/slbool"
"github.com/goki/gosl/slrand"
"github.com/goki/ki/bools"
"goki.dev/glop/num"
)

var (
Expand Down Expand Up @@ -244,50 +244,50 @@ func (ctx *Context) CopyNetStridesFrom(srcCtx *Context) {
// NetIdxs are indexes and sizes for processing network
type NetIdxs struct {

// [min: 1] number of data parallel items to process currently
NData uint32 `min:"1" desc:"number of data parallel items to process currently"`
// number of data parallel items to process currently
NData uint32 `min:"1"`

// network index in global Networks list of networks -- needed for GPU shader kernel compatible network variable access functions (e.g., NrnV, SynV etc) in CPU mode
NetIdx uint32 `inactive:"+" desc:"network index in global Networks list of networks -- needed for GPU shader kernel compatible network variable access functions (e.g., NrnV, SynV etc) in CPU mode"`
NetIdx uint32 `inactive:"+"`

// maximum amount of data parallel
MaxData uint32 `inactive:"+" desc:"maximum amount of data parallel"`
MaxData uint32 `inactive:"+"`

// number of layers in the network
NLayers uint32 `inactive:"+" desc:"number of layers in the network"`
NLayers uint32 `inactive:"+"`

// total number of neurons
NNeurons uint32 `inactive:"+" desc:"total number of neurons"`
NNeurons uint32 `inactive:"+"`

// total number of pools excluding * MaxData factor
NPools uint32 `inactive:"+" desc:"total number of pools excluding * MaxData factor"`
NPools uint32 `inactive:"+"`

// total number of synapses
NSyns uint32 `inactive:"+" desc:"total number of synapses"`
NSyns uint32 `inactive:"+"`

// maximum size in float32 (4 bytes) of a GPU buffer -- needed for GPU access
GPUMaxBuffFloats uint32 `inactive:"+" desc:"maximum size in float32 (4 bytes) of a GPU buffer -- needed for GPU access"`
GPUMaxBuffFloats uint32 `inactive:"+"`

// total number of SynCa banks of GPUMaxBufferBytes arrays in GPU
GPUSynCaBanks uint32 `inactive:"+" desc:"total number of SynCa banks of GPUMaxBufferBytes arrays in GPU"`
GPUSynCaBanks uint32 `inactive:"+"`

// total number of PVLV Drives / positive USs
PVLVNPosUSs uint32 `inactive:"+" desc:"total number of PVLV Drives / positive USs"`
PVLVNPosUSs uint32 `inactive:"+"`

// total number of PVLV Negative USs
PVLVNNegUSs uint32 `inactive:"+" desc:"total number of PVLV Negative USs"`
PVLVNNegUSs uint32 `inactive:"+"`

// offset into GlobalVars for USneg values
GvUSnegOff uint32 `inactive:"+" desc:"offset into GlobalVars for USneg values"`
GvUSnegOff uint32 `inactive:"+"`

// stride into GlobalVars for USneg values
GvUSnegStride uint32 `inactive:"+" desc:"stride into GlobalVars for USneg values"`
GvUSnegStride uint32 `inactive:"+"`

// offset into GlobalVars for USpos, Drive, VSPatch values values
GvUSposOff uint32 `inactive:"+" desc:"offset into GlobalVars for USpos, Drive, VSPatch values values"`
GvUSposOff uint32 `inactive:"+"`

// stride into GlobalVars for USpos, Drive, VSPatch values
GvUSposStride uint32 `inactive:"+" desc:"stride into GlobalVars for USpos, Drive, VSPatch values"`
GvUSposStride uint32 `inactive:"+"`

pad uint32
}
Expand Down Expand Up @@ -349,72 +349,72 @@ func (ctx *NetIdxs) SynIdxIsValid(si uint32) bool {
type Context struct {

// current evaluation mode, e.g., Train, Test, etc
Mode etime.Modes `desc:"current evaluation mode, e.g., Train, Test, etc"`
Mode etime.Modes

// if true, the model is being run in a testing mode, so no weight changes or other associated computations are needed. this flag should only affect learning-related behavior. Is automatically updated based on Mode != Train
Testing slbool.Bool `inactive:"+" desc:"if true, the model is being run in a testing mode, so no weight changes or other associated computations are needed. this flag should only affect learning-related behavior. Is automatically updated based on Mode != Train"`
Testing slbool.Bool `inactive:"+"`

// phase counter: typicaly 0-1 for minus-plus but can be more phases for other algorithms
Phase int32 `desc:"phase counter: typicaly 0-1 for minus-plus but can be more phases for other algorithms"`
Phase int32

// true if this is the plus phase, when the outcome / bursting is occurring, driving positive learning -- else minus phase
PlusPhase slbool.Bool `desc:"true if this is the plus phase, when the outcome / bursting is occurring, driving positive learning -- else minus phase"`
PlusPhase slbool.Bool

// cycle within current phase -- minus or plus
PhaseCycle int32 `desc:"cycle within current phase -- minus or plus"`
PhaseCycle int32

// cycle counter: number of iterations of activation updating (settling) on the current state -- this counts time sequentially until reset with NewState
Cycle int32 `desc:"cycle counter: number of iterations of activation updating (settling) on the current state -- this counts time sequentially until reset with NewState"`
Cycle int32

// [def: 200] length of the theta cycle in terms of 1 msec Cycles -- some network update steps depend on doing something at the end of the theta cycle (e.g., CTCtxtPrjn).
ThetaCycles int32 `def:"200" desc:"length of the theta cycle in terms of 1 msec Cycles -- some network update steps depend on doing something at the end of the theta cycle (e.g., CTCtxtPrjn)."`
// length of the theta cycle in terms of 1 msec Cycles -- some network update steps depend on doing something at the end of the theta cycle (e.g., CTCtxtPrjn).
ThetaCycles int32 `def:"200"`

// total cycle count -- increments continuously from whenever it was last reset -- typically this is number of milliseconds in simulation time -- is int32 and not uint32 b/c used with Synapse CaUpT which needs to have a -1 case for expired update time
CyclesTotal int32 `desc:"total cycle count -- increments continuously from whenever it was last reset -- typically this is number of milliseconds in simulation time -- is int32 and not uint32 b/c used with Synapse CaUpT which needs to have a -1 case for expired update time"`
CyclesTotal int32

// accumulated amount of time the network has been running, in simulation-time (not real world time), in seconds
Time float32 `desc:"accumulated amount of time the network has been running, in simulation-time (not real world time), in seconds"`
Time float32

// total trial count -- increments continuously in NewState call *only in Train mode* from whenever it was last reset -- can be used for synchronizing weight updates across nodes
TrialsTotal int32 `desc:"total trial count -- increments continuously in NewState call *only in Train mode* from whenever it was last reset -- can be used for synchronizing weight updates across nodes"`
TrialsTotal int32

// [def: 0.001] amount of time to increment per cycle
TimePerCycle float32 `def:"0.001" desc:"amount of time to increment per cycle"`
// amount of time to increment per cycle
TimePerCycle float32 `def:"0.001"`

// [def: 100] how frequently to perform slow adaptive processes such as synaptic scaling, inhibition adaptation, associated in the brain with sleep, in the SlowAdapt method. This should be long enough for meaningful changes to accumulate -- 100 is default but could easily be longer in larger models. Because SlowCtr is incremented by NData, high NData cases (e.g. 16) likely need to increase this value -- e.g., 400 seems to produce overall consistent results in various models.
SlowInterval int32 `def:"100" desc:"how frequently to perform slow adaptive processes such as synaptic scaling, inhibition adaptation, associated in the brain with sleep, in the SlowAdapt method. This should be long enough for meaningful changes to accumulate -- 100 is default but could easily be longer in larger models. Because SlowCtr is incremented by NData, high NData cases (e.g. 16) likely need to increase this value -- e.g., 400 seems to produce overall consistent results in various models."`
// how frequently to perform slow adaptive processes such as synaptic scaling, inhibition adaptation, associated in the brain with sleep, in the SlowAdapt method. This should be long enough for meaningful changes to accumulate -- 100 is default but could easily be longer in larger models. Because SlowCtr is incremented by NData, high NData cases (e.g. 16) likely need to increase this value -- e.g., 400 seems to produce overall consistent results in various models.
SlowInterval int32 `def:"100"`

// counter for how long it has been since last SlowAdapt step. Note that this is incremented by NData to maintain consistency across different values of this parameter.
SlowCtr int32 `inactive:"+" desc:"counter for how long it has been since last SlowAdapt step. Note that this is incremented by NData to maintain consistency across different values of this parameter."`
SlowCtr int32 `inactive:"+"`

// synaptic calcium counter, which drives the CaUpT synaptic value to optimize updating of this computationally expensive factor. It is incremented by 1 for each cycle, and reset at the SlowInterval, at which point the synaptic calcium values are all reset.
SynCaCtr float32 `inactive:"+" desc:"synaptic calcium counter, which drives the CaUpT synaptic value to optimize updating of this computationally expensive factor. It is incremented by 1 for each cycle, and reset at the SlowInterval, at which point the synaptic calcium values are all reset."`
SynCaCtr float32 `inactive:"+"`

pad, pad1 float32

// [view: inline] indexes and sizes of current network
NetIdxs NetIdxs `view:"inline" desc:"indexes and sizes of current network"`
// indexes and sizes of current network
NetIdxs NetIdxs `view:"inline"`

// [view: -] stride offsets for accessing neuron variables
NeuronVars NeuronVarStrides `view:"-" desc:"stride offsets for accessing neuron variables"`
// stride offsets for accessing neuron variables
NeuronVars NeuronVarStrides `view:"-"`

// [view: -] stride offsets for accessing neuron average variables
NeuronAvgVars NeuronAvgVarStrides `view:"-" desc:"stride offsets for accessing neuron average variables"`
// stride offsets for accessing neuron average variables
NeuronAvgVars NeuronAvgVarStrides `view:"-"`

// [view: -] stride offsets for accessing neuron indexes
NeuronIdxs NeuronIdxStrides `view:"-" desc:"stride offsets for accessing neuron indexes"`
// stride offsets for accessing neuron indexes
NeuronIdxs NeuronIdxStrides `view:"-"`

// [view: -] stride offsets for accessing synapse variables
SynapseVars SynapseVarStrides `view:"-" desc:"stride offsets for accessing synapse variables"`
// stride offsets for accessing synapse variables
SynapseVars SynapseVarStrides `view:"-"`

// [view: -] stride offsets for accessing synapse Ca variables
SynapseCaVars SynapseCaStrides `view:"-" desc:"stride offsets for accessing synapse Ca variables"`
// stride offsets for accessing synapse Ca variables
SynapseCaVars SynapseCaStrides `view:"-"`

// [view: -] stride offsets for accessing synapse indexes
SynapseIdxs SynapseIdxStrides `view:"-" desc:"stride offsets for accessing synapse indexes"`
// stride offsets for accessing synapse indexes
SynapseIdxs SynapseIdxStrides `view:"-"`

// random counter -- incremented by maximum number of possible random numbers generated per cycle, regardless of how many are actually used -- this is shared across all layers so must encompass all possible param settings.
RandCtr slrand.Counter `desc:"random counter -- incremented by maximum number of possible random numbers generated per cycle, regardless of how many are actually used -- this is shared across all layers so must encompass all possible param settings."`
RandCtr slrand.Counter
}

// Defaults sets default values
Expand Down Expand Up @@ -742,7 +742,7 @@ func GlobalsReset(ctx *Context) {
// GlobalSetRew is a convenience function for setting the external reward
// state in Globals variables
func GlobalSetRew(ctx *Context, di uint32, rew float32, hasRew bool) {
SetGlbV(ctx, di, GvHasRew, bools.ToFloat32(hasRew))
SetGlbV(ctx, di, GvHasRew, num.FromBool[float32](hasRew))
if hasRew {
SetGlbV(ctx, di, GvRew, rew)
} else {
Expand Down
Loading

0 comments on commit 6659f5d

Please sign in to comment.