TensorFlow implementation of Style Transfer Generative Adversarial Networks: Learning to Play Chess Differently.

Overview

Adversarial Chess

TensorFlow implementation of Style Transfer Generative Adversarial Networks: Learning to Play Chess Differently.

Requirements

To run this project, working installations of TensorFlow, Python-Chess, and h5py are needed. TensorFlow version 0.12.1 was used.

Background

AIs for chess have long since exceeded the abilities of the top human chess players. However, current AIs offer little pedagogical value due to their mechanical playstyle. This research project hopes to overcome this by applying the idea of style transfer to chess, so that an AI can be trained to play in the style of specific human players.

Data

The two datasets used in this project can be obtained from FICS and PGNMentor. Once the chess game data has been obtained, it can be converted to training data by running:

python process_data.py

Please note that the main() function in process_data.py should be edited to use your specific data paths.

Training and Testing

The model can be trained with:

python train_model.py

And run with:

python play.py

Examples

Commandline Move 1 Commandline Move 2

You might also like...
A simple PyTorch Implementation of Generative Adversarial Networks, focusing on anime face drawing.
A simple PyTorch Implementation of Generative Adversarial Networks, focusing on anime face drawing.

AnimeGAN A simple PyTorch Implementation of Generative Adversarial Networks, focusing on anime face drawing. Randomly Generated Images The images are

Alias-Free Generative Adversarial Networks (StyleGAN3) Official PyTorch implementation
Alias-Free Generative Adversarial Networks (StyleGAN3) Official PyTorch implementation

Alias-Free Generative Adversarial Networks (StyleGAN3) Official PyTorch implementation

Digan - Official PyTorch implementation of Generating Videos with Dynamics-aware Implicit Generative Adversarial Networks
Digan - Official PyTorch implementation of Generating Videos with Dynamics-aware Implicit Generative Adversarial Networks

DIGAN (ICLR 2022) Official PyTorch implementation of "Generating Videos with Dyn

Semi-supervised Representation Learning for Remote Sensing Image Classification Based on Generative Adversarial Networks

SSRL-for-image-classification Semi-supervised Representation Learning for Remote Sensing Image Classification Based on Generative Adversarial Networks

PyTorch implementation of Advantage Actor Critic (A2C), Proximal Policy Optimization (PPO), Scalable trust-region method for deep reinforcement learning using Kronecker-factored approximation (ACKTR) and Generative Adversarial Imitation Learning (GAIL). PyTorch implementation of Advantage Actor Critic (A2C), Proximal Policy Optimization (PPO), Scalable trust-region method for deep reinforcement learning using Kronecker-factored approximation (ACKTR) and Generative Adversarial Imitation Learning (GAIL).
PyTorch implementation of Advantage Actor Critic (A2C), Proximal Policy Optimization (PPO), Scalable trust-region method for deep reinforcement learning using Kronecker-factored approximation (ACKTR) and Generative Adversarial Imitation Learning (GAIL).

PyTorch implementation of Advantage Actor Critic (A2C), Proximal Policy Optimization (PPO), Scalable trust-region method for deep reinforcement learning using Kronecker-factored approximation (ACKTR) and Generative Adversarial Imitation Learning (GAIL).

Learning from Guided Play: A Scheduled Hierarchical Approach for Improving Exploration in Adversarial Imitation Learning Source Code
Learning from Guided Play: A Scheduled Hierarchical Approach for Improving Exploration in Adversarial Imitation Learning Source Code

Learning from Guided Play: A Scheduled Hierarchical Approach for Improving Exploration in Adversarial Imitation Learning Source Code

PyTorch implementation of neural style transfer algorithm
PyTorch implementation of neural style transfer algorithm

neural-style-pt This is a PyTorch implementation of the paper A Neural Algorithm of Artistic Style by Leon A. Gatys, Alexander S. Ecker, and Matthias

Official PyTorch implementation of
Official PyTorch implementation of "ArtFlow: Unbiased Image Style Transfer via Reversible Neural Flows"

ArtFlow Official PyTorch implementation of the paper: ArtFlow: Unbiased Image Style Transfer via Reversible Neural Flows Jie An*, Siyu Huang*, Yibing

