Skip to content

Adding attention strategy #1470

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added axelrod/data/model_attention.pth
Binary file not shown.
11 changes: 11 additions & 0 deletions axelrod/load_data_.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
import pkgutil
from typing import Callable, Dict, List, Optional, Tuple

import torch


def axl_filename(path: pathlib.Path) -> pathlib.Path:
"""Given a path under Axelrod/, return absolute filepath.
Expand Down Expand Up @@ -77,3 +79,12 @@ def load_pso_tables(filename="pso_gambler.csv", directory="data"):
values = list(map(float, row[4:]))
d[(name, int(a), int(b), int(c))] = values
return d


def load_attention_model_weights(
filename="model_attention.pth", directory="axelrod/data"
):
"""Load attention model weights."""
path = str(axl_filename(pathlib.Path(directory) / filename))
weights = torch.load(path, map_location=torch.device("cpu"))
return weights
3 changes: 3 additions & 0 deletions axelrod/strategies/_strategies.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
from .ann import ANN, EvolvableANN # pylint: disable=unused-import
from .apavlov import APavlov2006, APavlov2011
from .appeaser import Appeaser
from .attention import Attention, EvolvedAttention
from .averagecopier import AverageCopier, NiceAverageCopier
from .axelrod_first import (
FirstByDavis,
Expand Down Expand Up @@ -303,6 +304,7 @@
AntiCycler,
AntiTitForTat,
Appeaser,
Attention,
ArrogantQLearner,
AverageCopier,
BackStabber,
Expand Down Expand Up @@ -348,6 +350,7 @@
EvolvedHMM5,
EvolvedLookerUp1_1_1,
EvolvedLookerUp2_2_2,
EvolvedAttention,
FirmButFair,
FirstByAnonymous,
FirstByDavis,
Expand Down
Loading
Loading