-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodulations.py
39 lines (30 loc) · 1.3 KB
/
modulations.py
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
"""
===========================
Modulations
===========================
Dr. Cai Wingfield
---------------------------
Embodied Cognition Lab
Department of Psychology
University of Lancaster
caiwingfield.net
---------------------------
2022
---------------------------
"""
from typing import Dict, Callable
from framework.cognitive_model.basic_types import ActivationValue, ItemIdx
# Maps an item and its activation to a new, modulated activation
Modulation = Callable[[ItemIdx, ActivationValue], ActivationValue]
# Functions to create modulations
def make_apply_activation_cap_modulation_for(activation_cap: ActivationValue) -> Modulation:
def apply_activation_cap_modulation(idx: ItemIdx, activation: ActivationValue) -> ActivationValue:
"""If accumulated activation is over the cap, apply the cap."""
return activation if activation <= activation_cap else activation_cap
return apply_activation_cap_modulation
def make_attenuate_by_statistic_modulation_for(statistic: Dict[ItemIdx, float]) -> Modulation:
def attenuate_by_statistic_modulation(idx: ItemIdx, activation: ActivationValue) -> ActivationValue:
"""Scale an item's activation by a statistic for the item."""
return activation * statistic[idx]
return attenuate_by_statistic_modulation