Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update to v2 #321

Merged
merged 16 commits into from
Dec 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
sudo apt-get install libgl1-mesa-dev xorg-dev mesa-vulkan-drivers
- uses: actions/setup-go@v3
with:
go-version: "1.19"
go-version: "1.21"
- run: go build ./...
- run: go test -tags=multinet -race ./...

Expand All @@ -38,7 +38,7 @@ jobs:
sudo apt-get install libgl1-mesa-dev xorg-dev mesa-vulkan-drivers
- uses: actions/setup-go@v3
with:
go-version: "1.19"
go-version: "1.21"
- name: Generate coverage report
run: go test -tags=multinet ./... -coverprofile=coverage.txt -covermode=atomic -timeout=20m
- name: Upload coverage report
Expand Down
76 changes: 76 additions & 0 deletions .goki/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
Name = "axon"
Desc = ""
Version = "v2.0.0-dev0.0.2"
Type = "Library"

[Build]
Package = "."
Output = ""
ID = "org.emer.axon"
Debug = false
Rebuild = false
Install = false
PrintOnly = false
Print = false
Trimpath = false
Work = false
IOSVersion = "13.0"
AndroidMinSDK = 23
AndroidTargetSDK = 29

[Web]
Port = "8080"
RandomVersion = false
Gzip = false
BackgroundColor = "#2d2c2c"
ThemeColor = "#2d2c2c"
LoadingLabel = ""
Lang = "en"
Title = ""
Description = ""
Author = ""
Image = ""
AutoUpdateInterval = "10s"
WasmContentLengthHeader = ""
ServiceWorkerTemplate = ""

[Setup]
[Setup.Platform]
OS = ""
Arch = ""

[Log]
Target = "android"
Keep = false
All = "F"

[Release]
VersionFile = "axon/version.go"
Package = "axon"

[Generate]
Dir = "."
Output = "gokigen.go"
[Generate.Enumgen]
Dir = "."
Output = "enumgen.go"
Transform = ""
TrimPrefix = ""
AddPrefix = ""
LineComment = true
AcceptLower = true
Text = true
JSON = false
YAML = false
SQL = false
GQL = false
Extend = true
[Generate.Gtigen]
Dir = "."
Output = "gtigen.go"
AddTypes = false
AddMethods = false
AddFuncs = false
Instance = false
TypeVar = false
Setters = false
338 changes: 169 additions & 169 deletions axon/act.go

Large diffs are not rendered by default.

49 changes: 19 additions & 30 deletions axon/act_prjn.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,16 @@ package axon
import (
"log"

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

//go:generate stringer -type=PrjnGTypes

var KiT_PrjnGTypes = kit.Enums.AddEnum(PrjnGTypesN, kit.NotBitFlag, nil)

func (ev PrjnGTypes) MarshalJSON() ([]byte, error) { return kit.EnumMarshalJSON(ev) }
func (ev *PrjnGTypes) UnmarshalJSON(b []byte) error { return kit.EnumUnmarshalJSON(ev, b) }

//gosl: start act_prjn

// PrjnGTypes represents the conductance (G) effects of a given projection,
// including excitatory, inhibitory, and modulatory.
type PrjnGTypes int32
type PrjnGTypes int32 //enums:enum

// The projection conductance types
const (
Expand All @@ -49,8 +40,6 @@ const (
// Context projections are for inputs to CT layers, which update
// only at the end of the plus phase, and send to CtxtGe.
ContextG

PrjnGTypesN
)

//////////////////////////////////////////////////////////////////////////////////////
Expand All @@ -63,22 +52,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 +211,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 All @@ -251,16 +240,16 @@ func (ws *PrjnScaleParams) SLayActScale(savg, snu, ncon float32) float32 {
}
semExtra := 2
slayActN := int(mat32.Round(savg * snu)) // sending layer actual # active
slayActN = ints.MaxInt(slayActN, 1)
slayActN = max(slayActN, 1)
var sc float32
if ncon == snu {
sc = 1 / float32(slayActN)
} else {
maxActN := int(mat32.Min(ncon, float32(slayActN))) // max number we could get
avgActN := int(mat32.Round(savg * ncon)) // recv average actual # active if uniform
avgActN = ints.MaxInt(avgActN, 1)
avgActN = max(avgActN, 1)
expActN := avgActN + semExtra // expected
expActN = ints.MinInt(expActN, maxActN)
expActN = min(expActN, maxActN)
sc = 1 / float32(expActN)
}
return sc
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
10 changes: 5 additions & 5 deletions axon/avgmax.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,19 @@ func SetAvgMaxFloatFromIntErr(fun func()) {
type AvgMaxI32 struct {

// Average, from Calc when last computed as Sum / N
Avg float32 `inactive:"+" desc:"Average, from Calc when last computed as Sum / N"`
Avg float32 `inactive:"+"`

// Maximum value, copied from CurMax in Calc
Max float32 `inactive:"+" desc:"Maximum value, copied from CurMax in Calc"`
Max float32 `inactive:"+"`

// sum for computing average -- incremented in UpdateVal, reset in Calc
Sum int32 `inactive:"+" desc:"sum for computing average -- incremented in UpdateVal, reset in Calc"`
Sum int32 `inactive:"+"`

// current maximum value, updated via UpdateVal, reset in Calc
CurMax int32 `inactive:"+" desc:"current maximum value, updated via UpdateVal, reset in Calc"`
CurMax int32 `inactive:"+"`

// number of items in the sum -- this must be set in advance to a known value and it is used in computing the float <-> int conversion factor to maximize precision.
N int32 `inactive:"+" desc:"number of items in the sum -- this must be set in advance to a known value and it is used in computing the float <-> int conversion factor to maximize precision."`
N int32 `inactive:"+"`

pad, pad1, pad2 int32
}
Expand Down
4 changes: 3 additions & 1 deletion axon/axon.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@

package axon

//go:generate goki generate -add-types

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
18 changes: 9 additions & 9 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/goki/ki/kit"
"github.com/goki/mat32"
"github.com/emer/emergent/v2/erand"
"github.com/emer/emergent/v2/etime"
"github.com/emer/emergent/v2/params"
"github.com/emer/emergent/v2/prjn"
"goki.dev/etable/v2/etensor"
"goki.dev/laser"
"goki.dev/mat32/v2"
"golang.org/x/exp/maps"
)

Expand Down Expand Up @@ -260,7 +260,7 @@ func TestSpikeProp(t *testing.T) {

// StructVals adds field vals to given vals map
func StructVals(obj any, vals map[string]float32, key string) {
v := kit.NonPtrValue(reflect.ValueOf(obj))
v := laser.NonPtrValue(reflect.ValueOf(obj))
typ := v.Type()
for i := 0; i < v.NumField(); i++ {
ft := typ.Field(i)
Expand All @@ -269,7 +269,7 @@ func StructVals(obj any, vals map[string]float32, key string) {
}
fv := v.Field(i)
kk := key + fmt.Sprintf("\t%s", ft.Name)
vals[kk], _ = kit.ToFloat32(fv.Interface())
vals[kk], _ = laser.ToFloat32(fv.Interface())
}
}

Expand Down
Loading