Neural networks powered research of semigroups
Project description
Neural Semigroups
Here we try to learn Cayley tables of semigroups using neural networks. The supposed workflow:
- install the package
- get the data
- build a model
- print a model testing report
More documentation can be found here.
Motivation
This work was inspired by a sudoku solver. A solved Sudoku puzzle is nothing more than a Cayley table of a quasigroup from 9 items with some well-known additional properties. So, one can imagine a puzzle made from a Cayley table of any other magma, e. g. a semigroup, by hiding part of its cells.
There are two major differences between sudoku and puzzles based on semigroups:
-
it's easy to take a glance on a table to understand whether it is a sudoku or not. That's why it was possible to encode numbers in a table cells as colour intensities. Sudoku is a picture, and a semigroup is not. It's difficult to check a Cayley table's associativity with a naked eye;
-
sudoku puzzles are solved by humans for fun and thus catalogued. When solving a sudoku one knows for sure that there is a unique solution. On the contrary, nobody guesses values in a partially filled Cayley table of a semigroup as a form of amuzement. As a result, one can create a puzzle from a full Cayley table of a semigroup but there may be many distinct solutions.
Package Installation
First, get Python 3.8
Then run several commands in a terminal:
git clone git@bitbucket.org:inpefess/neural-semigroups.git
cd neural-semigroups
python -m venv venv
source ./venv/bin/activate
pip install -U pip poetry
poetry install
This could take some time (mostly downloading torch
).
After that you can go to the project's directory and source ./venv/bin/activate
to start a virtual environment there.
Getting Data
This package uses data included into a smallsemi
package for GAP
system. One can download it from the GAP
page.
You can get the data by running a script from a scripts
folder:
cd scripts
./download_smallsemi.sh
Training a Model
Here are several examples of commands to train a model depending on semigroup's cardinality:
python train_denoising_autoencoder.py --cardinality 4 --epochs 100 \
--learning_rate 0.1 --batch_size 32 --train_size 10 --validation_size 10
python train_denoising_autoencoder.py --cardinality 5 --epochs 100 \
--learning_rate 0.01 --batch_size 256 --train_size 100 --validation_size 100
python train_denoising_autoencoder.py --cardinality 6 --epochs 100 \
--learning_rate 0.001 --batch_size 2048 --train_size 1000 --validation_size 100
python train_denoising_autoencoder.py --cardinality 7 --epochs 100 \
--learning_rate 0.001 --batch_size 2048 --train_size 1000 --validation_size 100
Printing a Testing Report
One can print a model quality report using the following command:
python test_model.py --cardinality 4
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for neural_semigroups-0.2.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cb08452c2892ff7e418d2cea525222bf30bb323316094944a09f7f18d53e508e |
|
MD5 | 7341cae0cb01eaeb3a420ba103a2f51f |
|
BLAKE2b-256 | 9f174df53bf100bd94bf0b5bbe45da094fbe4fd17446b403d7aab5b0786b32c7 |