Comments
  • TypeError: Expected int32, got list containing Tensors of type '_Message' instead

    TypeError: Expected int32, got list containing Tensors of type '_Message' instead

    After doing python process_data.py using ../Data/GM2001.pgn the next step in the README.md fails:

    $ ls ../Data/
    -rw-r--r-- 1 lila lila    49530521 Feb 26 08:34 GM2001.pgn
    -rw-rw-r-- 1 lila lila 11946358296 Feb 28 00:51 training_data.hdf5
    -rw-rw-r-- 1 lila lila   134512600 Feb 28 00:57 player_data.hdf5
    -rw-rw-r-- 1 lila lila   452653274 Feb 28 00:59 full_boards.pkl
    
    $ uname -a
    Linux dugovic-host 4.4.0-64-generic #85-Ubuntu SMP Mon Feb 20 11:50:30 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
    
    $ python train_model.py 
    W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE3 instructions, but these are available on your machine and could speed up CPU computations.
    W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.1 instructions, but these are available on your machine and could speed up CPU computations.
    W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.2 instructions, but these are available on your machine and could speed up CPU computations.
    W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX instructions, but these are available on your machine and could speed up CPU computations.
    W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX2 instructions, but these are available on your machine and could speed up CPU computations.
    W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use FMA instructions, but these are available on your machine and could speed up CPU computations.
    Traceback (most recent call last):
      File "train_model.py", line 14, in <module>
        magikarp = Magikarp(config, sess)
      File "/home/lila/AdversarialChess/model.py", line 18, in __init__
        self.p_data = h5py.File(config['p_datafile'], 'r')
      File "/home/lila/.local/lib/python2.7/site-packages/h5py/_hl/files.py", line 272, in __init__
        fid = make_fid(name, mode, userblock_size, fapl, swmr=swmr)
      File "/home/lila/.local/lib/python2.7/site-packages/h5py/_hl/files.py", line 92, in make_fid
        fid = h5f.open(name, flags, fapl=fapl)
      File "h5py/_objects.pyx", line 54, in h5py._objects.with_phil.wrapper (/tmp/pip-4rPeHA-build/h5py/_objects.c:2684)
      File "h5py/_objects.pyx", line 55, in h5py._objects.with_phil.wrapper (/tmp/pip-4rPeHA-build/h5py/_objects.c:2642)
      File "h5py/h5f.pyx", line 76, in h5py.h5f.open (/tmp/pip-4rPeHA-build/h5py/h5f.c:1930)
    IOError: Unable to open file (Unable to open file: name = '../data/tal_data.hdf5', errno = 2, error message = 'no such file or directory', flags = 0, o_flags = 0)
    
    opened by ddugovic 5
  • 'Game' object has no attribute 'is_end'

    'Game' object has no attribute 'is_end'

    Hi,

    I was planning to open a PR with updated instructions for conda.

    I believe I've successfully installed everything - but I can't get python process_data.py to run.

    [Event "FICS rated standard game"] [Site "FICS freechess.org"] [Date "2017.01.31"] [Round "?"] [White "aberleider"] [Black "rewqfdsa"] [Result "1-0"] [FICSGamesDBGameNo "410988594"] [WhiteElo "2138"] [BlackElo "1925"] [WhiteRD "57.9"] [BlackRD "34.8"] [TimeControl "2700+15"] [Time "22:37:00"] [WhiteClock "0:45:00.000"] [BlackClock "0:45:00.000"] [ECO "D01"] [PlyCount "79"]

    1. d4 d5 2. Nc3 Nf6 3. Bg5 Nbd7 4. Qd3 h6 5. Bh4 g5 6. Bg3 a6 7. O-O-O Bg7 8. h4 g4 9. e4 dxe4 10. Nxe4 Nxe4 11. Qxe4 Nf6 12. Qe5 c6 13. Ne2 Qd5 14. Nc3 Qxe5 15. Bxe5 O-O 16. Bd3 h5 17. Ne2 Nd5 18. Bxg7 Kxg7 19. c4 Nf6 20. Nf4 Rd8 21. d5 cxd5 22. cxd5 Nxd5 23. Bc4 e6 24. Nxh5+ Kf8 25. Nf6 Ke7 26. Nxg4 b5 27. Bxd5 exd5 28. Rhe1+ Kf8 29. Ne5 Bf5 30. Kd2 f6 31. Nc6 Rd6 32. Nd4 Bd7 33. Rc1 Kg7 34. Re7+ Kg6 35. Rc7 Rd8 36. g4 Kh6 37. f4 Kg6 38. h5+ Kh6 39. Rcxd7 R6xd7 40. Nf5# { Black checkmated } 1-0 Traceback (most recent call last): File "process_data.py", line 174, in main() File "process_data.py", line 170, in main gen_board_pair_data(datafile, 'training_data') File "process_data.py", line 76, in gen_board_pair_data while not node.is_end(): AttributeError: 'Game' object has no attribute 'is_end

    my branch is here https://github.com/johndpope/AdversarialChess

    opened by johndpope 2
  • TypeError: Expected int32, got list containing Tensors of type '_Message' instead.

    TypeError: Expected int32, got list containing Tensors of type '_Message' instead.

    Traceback (most recent call last): File "train_model.py", line 15, in <module> magikarp.train() File "/Users/johndpope/Documents/tensorFlowWorkspace/AdversarialChess/model.py", line 215, in train self.create_model() File "/Users/johndpope/Documents/tensorFlowWorkspace/AdversarialChess/model.py", line 197, in create_model self.create_dis_model() File "/Users/johndpope/Documents/tensorFlowWorkspace/AdversarialChess/model.py", line 187, in create_dis_model self.d_pred_real = self.d_predict(tf.concat(1, [self.person_board_1, self.person_board_2]), self.p_keep) File "/Users/johndpope/miniconda2/envs/tensorflow-p2/lib/python2.7/site-packages/tensorflow/python/ops/array_ops.py", line 1029, in concat dtype=dtypes.int32).get_shape( File "/Users/johndpope/miniconda2/envs/tensorflow-p2/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 639, in convert_to_tensor as_ref=False) File "/Users/johndpope/miniconda2/envs/tensorflow-p2/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 704, in internal_convert_to_tensor ret = conversion_func(value, dtype=dtype, name=name, as_ref=as_ref) File "/Users/johndpope/miniconda2/envs/tensorflow-p2/lib/python2.7/site-packages/tensorflow/python/framework/constant_op.py", line 113, in _constant_tensor_conversion_function return constant(v, dtype=dtype, name=name) File "/Users/johndpope/miniconda2/envs/tensorflow-p2/lib/python2.7/site-packages/tensorflow/python/framework/constant_op.py", line 102, in constant tensor_util.make_tensor_proto(value, dtype=dtype, shape=shape, verify_shape=verify_shape)) File "/Users/johndpope/miniconda2/envs/tensorflow-p2/lib/python2.7/site-packages/tensorflow/python/framework/tensor_util.py", line 370, in make_tensor_proto _AssertCompatible(values, dtype) File "/Users/johndpope/miniconda2/envs/tensorflow-p2/lib/python2.7/site-packages/tensorflow/python/framework/tensor_util.py", line 302, in _AssertCompatible (dtype.name, repr(mismatch), type(mismatch).__name__)) TypeError: Expected int32, got list containing Tensors of type '_Message' instead.

    was there a specific tensorflow version you used?

    opened by johndpope 1
