Skip to main content

Python implementation of reverse engineering neural networks

Project description

reverse-engineering-py

DOI

Overview

This repository is a Python implementation of takuyaisomura/reverse_engineering, which provides code for research papers on reverse engineering neural networks.

Copyright

  • Original code: (C) 2021 Takuya Isomura (RIKEN Center for Brain Science)
  • Python implementation: (C) 2024 Araya Inc.

Papers

This repository is based on the following papers:

  1. "Reverse-engineering neural networks to characterize their cost functions" Takuya Isomura, Karl Friston Neural Computation 32(11), 2085–2121 (2020). https://doi.org/10.1162/neco_a_01315

  2. "Canonical neural networks perform active inference" Takuya Isomura, Hideaki Shimazaki, Karl Friston Communications Biology 5, 55 (2022). https://doi.org/10.1038/s42003-021-02994-2

  3. "Experimental validation of the free-energy principle with in vitro neural networks" Takuya Isomura, Kiyoshi Kotani, Yasuhiko Jimbo, Karl Friston Nature Communications 14, 4547 (2023). https://doi.org/10.1038/s41467-023-40141-z

Example Notebooks

The following Colab notebooks provide explanations and usage examples:

BSS Example
BSS

Blind Source Separation (Paper 1 & 3)

Maze Example
Maze

Maze Navigation (Paper 2)

In vitro BSS Example
In vitro BSS

In vitro Neural Network Analysis (Paper 3)

Installation

It is recommended to use a virtual environment for installation. This project has been tested with Python 3.10.

  1. Create and activate a virtual environment
python -m venv venv
source venv/bin/activate  # On Windows, use venv\Scripts\activate.ps1 or activate.bat
  1. Install:
  • Option 1: Install from PyPI (core library only, without examples)
pip install reverse-engineering-py
  • Option 2: Clone the repository (includes examples and full source code)
git clone https://github.com/takuyaisomura/reverse-engineering-py.git
cd reverse-engineering-py
pip install -e .

Main contents

This repository contains:

  • Free energy agent class (pomdp.py)
  • Functions for analyzing invitro neuronal response data (analysis.py)
  • Example code to reproduce main results from each paper (example/)
reverse_engineering/
├── pomdp.py             # Free energy agent class for simulation
├── analysis.py          # Functions for analyzing invitro neuronal response data
└── utils/
   └── variable_conversion.py  # Functions to convert between NN and Bayesian variables

example/                 # Example code to reproduce main results from each paper
├── bss/                 # Paper 1 (and 3)
│   └── main.py          # Runs blind source separation simulation and outputs figures
├── maze/                # Paper 2
│   └── main.py          # Runs maze simulation and outputs figures
└── invitro_bss/         # Paper 3
    ├── data/            # Neuronal response data
    └── main.py          # Analyzes data using analysis.py and outputs figures/videos

example/bss

This example demonstrates blind source separation (BSS) by using the free-energy principle. The implementation is based on the Paper 1 and Paper 3.

python example/bss/main.py
example bss output

example/maze

This example demonstrates maze navigation by using the free-energy principle. The implementation is based on the Paper 2.

python example/maze/main.py

example maze output

example/invitro_bss

This example analyzes data from invitro neuronal networks performing blind source separation (BSS) using the reverse engineering approach. The implementation is based on the Paper 3.

python example/invitro_bss/main.py
example invitro-bss output

License

This project is covered under the GNU General Public License v3.0.

Feedback and Contributing

All feedback including questions, bug reports, and feature improvement suggestions are welcome through GitHub Issues. Pull requests are also appreciated.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

reverse_engineering_py-0.1.2.tar.gz (50.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

reverse_engineering_py-0.1.2-py3-none-any.whl (36.3 kB view details)

Uploaded Python 3

File details

Details for the file reverse_engineering_py-0.1.2.tar.gz.

File metadata

  • Download URL: reverse_engineering_py-0.1.2.tar.gz
  • Upload date:
  • Size: 50.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.13

File hashes

Hashes for reverse_engineering_py-0.1.2.tar.gz
Algorithm Hash digest
SHA256 fb6a34c7558b8c7f048a38a2f235f850dc957a16167ede8a897b18416ac67347
MD5 ed3f7561bd498f2bf86fece73809ddba
BLAKE2b-256 8b1ca3e6661faef6ae364f2f41ed912900fe8af941f4a9656164fe9a316c16a8

See more details on using hashes here.

File details

Details for the file reverse_engineering_py-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for reverse_engineering_py-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 2927f088047f19025c528638c29135c5f0c1d074c74c27974f953ce2cf7528be
MD5 e68d8a9135103dca65ad0791db6fc17a
BLAKE2b-256 19bb028f90897d00aa2443a4832d622d0581e20ff5ec9372de6be681ac65387d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page