Initial commit

This commit is contained in:
Charlotte Aten 2025-07-20 14:20:25 -06:00
commit 7d6442d0ac
22 changed files with 2660 additions and 0 deletions

149
.gitignore vendored Normal file
View file

@ -0,0 +1,149 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
pip-wheel-metadata/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
# Translations
*.mo
*.pot
# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal
# Flask stuff:
instance/
.webassets-cache
# Scrapy stuff:
.scrapy
# Sphinx documentation
docs/_build/
# PyBuilder
target/
# Jupyter Notebook
.ipynb_checkpoints
# IPython
profile_default/
ipython_config.py
# pyenv
.python-version
# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/
# Celery stuff
celerybeat-schedule
celerybeat.pid
# SageMath parsed files
*.sage.py
# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/
# Spyder project settings
.spyderproject
.spyproject
# Rope project settings
.ropeproject
# mkdocs documentation
/site
# mypy
.mypy_cache/
.dmypy.json
dmypy.json
# Pyre type checker
.pyre/
# Emacs
.dir-locals.el
.dir-locals.el~
# PyCharm
.idea/
# Mac OS
.DS_Store
# Stored Trees, Dominions, and Homomorphisms
Tree0/
Tree1/
Tree2/
Tree3/
test2.py
# Stored trees and dominions
output/

21
LICENSE Normal file
View file

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2025 Charlotte Aten
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

80
README.md Normal file
View file

@ -0,0 +1,80 @@
# Discrete neural nets
This repository contains code and examples of implementing the notion of a
discrete neural net and polymorphic learning in Python. For more information on
these notions, see
[the corresponding preprint](https://arxiv.org/abs/2308.00677) on the arXiv.
### Project structure
The scripts that define basic components of the system are in the `src` folder.
These are:
* `arithmetic_operations.py`: Definitions of arithmetic operations modulo some
positive integer. These are used to test the basic functionality of the
`NeuralNet` class.
* `dominion.py`: Tools for creating dominions, a combinatorial object used in
the definition of the dominion polymorphisms in `polymorphisms.py`.
* `dominion_setup.py`: Utilities for creating files of trees, dominions with
those trees as constraint graphs, and the data for the corresponding
polymorphisms.
* `graphs.py`: Utilities for creating and storing simple graphs, including
randomly-generated trees.
* `mnist_training_binary.py`: Describes how to manufacture binary relations
from the MNIST dataset which can be passed as arguments into the
polymorphisms in `polymorphisms.py`.
* `neural_net.py`: Definition of the `NeuralNet` class, including feeding
forward and learning.
* `operations.py`: Definitions pertaining to the `Operation` class, whose
objects are to be thought of as operations in the sense of universal
algebra/model theory.
* `polymorphisms.py`: Definitions of polymorphisms of the Hamming graph, as
well as a neighbor function for the learning algorithm implemented in
`neural_net.py`.
* `random_neural_net.py`: Tools for making `NeuralNet` objects with