Skip to content

Commit

Permalink
inexplicable failure to drive exterinal activation of Act in ApplyAct…
Browse files Browse the repository at this point in the history
…ion in boa. Start on fsa update.
  • Loading branch information
rcoreilly committed Jun 2, 2023
1 parent a08b193 commit ed3de63
Show file tree
Hide file tree
Showing 10 changed files with 120 additions and 102 deletions.
25 changes: 11 additions & 14 deletions axon/gpu.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ package axon

import (
"embed"
"log"
"unsafe"

"github.com/goki/gi/oswin"
Expand Down Expand Up @@ -55,27 +54,28 @@ var content embed.FS
[[vk::binding(3, 3)]] RWStructuredBuffer<float> GSyns; // [Layer][RecvPrjns][RecvNeurons][Data]
Set: 0 Params
Set: 0
Role: Storage
Var: 0: Layers Struct[4] (size: 1520) Vals: 1
Var: 1: Prjns Struct[5] (size: 352) Vals: 1
Set: 1 Idxs
Set: 1
Role: Storage
Var: 0: NeuronIxs Uint32[534] (size: 4) Vals: 1
Var: 1: SynapseIxs Uint32[38976] (size: 4) Vals: 1
Var: 2: SendCon Struct[242] (size: 16) Vals: 1
Var: 3: RecvPrjnIdxs Uint32[5] (size: 4) Vals: 1
Var: 4: RecvCon Struct[281] (size: 16) Vals: 1
Var: 5: RecvSynIdxs Uint32[12992] (size: 4) Vals: 1
Set: 2 Structs
Set: 2
Role: Storage
Var: 0: Ctx Struct (size: 880) Vals: 1
Var: 1: Neurons Float32[233536] (size: 4) Vals: 1
Var: 2: NeuronAvgs Float32[890] (size: 4) Vals: 1
Var: 0: Ctx Struct (size: 496) Vals: 1
Var: 1: Neurons Float32[227840] (size: 4) Vals: 1
Var: 2: NeuronAvgs Float32[1246] (size: 4) Vals: 1
Var: 3: Pools Struct[64] (size: 1040) Vals: 1
Var: 4: LayVals Struct[64] (size: 128) Vals: 1
Var: 5: Exts Float32[800] (size: 4) Vals: 1
Set: 3 Syns
Var: 4: LayVals Struct[64] (size: 80) Vals: 1
Var: 5: Globals Float32[976] (size: 4) Vals: 1
Var: 6: Exts Float32[800] (size: 4) Vals: 1
Set: 3
Role: Storage
Var: 0: Synapses Float32[64960] (size: 4) Vals: 1
Var: 1: SynapseCas Float32[1455104] (size: 4) Vals: 1
Expand Down Expand Up @@ -811,10 +811,7 @@ func (gp *GPU) RunApplyExtsCmd() vk.CommandBuffer {

neurDataN := int(gp.Net.NNeurons) * int(gp.Net.MaxData)

exr, err := gp.Sys.Mem.SyncRegionValIdx(gp.Structs.Set, "Exts", 0)
if err != nil {
log.Println(err)
}
exr := gp.SyncRegionStruct("Exts")
cxr := gp.SyncRegionStruct("Ctx")
glr := gp.SyncRegionStruct("Globals")
gp.StartRunCmd(cmd)
Expand Down
8 changes: 5 additions & 3 deletions axon/layer.go
Original file line number Diff line number Diff line change
Expand Up @@ -821,7 +821,8 @@ func (ly *Layer) LocalistErr4D(ctx *Context) (err []bool, minusIdx, plusIdx []in
// Lesion

// UnLesionNeurons unlesions (clears the Off flag) for all neurons in the layer
func (ly *Layer) UnLesionNeurons(ctx *Context) {
func (ly *Layer) UnLesionNeurons() {
ctx := &ly.Network.Ctx
nn := ly.NNeurons
for lni := uint32(0); lni < nn; lni++ {
ni := ly.NeurStIdx + lni
Expand All @@ -834,8 +835,9 @@ func (ly *Layer) UnLesionNeurons(ctx *Context) {
// 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 (ly *Layer) LesionNeurons(ctx *Context, prop float32) int {
ly.UnLesionNeurons(ctx)
func (ly *Layer) LesionNeurons(prop float32) int {
ctx := &ly.Network.Ctx
ly.UnLesionNeurons()
if prop > 1 {
log.Printf("LesionNeurons got a proportion > 1 -- must be 0-1 as *proportion* (not percent) of neurons to lesion: %v\n", prop)
return 0
Expand Down
2 changes: 1 addition & 1 deletion axon/layerparams.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ type LayerParams struct {
Matrix MatrixParams `viewif:"LayType=MatrixLayer" view:"inline" desc:"parameters for BG Striatum Matrix MSN layers, which are the main Go / NoGo gating units in BG."`
GP GPParams `viewif:"LayType=GPLayer" view:"inline" desc:"type of GP Layer."`

Idxs LayerIdxs `view:"-" desc:"recv and send projection array access info"`
Idxs LayerIdxs `desc:"recv and send projection array access info"`
}

func (ly *LayerParams) Update() {
Expand Down
2 changes: 1 addition & 1 deletion axon/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,7 @@ func (nt *Network) UnLesionNeurons(ctx *Context) {
// if ly.IsOff() { // keep all sync'd
// continue
// }
ly.UnLesionNeurons(ctx)
ly.UnLesionNeurons()
}
}

Expand Down
2 changes: 1 addition & 1 deletion axon/networkbase.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ type NetworkBase struct {
PrjnGSyns []float32 `view:"-" desc:"[Layers][RecvPrjns][RecvNeurons][MaxData] synaptic conductance integrated over time per projection per recv neurons -- spikes come in via PrjnBuf -- subslices are allocated to each projection"`
RecvPrjnIdxs []uint32 `view:"-" desc:"[Layers][RecvPrjns] indexes into Prjns (organized by SendPrjn) organized by recv projections -- needed for iterating through recv prjns efficiently on GPU."`
RecvSynIdxs []uint32 `view:"-" desc:"[Layers][RecvPrjns][RecvNeurons][Syns] indexes into Synapses for each recv neuron, organized into blocks according to PrjnRecvCon, for receiver-based access."`
Exts []float32 `view:"-" desc:"[In / Targ Layers][Neurons][Data] external input values for all Input / Target / Compare layers in the network -- the ApplyExt methods write to this per layer, and it is then actually applied in one consistent method."`
Exts []float32 `desc:"[In / Targ Layers][Neurons][Data] external input values for all Input / Target / Compare layers in the network -- the ApplyExt methods write to this per layer, and it is then actually applied in one consistent method."`

Ctx Context `view:"-" desc:"context used only for accessing neurons for display"`
Rand erand.SysRand `view:"-" desc:"random number generator for the network -- all random calls must use this -- set seed here for weight initialization values"`
Expand Down
2 changes: 1 addition & 1 deletion examples/boa/approach_env.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ type Approach struct {
Acts []string `inactive:"+" desc:"list of actions"`
ActMap map[string]int `inactive:"+" desc:"action map of action names to indexes"`
NActs int `view:"-" desc:"number of actual represented actions -- the last action on Acts list is None -- not rendered"`
States map[string]*etensor.Float32 `view:"-" desc:"named states -- e.g., USs, CSs, etc"`
States map[string]*etensor.Float32 `desc:"named states -- e.g., USs, CSs, etc"`
TrgPos int `inactive:"+" desc:"target position where Drive US is"`
Drive int `inactive:"+" desc:"current drive state"`
Dist int `inactive:"+" desc:"current distance"`
Expand Down
5 changes: 2 additions & 3 deletions examples/boa/boa.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func main() {

// SimParams has all the custom params for this sim
type SimParams struct {
NData int `desc;"number of data-parallel items to process at once"`
NData int `desc:"number of data-parallel items to process at once"`
EnvSameSeed bool `desc:"for testing, force each env to use same seed"`
PctCortex float32 `desc:"proportion of behavioral approach sequences driven by the cortex vs. hard-coded reflexive subcortical"`
PctCortexMax float32 `desc:"maximum PctCortex, when running on the schedule"`
Expand All @@ -73,7 +73,7 @@ type SimParams struct {

// Defaults sets default params
func (ss *SimParams) Defaults() {
ss.NData = 8
ss.NData = 1
ss.EnvSameSeed = false
ss.PctCortexMax = 1.0
ss.PctCortexStEpc = 5
Expand Down Expand Up @@ -547,7 +547,6 @@ func (ss *Sim) TakeAction(net *axon.Network) {
}
ss.Net.ApplyExts(ctx)
ss.Net.GPU.SyncPoolsToGPU()
// fmt.Printf("action: %s\n", ev.Acts[act])
}

// DecodeAct decodes the VL ActM state to find closest action pattern
Expand Down
Loading

0 comments on commit ed3de63

Please sign in to comment.