Owner
Muthu Chidambaram
Muthu Chidambaram
Simple Tensorflow implementation of "Adaptive Convolutions for Structure-Aware Style Transfer" (CVPR 2021)

AdaConv — Simple TensorFlow Implementation [Paper] : Adaptive Convolutions for Structure-Aware Style Transfer (CVPR 2021) Note This repository does no

Junho Kim 26 Nov 18, 2022
Fast Style Transfer in TensorFlow

Fast Style Transfer in TensorFlow Add styles from famous paintings to any photo in a fraction of a second! You can even style videos! It takes 100ms o

Jefferson 5 Oct 24, 2021
TensorFlow CNN for fast style transfer

Fast Style Transfer in TensorFlow Add styles from famous paintings to any photo in a fraction of a second! It takes 100ms on a 2015 Titan X to style t

null 1 Dec 14, 2021
transfer attack; adversarial examples; black-box attack; unrestricted Adversarial Attacks on ImageNet; CVPR2021 天池黑盒竞赛

transfer_adv CVPR-2021 AIC-VI: unrestricted Adversarial Attacks on ImageNet CVPR2021 安全AI挑战者计划第六期赛道2:ImageNet无限制对抗攻击 介绍 : 深度神经网络已经在各种视觉识别问题上取得了最先进的性能。

null 25 Dec 8, 2022
PyTorch implementation of "Learning to Discover Cross-Domain Relations with Generative Adversarial Networks"

DiscoGAN in PyTorch PyTorch implementation of Learning to Discover Cross-Domain Relations with Generative Adversarial Networks. * All samples in READM

Taehoon Kim 1k Jan 4, 2023
Official implementation of "Learning to Discover Cross-Domain Relations with Generative Adversarial Networks"

DiscoGAN Official PyTorch implementation of Learning to Discover Cross-Domain Relations with Generative Adversarial Networks. Prerequisites Python 2.7

SK T-Brain 754 Dec 29, 2022
Minimal PyTorch implementation of Generative Latent Optimization from the paper "Optimizing the Latent Space of Generative Networks"

Minimal PyTorch implementation of Generative Latent Optimization This is a reimplementation of the paper Piotr Bojanowski, Armand Joulin, David Lopez-

Thomas Neumann 117 Nov 27, 2022
Unofficial implementation of Alias-Free Generative Adversarial Networks. (https://arxiv.org/abs/2106.12423) in PyTorch

alias-free-gan-pytorch Unofficial implementation of Alias-Free Generative Adversarial Networks. (https://arxiv.org/abs/2106.12423) This implementation

Kim Seonghyeon 502 Jan 3, 2023
Partial implementation of ODE-GAN technique from the paper Training Generative Adversarial Networks by Solving Ordinary Differential Equations

ODE GAN (Prototype) in PyTorch Partial implementation of ODE-GAN technique from the paper Training Generative Adversarial Networks by Solving Ordinary

Somshubra Majumdar 15 Feb 10, 2022
Pytorch implementation for reproducing StackGAN_v2 results in the paper StackGAN++: Realistic Image Synthesis with Stacked Generative Adversarial Networks

StackGAN-v2 StackGAN-v1: Tensorflow implementation StackGAN-v1: Pytorch implementation Inception score evaluation Pytorch implementation for reproduci

Han Zhang 809 Dec 16, 2022