-
Notifications
You must be signed in to change notification settings - Fork 0
/
ach.go
59 lines (50 loc) · 1.58 KB
/
ach.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
// Copyright (c) 2019, 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 pbwm
import (
"log"
"github.com/PrincetonCompMemLab/neurodiff_leabra/deep"
"github.com/goki/ki/kit"
)
// AChSrcLayer is the basic type of layer that sends ACh to other layers.
// Uses a list of layer names to send to -- not use Prjn infrastructure
// as it is global broadcast modulator -- individual neurons
// can use it in their own special way.
type AChSrcLayer struct {
Layer
SendTo []string `desc:"list of layers to send ACh to"`
}
var KiT_AChSrcLayer = kit.Types.AddType(&AChSrcLayer{}, deep.LayerProps)
// SendToCheck is called during Build to ensure that SendTo layers are valid
func (ly *AChSrcLayer) SendToCheck() error {
var lasterr error
for _, lnm := range ly.SendTo {
ly, err := ly.Network.LayerByNameTry(lnm)
if err != nil {
log.Printf("AChSrcLayer %s SendToCheck: %v\n", ly.Name(), err)
lasterr = err
}
}
return lasterr
}
// Build constructs the layer state, including calling Build on the projections.
func (ly *AChSrcLayer) Build() error {
err := ly.Layer.Build()
if err != nil {
return err
}
err = ly.SendToCheck()
return err
}
// SendACh sends ACh to SendTo list of layers
func (ly *AChSrcLayer) SendACh(ach float32) {
for _, lnm := range ly.SendTo {
ml := ly.Network.LayerByName(lnm).(PBWMLayer).AsPBWM()
ml.ACh = ach
}
}
// AddSendTo adds given layer name to list of those to send DA to
func (ly *AChSrcLayer) AddSendTo(laynm string) {
ly.SendTo = append(ly.SendTo, laynm)
}