Package: biotorch
BioTorch is a PyTorch framework specializing in biologically plausible learning algorithmsBioTorch Provides:🧠   Implementations of layers, models and biologically-motivated learning algorithms. It allows to load existing state-of-the-art models, easy creation of custom models and automatic conversion of existing models.🧠   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 SupportedFeedback AlignmentNameModeOfficial ImplementationsFeedback Alignment'fa'N/ADirect Feedback Alignment'dfa'[Torch]Sign Symmetry['usf', 'brsf', 'frsf'][PyTorch]Metrics SupportedLayer Weight AlignmentLayer Weight Norm RatioQuick TourCreate a Feedback Aligment (FA) ResNet-18 modelfrombiotorch.models.faimportresnet18model=resnet18()Create a custom model with uSF layersimporttorch.nn.functionalasFfrombiotorch.layers.usfimportConv2d,LinearclassModel(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)defforward(self,x):out=F.relu(self.conv1(x))out=F.avg_pool2d(out,out.size()[3])returnself.fc(out)model=Model()Automatically convert AlexNet to use the "frSF" algorithmfromtorchvision.modelsimportalexnetfrombiotorch.module.biomoduleimportBioModulemodel=BioModule(module=alexnet(),mode='frsf')Run an experiment on the command linepythonbenchmark.py--configbenchmark_configs/mnist/fa.yamlIf you want the experiment to be reproducible, check that you have specified a seed and the parameterdeterministicis set to true in the configuration file yaml. That will apply all thePyTorch reproducibility steps.
If you are running your experiment on GPU add the extra environment variableCUBLAS_WORKSPACE_CONFIG.CUBLAS_WORKSPACE_CONFIG=:4096:8pythonbenchmark.py--configbenchmark_configs/mnist/fa.yamlClickhereto learn more about the configuration file API.Run an experiment on a Colab NotebookBenchmark with configuration fileBenchmark with custom modelPlot alignment metricsInstallationWe are hosted inPyPI, you can install the library using pip:pipinstallbiotorchOr from source:gitclonehttps://github.com/jsalbert/biotorch.gitcdbiotorch
script/setupBenchmarksMNISTCIFAR-10ImageNetContributingIf you want to contribute to the project please read theCONTRIBUTINGsection. If you found any bug please don't hesitate to comment in theIssuessection.Related paper: Benchmarking the Accuracy and Robustness of Feedback Alignment AlgorithmsAlbert Jiménez Sanfiz, Mohamed AkroutBackpropagation is the default algorithm for training deep neural networks due to its simplicity, efficiency and high convergence rate. However, its requirements make it impossible to be implemented in a human brain. In recent years, more biologically plausible learning methods have been proposed. Some of these methods can match backpropagation accuracy, and simultaneously provide other extra benefits such as faster training on specialized hardware (e.g., ASICs) or higher robustness against adversarial attacks. While the interest in the field is growing, there is a necessity for open-source libraries and toolkits to foster research and benchmark algorithms. In this paper, we present BioTorch, a software framework to create, train, and benchmark biologically motivated neural networks. In addition, we investigate the performance of several feedback alignment methods proposed in the literature, thereby unveiling the importance of the forward and backward weight initialization and optimizer choice. Finally, we provide a novel robustness study of these methods against state-of-the-art white and black-box adversarial attacks.Preprint here, feedback welcome!Contact:albert@aip.aiIf you use our code in your research, you can cite our paper:@misc{sanfiz2021benchmarking,
      title={Benchmarking the Accuracy and Robustness of Feedback Alignment Algorithms},
      author={Albert Jiménez Sanfiz and Mohamed Akrout},
      year={2021},
      eprint={2108.13446},
      archivePrefix={arXiv},
      primaryClass={cs.LG}
}