Skip to content

Commit 927371b

Browse files
committed
Adding attention strategy
1 parent 8fa56d2 commit 927371b

File tree

15 files changed

+530
-6
lines changed

15 files changed

+530
-6
lines changed

axelrod/data/model_attention.pth

48.9 MB
Binary file not shown.

axelrod/load_data_.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
import pkgutil
33
from typing import Callable, Dict, List, Optional, Tuple
44

5+
import torch
6+
57

68
def axl_filename(path: pathlib.Path) -> pathlib.Path:
79
"""Given a path under Axelrod/, return absolute filepath.
@@ -77,3 +79,12 @@ def load_pso_tables(filename="pso_gambler.csv", directory="data"):
7779
values = list(map(float, row[4:]))
7880
d[(name, int(a), int(b), int(c))] = values
7981
return d
82+
83+
84+
def load_attention_model_weights(
85+
filename="model_attention.pth", directory="axelrod/data"
86+
):
87+
"""Load attention model weights."""
88+
path = str(axl_filename(pathlib.Path(directory) / filename))
89+
weights = torch.load(path, map_location=torch.device("cpu"))
90+
return weights

axelrod/strategies/_strategies.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
from .ann import ANN, EvolvableANN # pylint: disable=unused-import
3131
from .apavlov import APavlov2006, APavlov2011
3232
from .appeaser import Appeaser
33+
from .attention import EvolvedAttention
3334
from .averagecopier import AverageCopier, NiceAverageCopier
3435
from .axelrod_first import (
3536
FirstByDavis,
@@ -348,6 +349,7 @@
348349
EvolvedHMM5,
349350
EvolvedLookerUp1_1_1,
350351
EvolvedLookerUp2_2_2,
352+
EvolvedAttention,
351353
FirmButFair,
352354
FirstByAnonymous,
353355
FirstByDavis,

0 commit comments

Comments
 (0)