README.md 1.18 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# Recurrent Relational Network (RRN)

* Paper link: https://arxiv.org/abs/1711.08028
* Author's code repo: https://github.com/rasmusbergpalm/recurrent-relational-networks.git

## Dependencies

* PyTorch 1.0+
* DGL 0.3+

## Codes

The folder contains a DGL implementation of Recurrent Relational Network, and its
application on sudoku solving.

16
## Usage
17

18
- To train the RNN for sudoku, run the following
19
20
21
22
```
python3 train_sudoku.py --output_dir out/ --do_train --do_eval
```
Test accuracy (puzzle-level): 96.08% (paper: 96.6%)
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


- To use the trained model for solving sudoku, follow the example bellow:
```python
from sudoku_solver import solve_sudoku

q = [[9, 7, 0, 4, 0, 2, 0, 5, 3],
     [0, 4, 6, 0, 9, 0, 0, 0, 0],
     [0, 0, 8, 6, 0, 1, 4, 0, 7],
     [0, 0, 0, 0, 0, 3, 5, 0, 0],
     [7, 6, 0, 0, 0, 0, 0, 8, 2],
     [0, 0, 2, 8, 0, 0, 0, 0, 0],
     [6, 0, 5, 1, 0, 7, 2, 0, 0],
     [0, 0, 0, 0, 6, 0, 7, 4, 0],
     [4, 3, 0, 2, 0, 9, 0, 6, 1]
    ]

answer = solve_sudoku(q)
print(answer)
'''
[[9 7 1 4 8 2 6 5 3]
 [3 4 6 7 9 5 1 2 8]
 [2 5 8 6 3 1 4 9 7]
 [8 1 4 9 2 3 5 7 6]
 [7 6 3 5 1 4 9 8 2]
 [5 9 2 8 7 6 3 1 4]
 [6 8 5 1 4 7 2 3 9]
 [1 2 9 3 6 8 7 4 5]
 [4 3 7 2 5 9 8 6 1]]
'''
```