forked from emer/leabra
-
Notifications
You must be signed in to change notification settings - Fork 1
/
da.go
107 lines (83 loc) · 3.67 KB
/
da.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
// 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/goki/ki/kit"
)
//////////////////////////////////////////////////////////////////////////////////////
// DaMod
// Params for effects of dopamine (Da) based modulation, typically adding
// a Da-based term to the Ge excitatory synaptic input.
// Plus-phase = learning effects relative to minus-phase "performance" dopamine effects
type DaModParams struct {
On bool `desc:"whether to use dopamine modulation"`
ModGain bool `viewif:"On" desc:"modulate gain instead of Ge excitatory synaptic input"`
Minus float32 `viewif:"On" desc:"how much to multiply Da in the minus phase to add to Ge input -- use negative values for NoGo/indirect pathway/D2 type neurons"`
Plus float32 `viewif:"On" desc:"how much to multiply Da in the plus phase to add to Ge input -- use negative values for NoGo/indirect pathway/D2 type neurons"`
NegGain float32 `viewif:"On&&ModGain" desc:"for negative dopamine, how much to change the default gain value as a function of dopamine: gain = gain * (1 + da * NegNain) -- da is multiplied by minus or plus depending on phase"`
PosGain float32 `viewif:"On&&ModGain" desc:"for positive dopamine, how much to change the default gain value as a function of dopamine: gain = gain * (1 + da * PosGain) -- da is multiplied by minus or plus depending on phase"`
}
func (dm *DaModParams) Defaults() {
dm.Minus = 0
dm.Plus = 0.01
dm.NegGain = 0.1
dm.PosGain = 0.1
}
// GeModOn returns true if modulating Ge
func (dm *DaModParams) GeModOn() bool {
return dm.On && !dm.ModGain
}
// GainModOn returns true if modulating Gain
func (dm *DaModParams) GainModOn() bool {
return dm.On && dm.ModGain
}
// Ge returns da-modulated ge value
func (dm *DaModParams) Ge(da, ge float32, plusPhase bool) float32 {
if plusPhase {
return dm.Plus * da * ge
} else {
return dm.Minus * da * ge
}
}
// Gain returns da-modulated gain value
func (dm *DaModParams) Gain(da, gain float32, plusPhase bool) float32 {
if plusPhase {
da *= dm.Plus
} else {
da *= dm.Minus
}
if da < 0 {
return gain * (1 + da*dm.NegGain)
} else {
return gain * (1 + da*dm.PosGain)
}
}
//////////////////////////////////////////////////////////////////////
// Enums
// DaReceptors for D1R and D2R dopamine receptors
type DaReceptors int
//go:generate stringer -type=DaReceptors
var KiT_DaReceptors = kit.Enums.AddEnum(DaReceptorsN, kit.NotBitFlag, nil)
func (ev DaReceptors) MarshalJSON() ([]byte, error) { return kit.EnumMarshalJSON(ev) }
func (ev *DaReceptors) UnmarshalJSON(b []byte) error { return kit.EnumUnmarshalJSON(ev, b) }
const (
// D1R primarily expresses Dopamine D1 Receptors -- dopamine is excitatory and bursts of dopamine lead to increases in synaptic weight, while dips lead to decreases -- direct pathway in dorsal striatum
D1R DaReceptors = iota
// D2R primarily expresses Dopamine D2 Receptors -- dopamine is inhibitory and bursts of dopamine lead to decreases in synaptic weight, while dips lead to increases -- indirect pathway in dorsal striatum
D2R
DaReceptorsN
)
// Valences for Appetitive and Aversive valence coding
type Valences int
//go:generate stringer -type=Valences
var KiT_Valences = kit.Enums.AddEnum(ValencesN, kit.NotBitFlag, nil)
func (ev Valences) MarshalJSON() ([]byte, error) { return kit.EnumMarshalJSON(ev) }
func (ev *Valences) UnmarshalJSON(b []byte) error { return kit.EnumUnmarshalJSON(ev, b) }
const (
// Appetititve is a positive valence US (food, water, etc)
Appetitive Valences = iota
// Aversive is a negative valence US (shock, threat etc)
Aversive
ValencesN
)