README.md 1.38 KB
Newer Older
1
2
3
# Recurrent Relational Network (RRN)

* Paper link: https://arxiv.org/abs/1711.08028
4
* Author's code repo: https://github.com/rasmusbergpalm/recurrent-relational-networks
5
6
7
8

## Dependencies

* PyTorch 1.0+
9
* DGL 0.5+
10
11
12
13
14
15

## Codes

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

16
## Usage
17

18
- To train the RRN for sudoku, run the following
19
```
20
python3 train_sudoku.py --output_dir out/ --do_train
21
```
22
23
24
25
26
27
28
29
30
31
32
33

- Test with specified aggregation steps:
```
python3 train_sudoku.py --output_dir out/ --do_eval --steps 64
```

  Test accuracy (puzzle-level): 

|       | 32 steps | 64 steps |
| ----- | :------: | :------: |
| Paper | 94.1     | 96.6     |
| DGL   | 95.3     | 98.9     |
34
35
36


- To use the trained model for solving sudoku, follow the example bellow:
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
```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]]
'''
```