forked from emer/leabra
/
bl_amyg.go
108 lines (96 loc) · 2.7 KB
/
bl_amyg.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
// Copyright (c) 2020, The Emergent Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package pvlv
import (
"fmt"
"strconv"
"github.com/ccnlab/leabrax/interinhib"
"github.com/ccnlab/leabrax/leabra"
"github.com/goki/ki/kit"
)
// IBlAmygLayer has one method, AsBlAmygLayer, that returns a pointer to the layer specifically as a BLA layer.
type IBlAmygLayer interface {
AsBlAmygLayer() *BlAmygLayer
}
// AsBlAmygLayer returns a pointer to the layer specifically as a BLA layer.
func (ly *BlAmygLayer) AsBlAmygLayer() *BlAmygLayer {
return ly
}
// BlAmygLayer contains values specific to BLA layers, including Interlayer Inhibition (ILI)
type BlAmygLayer struct {
ModLayer `desc:"modulation state"`
Valence Valence `desc:"positive or negative valence"`
ILI interinhib.InterInhib `desc:"inter-layer inhibition parameters and state"`
}
var KiT_BlAmygLayer = kit.Types.AddType(&BlAmygLayer{}, nil)
func (ly *BlAmygLayer) Build() error {
nu := ly.Shp.Len()
if nu == 0 {
return fmt.Errorf("build Layer %v: no units specified in Shape", ly.Nm)
}
ly.Neurons = make([]leabra.Neuron, nu)
err := ly.AsMod().Build()
if err != nil {
return err
}
err = ly.BuildPools(nu)
if err != nil {
return err
}
err = ly.BuildPrjns()
if err != nil {
return err
}
return err
}
func (ly *BlAmygLayer) Defaults() {
ly.ModLayer.Defaults()
ly.ActModZero = true
ly.DaMod.BurstGain = 0.04
ly.DaMod.DipGain = 0.1
ly.DaMod.On = true
ly.Minus = 1.0
ly.Plus = 1.0
ly.NegGain = 0.1
ly.PosGain = 0.1
ly.Act.Init.Vm = 0.55
}
// GetMonitorVal retrieves a value for a trace of some quantity, possibly more than just a variable
func (ly *BlAmygLayer) GetMonitorVal(data []string) float64 {
var val float32
var err error
valType := data[0]
unitIdx, _ := strconv.Atoi(data[1])
switch valType {
case "TotalAct":
val = TotalAct(ly)
case "PoolActAvg":
val = ly.Pools[unitIdx].Inhib.Act.Avg
case "PoolActMax":
val = ly.Pools[unitIdx].Inhib.Act.Max
case "Act":
val = ly.Neurons[unitIdx].Act
case "ActDiff":
val = ly.Neurons[unitIdx].Act - ly.ModNeurs[unitIdx].ModAct
default:
mnr := &ly.ModNeurs[unitIdx]
val, err = mnr.VarByName(valType)
if err != nil {
nrn := &ly.Neurons[unitIdx]
val, err = nrn.VarByName(valType)
if err != nil {
fmt.Printf("VarByName error: %v\n", err)
}
}
}
return float64(val)
}
// InhibiFmGeAct computes inhibition Gi from Ge and Act averages within relevant Pools
func (ly *BlAmygLayer) InhibFmGeAct(ltime *leabra.Time) {
lpl := &ly.Pools[0]
ly.Inhib.Layer.Inhib(&lpl.Inhib)
ly.ILI.Inhib(&ly.Layer) // does inter-layer inhibition
ly.PoolInhibFmGeAct(ltime)
ly.InhibFmPool(ltime)
}