Skip to content

Commit

Permalink
passing TestNetAct
Browse files Browse the repository at this point in the history
  • Loading branch information
rcoreilly committed Nov 3, 2024
1 parent 892aa58 commit d96e943
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 38 deletions.
48 changes: 31 additions & 17 deletions axon/basic_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

47 changes: 30 additions & 17 deletions axon/basic_test.goal
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,10 @@ func newTestNet(nData int) *Network {
hidLay := testNet.AddLayer("Hidden", SuperLayer, 4, 1)
outLay := testNet.AddLayer("Output", TargetLayer, 4, 1)

_ = inLay
testNet.ConnectLayers(inLay, hidLay, paths.NewOneToOne(), ForwardPath)
testNet.ConnectLayers(hidLay, outLay, paths.NewOneToOne(), ForwardPath)
testNet.ConnectLayers(outLay, hidLay, paths.NewOneToOne(), BackPath)
one2one := paths.NewOneToOne()
testNet.ConnectLayers(inLay, hidLay, one2one, ForwardPath)
testNet.ConnectLayers(hidLay, outLay, one2one, ForwardPath)
testNet.ConnectLayers(outLay, hidLay, one2one, BackPath)

testNet.Rubicon.SetNUSs(4, 3)
testNet.Rubicon.Defaults()
Expand All @@ -121,7 +121,6 @@ func newTestNetFull(nData int) *Network {
hidLay := testNet.AddLayer("Hidden", SuperLayer, 4, 1)
outLay := testNet.AddLayer("Output", TargetLayer, 4, 1)

_ = inLay
full := paths.NewFull()
testNet.ConnectLayers(inLay, hidLay, full, ForwardPath)
testNet.ConnectLayers(hidLay, outLay, full, ForwardPath)
Expand Down Expand Up @@ -161,7 +160,7 @@ func TestSynValues(t *testing.T) {

func newInPats() *tensor.Float32 {
inPats := tensor.NewFloat32(4, 4, 1)
for pi := 0; pi < 4; pi++ {
for pi := range 4 {
inPats.Set(1, pi, pi, 0)
}
return inPats
Expand Down Expand Up @@ -208,7 +207,7 @@ func TestSpikeProp(t *testing.T) {
pat := tensor.NewFloat32(1, 1)
pat.Set(1, 0, 0)

for del := 0; del <= 4; del++ {
for del := range 5 {
pt.Params.Com.Delay = uint32(del)
pt.Params.Com.MaxDelay = uint32(del) // now need to ensure that >= Delay
net.InitWeights() // resets Gbuf
Expand All @@ -218,7 +217,7 @@ func TestSpikeProp(t *testing.T) {

inCyc := 0
hidCyc := 0
for cyc := 0; cyc < 100; cyc++ {
for cyc := range 100 {
net.Cycle()
// fmt.Println(cyc, Neurons[Ge, hidLay.NeurStIndex, 0], Neurons[GeRaw, hidLay.NeurStIndex, 0])
if Neurons[Spike, inLay.NeurStIndex, 0] > 0 {
Expand Down Expand Up @@ -283,7 +282,7 @@ func TestInitWeights(t *testing.T) {
testNet.SetRandSeed(42) // critical for ActAvg values
testNet.InitWeights()
testNet.InitExt()
for li := 0; li < 3; li++ {
for li := range 3 {
ly := testNet.Layers[li]
for di := range nData {
for _, vnm := range NeuronVarNames {
Expand All @@ -295,9 +294,9 @@ func TestInitWeights(t *testing.T) {
}
}
}
for li := 0; li < 3; li++ {
for li := range 3 {
ly := testNet.Layers[li]
for di := 0; di < nData; di++ {
for di := range nData {
lpi := ly.Params.PoolIndex(0)
lnm := fmt.Sprintf("%s: di: %d", ly.Name, di)
poolValues(lpi, di, valMap, lnm)
Expand All @@ -310,14 +309,14 @@ func TestInitWeights(t *testing.T) {

inpat := inPats.SubSpace(pi)
testNet.InitExt()
for di := 0; di < nData; di++ {
for di := range nData {
inLay.ApplyExt(uint32(di), inpat)
outLay.ApplyExt(uint32(di), inpat)
}
testNet.ApplyExts() // key now for GPU

for qtr := 0; qtr < 4; qtr++ {
for cyc := 0; cyc < 50; cyc++ {
for qtr := range 4 {
for range 50 {
testNet.Cycle()
}
if qtr == 2 {
Expand Down Expand Up @@ -404,7 +403,7 @@ func NetActTest(t *testing.T, tol float32, gpu bool) {

cycPerQtr := 50

for pi := 0; pi < 4; pi++ {
for pi := range 4 {
testNet.NewState(etime.Train)

inpat := inPats.SubSpace(pi)
Expand All @@ -413,12 +412,26 @@ func NetActTest(t *testing.T, tol float32, gpu bool) {
outLay.ApplyExt(0, inpat)
testNet.ApplyExts() // key now for GPU

for qtr := 0; qtr < 4; qtr++ {
for cyc := 0; cyc < cycPerQtr; cyc++ {
for qtr := range 4 {
for cyc := range cycPerQtr {
_ = cyc
testNet.Cycle()
// if gpu {
// testNet.GPU.SyncNeuronsFromGPU()
// }
// inLay.UnitValues(&inActs, "Spike", 0)
// hidLay.UnitValues(&hidActs, "Spike", 0)
// hidLay.UnitValues(&hidGes, "GeRaw", 0)
// hidLay.UnitValues(&hidGis, "Gi", 0)
// outLay.UnitValues(&outActs, "Spike", 0)
// outLay.UnitValues(&outGes, "Ge", 0)
// outLay.UnitValues(&outGis, "Gi", 0)
// fmt.Println("\n############ Cycle:", cyc)
// fmt.Println("In Act:", inActs)
// fmt.Println("Hid Act:", hidActs)
// fmt.Println("Hid Ge:", hidGes)
// fmt.Println("Hid Gi:", hidGis)
// fmt.Println("Out Act:", outActs)
}
if qtr == 2 {
testNet.MinusPhase()
Expand Down
2 changes: 1 addition & 1 deletion axon/layerparams.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion axon/layerparams.goal
Original file line number Diff line number Diff line change
Expand Up @@ -817,7 +817,7 @@ func (ly *LayerParams) SendSpike(ctx *Context, ni, di uint32) {

for pti := uint32(0); pti < ly.Indexes.SendN; pti++ {
pt := GetPaths(ly.Indexes.SendSt + pti)
pt.SendSpike(ctx, ni, lni, di)
pt.SendSpike(ctx, ni, di, lni)
}
}

Expand Down
2 changes: 1 addition & 1 deletion axon/pathparams.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion axon/pathparams.goal
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ func (pt *PathParams) GatherSpikes(ctx *Context, ly *LayerParams, ni, di, lni ui
PathGSyns[npti, di] = gsyn
}

// GatherSpikes integrates G*Raw and G*Syn values for given neuron
// GatherSpikesGSyn integrates G*Raw and G*Syn values for given neuron
// from the given Path-level GRaw value, first integrating
// pathway-level GSyn value.
func (pt *PathParams) GatherSpikesGSyn(ctx *Context, ly *LayerParams, ni, di uint32, gRaw float32, gSyn *float32) {
Expand Down

0 comments on commit d96e943

Please sign in to comment.