Skip to main content

BioTorch is a PyTorch framework specializing in biologically plausible learning algorithms.

Project description

BioTorch

BioTorch is a PyTorch framework specializing in biologically plausible learning algorithms


Build Status PRs Welcome

BioTorch Provides:

🧠   Implementations of layers, models and biologically plausible learning algorithms. It allows to load existing state-of-the-art models, easy creation of custom models and automatic conversion of any existing model.

🧠   A framework to train, evaluate and benchmark different biologically plausible learning algorithms in a selection of datasets. It is focused on the principles of PyTorch design and research reproducibility. Configuration files that include the choice of a fixed seed and deterministic math and CUDA operations are provided.

🧠   A place of colaboration, ideas sharing and discussion.

Methods Supported

Feedback Alignment

Name Mode Official Implementations
Feedback Alignment 'fa' N/A
Direct Feedback Alignment 'dfa' [Torch]
Sign Symmetry ['usf', 'brsf', 'frsf'] [PyTorch]

Metrics Supported

Layer Weight Alignment Layer Weight Norm Ratio

Quick Tour

Create a Feedback Aligment (FA) ResNet-18 model

from biotorch.models.fa import resnet18
model = resnet18()

Create a custom model with uSF layers

import torch.nn.functional as F
from biotorch.layers.usf import Conv2d, Linear

class Model(nn.Module):
  def __init__(self):
    super(Model, self).__init__()
    self.conv1 = Conv2d(in_channels=64, out_channels=128, kernel_size=3)
    self.fc = Linear(in_features=256, out_features=10)

  def forward(self, x):
    out = F.relu(self.conv1(x))
    out = F.avg_pool2d(out, out.size()[3])
    return self.fc(out)
    
model = Model()

Automatically convert AlexNet to use the "frSF" algorithm

from torchvision.models import alexnet
from biotorch.module.biomodule import BioModule

model = BioModule(module=alexnet(), mode='frsf')

Run an experiment on the command line

python benchmark.py --config benchmark_configs/mnist/fa.yaml

If you want the experiment to be reproducible, check that you have specified a seed and the parameter deterministicis set to true in the configuration file yaml. That will apply all the PyTorch reproducibility steps. If you are running your experiment on GPU add the extra environment variable CUBLAS_WORKSPACE_CONFIG.

CUBLAS_WORKSPACE_CONFIG=:4096:8 python benchmark.py --config benchmark_configs/mnist/fa.yaml

Click here to learn more about the configuration file API.

Run an experiment on a Colab Notebook

Installation

We are hosted in PyPI, you can install the library using pip:

pip install biotorch

Or from source:

git clone https://github.com/jsalbert/biotorch.git
cd biotorch
script/setup

Benchmarks

MNIST

CIFAR-10

ImageNet

Contributing

If you want to contribute to the project please read the CONTRIBUTING section. If you found any bug please don't hesitate to comment in the Issues section.

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

biotorch-0.0.9.tar.gz (35.4 MB view details)

Uploaded Source

File details

Details for the file biotorch-0.0.9.tar.gz.

File metadata

  • Download URL: biotorch-0.0.9.tar.gz
  • Upload date:
  • Size: 35.4 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.8.7

File hashes

Hashes for biotorch-0.0.9.tar.gz
Algorithm Hash digest
SHA256 9493fc08b08be388d0213a4bc05c3e2678758bb49319f8343a49db7a7ffb275a
MD5 b5289c560003a71245f064fef047f957
BLAKE2b-256 dd5a07425f80a5c2354ee59c18228e531b16b2dc9c5989c04915fe99d75ccdaf

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