Git Product home page Git Product logo

mdl-hn's Introduction

Minimum Description Length Hopfield Networks

Python 3.11 MIT License arXiv

Code for Minimum Description Length Hopfield Networks paper.

Getting Started

Setup

Note that it has been tested with Python 3.11, but any version after 3.9 should work.

virtualenv venv
source venv/bin/activate
pip install -r requirements.txt  

Before training or running experiments, please make sure to run python prepare_data.py to obtain all the required datasets. Additionally, note that all the scripts below rely on configuration parameters specified in config.py. For instance, the default training of a specific model is performed with the following parameters:

  • DIGITS_TO_TEST = [0, 1, 2, 3, 4]
  • NOISE_TYPE = NoiseType.DISCRETE
  • NOISE_LEVEL_TO_TRAIN = NoiseLevel.LOW
  • NUM_NOISE_VARIATIONS_TO_TRAIN = 5

Which means running on 5 digits (0, 1, 2, 3, 4) with discrete low noise, and having 5 noisy examples per digit.

Training a Modern Hopfield Network

Adapted from eqx-hamux, use the train_mhn.py script to train a Modern Hopfield Network based on the provided configuration.

Training a Minimum Description Length Modern Hopfield Network

You can train using Simulated Annealing either single-processed in train_sa.py or multi-processed using multiple_train_sa.py. The number of workers is determined by NUM_WORKERS in config.py.

Running Experiments

To run the experiments as mentioned in the paper, one should execute run_experiments.py. This script runs both MDL-MHN experiments and MHN experiments. The results are saved in a default directory named results and can be parsed using parse_results.py.

Parsing Results

Parsing results will provide the following statistics and graphs for each dataset you ran against in your results directory. By default, this includes golden, discrete noise, balanced discrete noise, continuous noise, and balanced continuous noise.

  • If show_samples=True:
    • For MHN experiments, two consecutive experiments of MHN will be sampled: one with the correct number of pre-determined clusters for training, and one with an incorrect number.
    • For MDL-MHN experiments, 2 random sub-experiments will be chosen. These samples will be displayed as organized plots along with the golden solution.
  • Distance distributions per noise level: These distributions show the distances from the trained MHN memories for both the golden digits and the training set digits. We can observe the shift in MDL-MHN, where the distances concentrate towards lower values after training. The statistics of mean and median distances per noise level are also provided.
  • MDL-MHN only:
    • A bar plot of clusters in the trained MHNs, along with the golden baseline.
    • A line plot of the number of memories vs. the number of digits tested will also be shown, with color representing the number of training examples and line type representing the level of noise.
    • Accuracies - hard accuracy denotes the number of times MDL-MHN correctly identified the number of clusters, and soft accuracy denotes the number of times it correctly identified the number of clusters or a lower number.

Citation

@article{abudy2023minimum,
      title={Minimum Description Length Hopfield Networks}, 
      author={Matan Abudy and Nur Lan and Emmanuel Chemla and Roni Katzir},
      year={2023},
      eprint={2311.06518},
      archivePrefix={arXiv},
      primaryClass={cs.LG}
}

mdl-hn's People

Contributors

matanabudy avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

mdl-hn's Issues

DEBUG log not informative?

I executed multiple_train_sa_run.py and generated the attached log which shows no difference in the length of the description from start to finish. Perhaps it is due to the fact that I use conda rather than pip to install dependencies. I prefer conda for a variety of reasons and have attached the environment.yml file which, you will notice, has no version constraints so as to solve for the "best" version alignments accodring to conda.

Is the log intended to show no change in the length?

multiple_train_sa_run.log
environment.yml.txt

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.