File size: 2,082 Bytes
ce5ebae
c5361c5
 
 
 
 
 
 
ce5ebae
 
c5361c5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
---

tags:
- chess
- reinforcement-learning
- pytorch
- neural-network
language:
- en
license: mit
---


# Chess Policy Network

A neural network-based chess engine that uses a policy network to predict the best moves.

## Model Details

- **Architecture**: Convolutional ResNet with policy head
- **Input**: 12-channel board representation (piece positions for each color)
- **Output**: 4672 move logits
- **Total Parameters**: 5,827,456

## Architecture Configuration

```python

input_channels: 12

num_res_blocks: 8

filters: 128

policy_channels: 32

num_move_classes: 4672

dropout: 0.1

activation: relu

```

## Training Data

- Trained on high-ELO chess games (minimum rating: 2200+)
- Supervised learning on master games
- Cross-entropy loss with AdamW optimizer
- Cosine annealing learning rate schedule

## Usage

```python

import torch

from huggingface_hub import hf_hub_download

from training.models import PolicyNetwork

from training.utils import encode_board



# Load model

model_path = hf_hub_download("rzhang-7/chesshacks-model", "pytorch_model.bin")

model = PolicyNetwork.from_config(config)

model.load(model_path)

model.eval()



# Get move predictions for a position

board_tensor = encode_board(board)

with torch.no_grad():

    logits = model(board_tensor.unsqueeze(0))



# Convert to legal moves

move_probs = filter_policy_to_legal(logits[0].numpy(), board)

```

## Performance

Evaluate with:
```bash

python training/scripts/evaluate.py --model-path path/to/model.pt --data-dir training/data

```

## License

MIT

## Citation

If you use this model, please cite:

```bibtex

@model{chess_policy_net,

  title={Chess Policy Network},

  author={Chess Hacks},

  year={2024},

  url={https://huggingface.co/rzhang-7/chesshacks-model}

}

```

## Disclaimers

- This model is trained on historical chess games and may reflect biases in those games
- The model is provided as-is without guarantees
- For competitive chess, consider using dedicated engines like Stockfish or Leela Chess Zero