-
Notifications
You must be signed in to change notification settings - Fork 0
/
modlayer.go
62 lines (56 loc) · 1.75 KB
/
modlayer.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
// 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 (
"github.com/PrincetonCompMemLab/neurodiff_leabra/deep"
"github.com/PrincetonCompMemLab/neurodiff_leabra/leabra"
"github.com/goki/ki/kit"
)
// ModLayer provides DA modulated learning to basic Leabra layers.
type ModLayer struct {
Layer
DaMod DaModParams `desc:"dopamine modulation effects, typically affecting Ge or gain -- a phase-based difference in modulation will result in learning effects through standard error-driven learning."`
}
var KiT_ModLayer = kit.Types.AddType(&ModLayer{}, deep.LayerProps)
// GFmInc integrates new synaptic conductances from increments sent during last SendGDelta.
func (ly *ModLayer) GFmInc(ltime *leabra.Time) {
if !ly.DaMod.GeModOn() {
ly.Layer.GFmInc(ltime)
return
}
ly.RecvGInc(ltime)
for ni := range ly.Neurons {
nrn := &ly.Neurons[ni]
if nrn.IsOff() {
continue
}
ly.Act.GRawFmInc(nrn)
geRaw := ly.DaMod.Ge(ly.DA, nrn.GeRaw, ltime.PlusPhase)
ly.Act.GeFmRaw(nrn, geRaw)
ly.Act.GiFmRaw(nrn, nrn.GiRaw)
}
ly.LeabraLay.(PBWMLayer).AttnGeInc(ltime)
}
// ActFmG computes rate-code activation from Ge, Gi, Gl conductances
// and updates learning running-average activations from that Act
func (ly *ModLayer) ActFmG(ltime *leabra.Time) {
if !ly.DaMod.GainModOn() {
ly.Layer.ActFmG(ltime)
return
}
curGain := ly.Act.XX1.Gain
ly.Act.XX1.Gain = ly.DaMod.Gain(ly.DA, curGain, ltime.PlusPhase)
ly.Act.XX1.Update()
for ni := range ly.Neurons {
nrn := &ly.Neurons[ni]
if nrn.IsOff() {
continue
}
ly.Act.VmFmG(nrn)
ly.Act.ActFmG(nrn)
ly.Learn.AvgsFmAct(nrn)
}
ly.Act.XX1.Gain = curGain
ly.Act.XX1.Update()
}