All Projects → ashutosh1919 → neuro-symbolic-sudoku-solver

ashutosh1919 / neuro-symbolic-sudoku-solver

Licence: Apache-2.0 license
⚙️ Solving sudoku using Deep Reinforcement learning in combination with powerful symbolic representations.

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to neuro-symbolic-sudoku-solver

Resolvedor-de-Sudoku
Resolver Sudoku de genina.com
Stars: ✭ 17 (-71.67%)
Mutual labels:  sudoku-solver, sudoku
sudoku-solver
A simple sudoku solver
Stars: ✭ 16 (-73.33%)
Mutual labels:  sudoku-solver, sudoku
sudoku
A very fast Java Sudoku library implementation along with a command line client
Stars: ✭ 15 (-75%)
Mutual labels:  sudoku-solver, sudoku
python-sudoku-generator-solver
Python based sudoku generator that can create unique Sudoku board based on 4 difficulty levels. This code also includes a brute force sudoku solver that is capable of solving even the most difficult sudoku puzzles!
Stars: ✭ 58 (-3.33%)
Mutual labels:  sudoku-solver, sudoku
Sudoku-Solver
🎯 This Python-based Sudoku Solver utilizes the PyGame Library and Backtracking Algorithm to visualize and solve Sudoku puzzles efficiently. With its intuitive interface, users can input and interact with the Sudoku board, allowing for a seamless solving experience.
Stars: ✭ 51 (-15%)
Mutual labels:  sudoku-solver, sudoku
datafsm
Machine Learning Finite State Machine Models from Data with Genetic Algorithms
Stars: ✭ 14 (-76.67%)
Mutual labels:  explainable-ai
pyradox
State of the Art Neural Networks for Deep Learning
Stars: ✭ 61 (+1.67%)
Mutual labels:  artificial-neural-networks
Udacity
This repo includes all the projects I have finished in the Udacity Nanodegree programs
Stars: ✭ 57 (-5%)
Mutual labels:  sudoku-solver
sudoku
Multiplayer concurrent sudoku. The winner is the player who fills the last cell correctly.
Stars: ✭ 15 (-75%)
Mutual labels:  sudoku
prometheus-spec
Censorship-resistant trustless protocols for smart contract, generic & high-load computing & machine learning on top of Bitcoin
Stars: ✭ 24 (-60%)
Mutual labels:  artificial-neural-networks
Dino-AI
An AI to teach Google Chrome's dinosaur to jump obstacles.
Stars: ✭ 15 (-75%)
Mutual labels:  artificial-neural-networks
mindsdb server
MindsDB server allows you to consume and expose MindsDB workflows, through http.
Stars: ✭ 3 (-95%)
Mutual labels:  explainable-ai
self critical vqa
Code for NeurIPS 2019 paper ``Self-Critical Reasoning for Robust Visual Question Answering''
Stars: ✭ 39 (-35%)
Mutual labels:  explainable-ai
XAIatERUM2020
Workshop: Explanation and exploration of machine learning models with R and DALEX at eRum 2020
Stars: ✭ 52 (-13.33%)
Mutual labels:  explainable-ai
python-neuron
Neuron class provides LNU, QNU, RBF, MLP, MLP-ELM neurons
Stars: ✭ 38 (-36.67%)
Mutual labels:  artificial-neural-networks
Xtreme-Vision
A High Level Python Library to empower students, developers to build applications and systems enabled with computer vision capabilities.
Stars: ✭ 77 (+28.33%)
Mutual labels:  artificial-neural-networks
pyCeterisParibus
Python library for Ceteris Paribus Plots (What-if plots)
Stars: ✭ 19 (-68.33%)
Mutual labels:  explainable-ai
compv
Insanely fast Open Source Computer Vision library for ARM and x86 devices (Up to #50 times faster than OpenCV)
Stars: ✭ 155 (+158.33%)
Mutual labels:  artificial-neural-networks
pyERA
Python implementation of the Epigenetic Robotic Architecture (ERA). It includes standalone classes for Self-Organizing Maps (SOM) and Hebbian Networks.
Stars: ✭ 68 (+13.33%)
Mutual labels:  artificial-neural-networks
grilops
a GRId LOgic Puzzle Solver library
Stars: ✭ 29 (-51.67%)
Mutual labels:  sudoku-solver

Neuro-Symbolic Sudoku Solver

PyTorch implementation for the Neuro-Symbolic Sudoku Solver leveraging the power of Neural Logic Machines (NLM). Please note that this is not an officially supported Google product. This project is a direct application of work done as part of original NLM project. We have applied NLM concept to solve more complex (Solving Sudoku) problems. We have also described the internal workings in Medium Blog.

Star us on GitHub — it helps!

Neural Logic Machine (NLM) is a neural-symbolic architecture for both inductive learning and logic reasoning. NLMs use tensors to represent logic predicates. This is done by grounding the predicate as True or False over a fixed set of objects. Based on the tensor representation, rules are implemented as neural operators that can be applied over the premise tensors and generate conclusion tensors. Learn more about NLM from the paper.

Predicate Logic

We have used below boolean predicates as inputs to NLM architecture:

  1. isRow(r, num): Does number num present in row r inside Sudoku grid?
  2. isColumn(c, num): Does number num present in column c inside Sudoku grid?
  3. isSubMat(r, c, num): Does number num present in 3x3 sub-matrix starting with row r and column c.

Note here that isRow and isColumn are binary predicates and isSubMat is ternary predicate. We have stacked the results of isRow and isColumn and inputted as binary predicate.

The core architecture of the model contains deep reinforcement learning leveraging representation power of first order logic predicates.

Prerequisites

  • Python 3.x
  • PyTorch 0.4.0
  • Jacinle. We use the version ed90c3a for this repo.
  • Other required python packages specified by requirements.txt. See the Installation.

Installation

Clone this repository:

git clone https://github.com/ashutosh1919/neuro-symbolic-sudoku-solver.git --recursive

Install Jacinle included as a submodule. You need to add the bin path to your global PATH environment variable:

export PATH=<path_to_neural_logic_machines>/third_party/Jacinle/bin:$PATH

Create a conda environment for NLM, and install the requirements. This includes the required python packages from both Jacinle and NLM. Most of the required packages have been included in the built-in anaconda package:

conda create -n nlm anaconda
conda install pytorch torchvision -c pytorch

Usage

This repo is extension of original NLM repository. We haven't removed the codebase of problems solved in the base repository but we are only maintaining the Sudoku codebase in this repository.

Below is the file structure for the code we have added to original repository to understand things better.

The code in difflogic/envs/sudoku contains information about the environment for reinforcement learning. grid.py selects dataset randomly from 1 Million Sudoku Dataset from Kaggle. grid_env.py creates reinforcement learning environment which can perform actions.

The code in scripts/sudoku/learn_policy.py trains the model whereas scripts/sudoku/inference.py generates prediction from trained model.

We also provide code to download dataset and pre-trained models.

Taking the Sudoku task as an example.

# To download dataset and pre-trained models
$ jac-run scripts/sudoku/download_data_mode.py

# To train the model:
$ jac-run scripts/sudoku/learn_policy.py --task sudoku --dump-dir models

# To infer the model:
$ jac-run scripts/sudoku/inference.py --task sudoku --load-checkpoint models/sudoku.pth

Below is the sample output that you should get after running inference.py where the program will generate a problem Sudoku grid and NLM model will solve it.

We have trained model with tuning with different parameters and we got below results.

Contributors

Thanks goes to these wonderful people (emoji key):


Ashutosh Hathidara

💻 🤔 🚧 🎨 📖 💬 🔬

Lalit Pandey

💻 📖 🤔 🚧 🎨 💬 🔬

This project follows the all-contributors specification. Contributions of any kind welcome!

References

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].