-
Notifications
You must be signed in to change notification settings - Fork 0
/
se.go
59 lines (50 loc) · 1.56 KB
/
se.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/dhairyyas/leabra-sleep/deep"
"github.com/goki/ki/kit"
)
// SeSrcLayer is the basic type of layer that sends Se 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 SeSrcLayer struct {
ModLayer
SendTo []string `desc:"list of layers to send Se to"`
}
var KiT_SeSrcLayer = kit.Types.AddType(&SeSrcLayer{}, deep.LayerProps)
// SendToCheck is called during Build to ensure that SendTo layers are valid
func (ly *SeSrcLayer) SendToCheck() error {
var lasterr error
for _, lnm := range ly.SendTo {
ly, err := ly.Network.LayerByNameTry(lnm)
if err != nil {
log.Printf("SeSrcLayer %s SendToCheck: %v\n", ly.Name(), err)
lasterr = err
}
}
return lasterr
}
// Build constructs the layer state, including calling Build on the projections.
func (ly *SeSrcLayer) Build() error {
err := ly.ModLayer.Build()
if err != nil {
return err
}
err = ly.SendToCheck()
return err
}
// SendSe sends serotonin to SendTo list of layers
func (ly *SeSrcLayer) SendSe(se float32) {
for _, lnm := range ly.SendTo {
ml := ly.Network.LayerByName(lnm).(PBWMLayer).AsMod()
ml.SE = se
}
}
// AddSendTo adds given layer name to list of those to send DA to
func (ly *SeSrcLayer) AddSendTo(laynm string) {
ly.SendTo = append(ly.SendTo, laynm)
}