GNU General Public License v3.0

项目介绍

Kyubyong/sudoku 是一个托管在 GitHub 上的开源项目,主要使用 Python 编写,采用 GNU General Public License v3.0 许可证,目前获得 869 个 Star、129 次 Fork。

仓库全名
Kyubyong/sudoku
开源许可证
GNU General Public License v3.0
Star 数
869
Fork 数
129
未关闭 Issue
3

README 摘要

Can Convolutional Neural Networks Crack Sudoku Puzzles? Sudoku is a popular number puzzle that requires you to fill blanks in a 9X9 grid with digits so that each column, each row, and each of the nine 3×3 subgrids contains all of the digits from 1 to 9. There have been various approaches to solving that, including computational ones. In this project, I show that simple convolutional neural networks have the…

完整内容见 GitHub 原始 README 或本页 。

常见问题

sudoku 用什么语言开发?

主要使用 Python 编写,采用 GNU General Public License v3.0 许可证,目前有 869 个 Star。

sudoku 可以免费商用吗?

仓库标注的许可证为 GNU General Public License v3.0,商用前请先阅读仓库 LICENSE 文件确认授权范围。

如何获取 sudoku 的源码?

可以直接克隆仓库:git clone https://github.com/Kyubyong/sudoku.git,默认分支为 master;安装与运行步骤见仓库 README。

sudoku 最近还在维护吗?

仓库最近一次更新为 2023年2月17日,当前有 3 个未关闭 Issue;Star 数为 869,可作为社区活跃度的参考。

关于

Can Neural Networks Crack Sudoku?

描述取自 GitHub 官方 API,中文内容由 GitRead 中文社区 编辑团队整理。

简要分析

热度分
1147
价值分
561
活跃状态
活跃

语言占比

Python

README

Can Convolutional Neural Networks Crack Sudoku Puzzles?

Sudoku is a popular number puzzle that requires you to fill blanks in a 9X9 grid with digits so that each column, each row, and each of the nine 3×3 subgrids contains all of the digits from 1 to 9. There have been various approaches to solving that, including computational ones. In this project, I show that simple convolutional neural networks have the potential to crack Sudoku without any rule-based postprocessing.

Requirements

  • NumPy >= 1.11.1
  • TensorFlow == 1.1

Background

Dataset

  • 1M games were generated using generate_sudoku.py for training. I’ve uploaded them on the Kaggle dataset storage. They are available here.
  • 30 authentic games were collected from http://1sudoku.com.

Model description

  • 10 blocks of convolution layers of kernel size 3.

File description

  • generate_sudoku.py create sudoku games. You don’t have to run this. Instead, download pre-generated games.
  • hyperparams.py includes all adjustable hyper parameters.
  • data_load.py loads data and put them in queues so multiple mini-bach data are generated in parallel.
  • modules.py contains some wrapper functions.
  • train.py is for training.
  • test.py is for test.

Training

Test

  • Run python test.py.

Evaluation Metric

Accuracy is defined as

Number of blanks where the prediction matched the solution / Number of blanks.

Results

After a couple of hours of training, the training curve seems to reach the optimum.

I use a simple trick in inference. Instead of cracking the whole blanks all at once, I fill in a single blank where the prediction is the most probable among the all predictions. As can be seen below, my model scored 0.86 in accuracy. Details are available in the `results` folder.
Level Accuracy (#correct/#blanks=acc.)
Easy 47/47 = 1.00
Easy 45/45 = 1.00
Easy 47/47 = 1.00
Easy 45/45 = 1.00
Easy 47/47 = 1.00
Easy 46/46 = 1.00
Medium 33/53 = 0.62
Medium 55/55 = 1.00
Medium 55/55 = 1.00
Medium 53/53 = 1.00
Medium 33/52 = 0.63
Medium 51/56 = 0.91
Hard 29/56 = 0.52
Hard 55/55 = 1.00
Hard 27/55 = 0.49
Hard 57/57 = 1.00
Hard 35/55 = 0.64
Hard 15/56 = 0.27
Expert 56/56 = 1.00
Expert 55/55 = 1.00
Expert 54/54 = 1.00
Expert 55/55 = 1.00
Expert 17/55 = 0.31
Expert 54/54 = 1.00
Evil 50/50 = 1.00
Evil 50/50 = 1.00
Evil 49/49 = 1.00
Evil 28/53 = 0.53
Evil 51/51 = 1.00
Evil 51/51 = 1.00
Total Accuracy 1345/1568 = 0.86

References

If you use this code for research, please cite:

@misc{sudoku2018,
  author = {Park, Kyubyong},
  title = {Can Convolutional Neural Networks Crack Sudoku Puzzles?},
  year = {2018},
  publisher = {GitHub},
  journal = {GitHub repository},
  howpublished = {\url{https://github.com/Kyubyong/sudoku}}
}

Papers that referenced this repository

评论

暂无评论