diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 3b800f0b8..89a7a70b8 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -21,11 +21,10 @@ updates: - "minor" - "patch" ignore: - # torch and torchvision are pinned to exact versions served from the - # custom CUDA wheel index declared in pyproject.toml, and the two must - # move together. Routine version bumps here would break that pairing or - # silently pull the plain PyPI build instead, so they are upgraded by - # hand. These conditions cover version updates only; Dependabot security + # torch and torchvision are locked (poetry.lock) to builds from the CUDA + # wheel index declared in pyproject.toml, and docs/requirements.txt pins + # the matching CPU builds. The two must move together, and a routine bump + # could pull the plain PyPI build instead, so they are upgraded by hand. These conditions cover version updates only; Dependabot security # alerts for torch and torchvision still come through. - dependency-name: "torch" update-types: @@ -53,3 +52,12 @@ updates: github-actions: patterns: - "*" + + # Base image of the Dockerfile. + - package-ecosystem: "docker" + directory: "/" + schedule: + interval: "weekly" + day: "monday" + labels: + - "dependencies" diff --git a/.github/workflows/black.yml b/.github/workflows/black.yml index c2e70ed91..8db2090e4 100644 --- a/.github/workflows/black.yml +++ b/.github/workflows/black.yml @@ -1,14 +1,34 @@ +# Formatting and import-order check. Branch protection on master requires the job named "lint"; keep that name. name: Black Formater -on: [push, pull_request] +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] permissions: contents: read +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + jobs: lint: runs-on: ubuntu-latest steps: - uses: actions/checkout@v7 - uses: actions/setup-python@v7 - - uses: psf/black@stable \ No newline at end of file + with: + python-version: "3.13" + # Use the black and isort versions pinned in poetry.lock, so CI and local + # formatting agree. + - name: Check formatting with black + run: | + version=$(python -c "import tomllib; print(next(p['version'] for p in tomllib.load(open('poetry.lock','rb'))['package'] if p['name']=='black'))") + pipx run "black==${version}" --check --diff . + - name: Check import order with isort + run: | + version=$(python -c "import tomllib; print(next(p['version'] for p in tomllib.load(open('poetry.lock','rb'))['package'] if p['name']=='isort'))") + pipx run "isort==${version}" --check-only --diff . diff --git a/.github/workflows/python-app.yml b/.github/workflows/python-app.yml index 18d293846..148d289e0 100644 --- a/.github/workflows/python-app.yml +++ b/.github/workflows/python-app.yml @@ -1,6 +1,4 @@ -# This workflow will install Python dependencies, run tests and lint with a single version of Python -# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions - +# Tests. Branch protection on master requires the job named "build"; keep that name. name: BindsNET build status on: @@ -8,39 +6,53 @@ on: branches: [ master ] pull_request: branches: [ master ] + workflow_dispatch: permissions: contents: read +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +env: + POETRY_VERSION: "2.4.3" + jobs: build: - + name: build runs-on: ubuntu-latest - steps: - uses: actions/checkout@v7 - - name: Set up Python 3.13 - uses: actions/setup-python@v7 + - name: Install Poetry + run: pipx install "poetry==${POETRY_VERSION}" + - uses: actions/setup-python@v7 with: - python-version: 3.13 + python-version: "3.13" + cache: poetry + - name: Install dependencies + run: poetry install + - name: Lint with flake8 (syntax errors and undefined names) + run: pipx run flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics + - name: Test with pytest + run: poetry run pytest + + # The other supported Python versions (pyproject.toml: >=3.11,<3.14). + test: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + python-version: ["3.11", "3.12"] + steps: + - uses: actions/checkout@v7 - name: Install Poetry - env: - POETRY_VERSION: 2.4.3 - run: | - curl -sSL https://install.python-poetry.org | python - -y &&\ - poetry config virtualenvs.create false + run: pipx install "poetry==${POETRY_VERSION}" + - uses: actions/setup-python@v7 + with: + python-version: ${{ matrix.python-version }} + cache: poetry - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install flake8 pytest - # if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - poetry install - - name: Lint with flake8 - run: | - # stop the build if there are Python syntax errors or undefined names - flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics - # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide - # flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics + run: poetry install - name: Test with pytest - run: | - pytest + run: poetry run pytest diff --git a/.github/workflows/pythonpackage.yml b/.github/workflows/pythonpackage.yml deleted file mode 100644 index 689080d42..000000000 --- a/.github/workflows/pythonpackage.yml +++ /dev/null @@ -1,36 +0,0 @@ -name: Python package - -on: [push] - -permissions: - contents: read - -jobs: - build: - - runs-on: ubuntu-latest - strategy: - max-parallel: 4 - matrix: - python-version: ["3.11", "3.12", "3.13"] - - steps: - - uses: actions/checkout@v7 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v7 - with: - python-version: ${{ matrix.python-version }} - - name: Install Poetry - env: - POETRY_VERSION: 2.4.3 - run: | - curl -sSL https://install.python-poetry.org | python - -y - - name: Install dependencies - run: | - poetry install - - name: Format with black - run: | - poetry run black . - - name: Test with pytest - run: | - poetry run pytest diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 000000000..ff481b9bc --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,15 @@ +# Installed by `poetry run pre-commit install` (see CONTRIBUTING.md). +# Uses the isort and black installed by Poetry, so the version always matches poetry.lock and CI. +repos: + - repo: local + hooks: + - id: isort + name: isort + entry: poetry run isort + language: system + types: [python] + - id: black + name: black + entry: poetry run black + language: system + types: [python] diff --git a/.readthedocs.yaml b/.readthedocs.yaml index 5326b936e..cf020d299 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -1,39 +1,25 @@ -# .readthedocs.yaml # Read the Docs configuration file -# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details - -# Required +# https://docs.readthedocs.io/en/stable/config-file/v2.html version: 2 -# Set the version of Python and other tools you might need build: - os: ubuntu-22.04 + os: ubuntu-24.04 tools: - python: "3.11" + python: "3.13" -# Build documentation in the docs/ directory with Sphinx sphinx: builder: html configuration: docs/source/conf.py - + formats: - epub - pdf -# We recommend specifying your dependencies to enable reproducible builds: -# https://docs.readthedocs.io/en/stable/guides/reproducible-builds.html +# autodoc imports bindsnet, so the package and its dependencies must be installed. +# docs/requirements.txt installs the CPU build of torch first (much smaller than the +# CUDA build); installing the package then keeps that torch. python: install: - requirements: docs/requirements.txt - method: pip - path: docs/ - # extra_requirements: - # - docs - -# python: - # version: 3.8 - # install: - # - method: pip - # path: . - # - requirements: docs/requirements.txt - # system_packages: False \ No newline at end of file + path: . diff --git a/.vscode/launch.json b/.vscode/launch.json deleted file mode 100644 index 91a770239..000000000 --- a/.vscode/launch.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - // Use IntelliSense to learn about possible attributes. - // Hover to view descriptions of existing attributes. - // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 - "version": "0.2.0", - "configurations": [ - { - "name": "Python: Current File", - "type": "python", - "request": "launch", - "program": "${file}", - "python": "/home/hananel/miniconda3/envs/bindsNET/bin/python", - "console": "integratedTerminal", - "justMyCode": false - } - ] -} \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 5f254749e..8a6708bf5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,42 @@ see the [GitHub releases / tags](https://github.com/BindsNET/bindsnet/releases). ## [Unreleased] +### Fixed +- API reference on Read the Docs was empty: the build never installed `bindsnet`, so + every `automodule` failed to import (`No module named 'matplotlib'`), and + `docs/pyproject.toml` downgraded Sphinx to 7.2.6. `.readthedocs.yaml` now installs a + CPU build of torch and the package (Python 3.13, Ubuntu 24.04); + `docs/pyproject.toml` removed. +- The docs build has no warnings (was 48 on Read the Docs, 53 with the package + installed): docstring markup fixed in `topology.py`, `topology_features.py`, + `monitors.py`, `learning.py`, `nodes.py`, `encoders.py`, `plotting.py`, + `conversion.py`, `davis.py`, `preprocess.py`, `cue_reward.py`, `dot_simulator.py`; + broken links in `index.rst` and the guide; `conf.py` takes the version from the + installed package. Docstring text only; no code changed. +- API reference now includes `learning.MCC_learning`, `network.topology_features`, + `environment.cue_reward`, `environment.dot_simulator` and + `analysis.dotTrace_plotter`, which were missing. + +### Changed +- CI: one test workflow (`python-app.yml`: job `build` on Python 3.13 plus a 3.11/3.12 + matrix, Poetry 2.4.3 with dependency caching, superseded runs cancelled); + `pythonpackage.yml` removed (it ran on every push to every branch and its + `black .` step reformatted instead of checking). `black.yml` checks with the black + version from `poetry.lock` instead of the floating `psf/black@stable`. +- Dependabot also updates the Dockerfile base image. +- Imports sorted with isort (settings already in `pyproject.toml`, never applied; 20 + files, import order only). `black.yml` and the pre-commit hook now also check isort. +- Removed from git: 59 TensorBoard event files under `logs/` (test output; `logs/*` + was already in `.gitignore`), `.vscode/launch.json` (a local interpreter path) and + `docs/Makefile.old`, `docs/make.bat.old`. +- Added `.pre-commit-config.yaml` (black from Poetry); `CONTRIBUTING.md` already told + contributors to install pre-commit, but there was no configuration. +- `[tool.black] target-version` is `py311`-`py313` (was `py38`); no file changes. +- README: dead link to Markram et al. (1997) replaced with its DOI; RL example named + correctly (Breakout, not Space Invaders); OpenAI gym text replaced (Gymnasium and + ale-py install with BindsNET); benchmark marked as from the 2018 paper; PyPI badge + refreshes hourly. + ## [0.3.4 (PyPI)] - 2026-09-16 First PyPI upload since 0.2.7. It is built from the `master` branch on this date, not diff --git a/README.md b/README.md index d812177d5..1d8ed5c12 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@

-A Python package used for simulating spiking neural networks (SNNs) on CPUs or GPUs using [PyTorch](http://pytorch.org/) `Tensor` functionality. +A Python package used for simulating spiking neural networks (SNNs) on CPUs or GPUs using [PyTorch](https://pytorch.org/) `Tensor` functionality. BindsNET is a spiking neural network simulation library geared towards the development of biologically inspired algorithms for machine learning. @@ -9,7 +9,7 @@ This package is used as part of ongoing research on applying SNNs, machine learn Check out the [BindsNET examples](https://github.com/BindsNET/bindsnet/tree/master/examples) for a collection of experiments, functions for the analysis of results, plots of experiment outcomes, and more. Documentation for the package can be found [here](https://bindsnet-docs.readthedocs.io). -[![PyPI](https://img.shields.io/pypi/v/bindsnet.svg)](https://pypi.org/project/bindsnet/) +[![PyPI](https://img.shields.io/pypi/v/bindsnet.svg?cacheSeconds=3600)](https://pypi.org/project/bindsnet/) [![Build Status](https://github.com/BindsNET/bindsnet/actions/workflows/python-app.yml/badge.svg?branch=master)](https://github.com/BindsNET/bindsnet/actions/workflows/python-app.yml) [![CodeQL](https://github.com/BindsNET/bindsnet/actions/workflows/github-code-scanning/codeql/badge.svg)](https://github.com/BindsNET/bindsnet/actions/workflows/github-code-scanning/codeql) [![Documentation Status](https://readthedocs.org/projects/bindsnet-docs/badge/?version=latest)](https://bindsnet-docs.readthedocs.io/?badge=latest) @@ -57,7 +57,7 @@ Or, to install in editable mode (allows modification of package without re-insta pip install -e . ``` -To install the packages necessary to interface with the [OpenAI gym RL environments library](https://github.com/openai/gym), follow their instructions for installing the packages needed to run the RL environments simulator (on Linux / MacOS). +The reinforcement-learning environments use [Gymnasium](https://gymnasium.farama.org/) with the Arcade Learning Environment ([ale-py](https://github.com/Farama-Foundation/Arcade-Learning-Environment)); both are installed with BindsNET. ### Using Docker The `Dockerfile` installs BindsNET with the dependency versions pinned in `poetry.lock`. @@ -104,8 +104,6 @@ Issue the following to run the tests: python -m pytest test/ ``` -Some tests will fail if Open AI `gym` is not installed on your machine. - ## Datasets BindsNET ships no third-party datasets; its loaders fetch them from upstream sources. @@ -122,17 +120,17 @@ Hazan et al. 2018 scaling benchmark). ## Background -The simulation of biologically plausible spiking neuron dynamics can be challenging. It is typically done by solving ordinary differential equations (ODEs) which describe said dynamics. PyTorch does not explicitly support the solution of differential equations (as opposed to [`brian2`](https://github.com/brian-team/brian2), for example), but we can convert the ODEs defining the dynamics into difference equations and solve them at regular, short intervals (a `dt` on the order of 1 millisecond) as an approximation. Of course, under the hood, packages like `brian2` are doing the same thing. Doing this in [`PyTorch`](http://pytorch.org/) is exciting for a few reasons: +The simulation of biologically plausible spiking neuron dynamics can be challenging. It is typically done by solving ordinary differential equations (ODEs) which describe said dynamics. PyTorch does not explicitly support the solution of differential equations (as opposed to [`brian2`](https://github.com/brian-team/brian2), for example), but we can convert the ODEs defining the dynamics into difference equations and solve them at regular, short intervals (a `dt` on the order of 1 millisecond) as an approximation. Of course, under the hood, packages like `brian2` are doing the same thing. Doing this in [`PyTorch`](https://pytorch.org/) is exciting for a few reasons: -1. We can use the powerful and flexible [`torch.Tensor`](http://pytorch.org/) object, a wrapper around the [`numpy.ndarray`](https://docs.scipy.org/doc/numpy-1.13.0/reference/generated/numpy.ndarray.html) which can be transferred to and from GPU devices. +1. We can use the powerful and flexible [`torch.Tensor`](https://pytorch.org/docs/stable/tensors.html) object, an array similar to the [`numpy.ndarray`](https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html) that can be moved to and from GPU devices. -2. We can avoid "reinventing the wheel" by repurposing functions from the [`torch.nn.functional`](http://pytorch.org/docs/master/nn.html#torch-nn-functional) PyTorch submodule in our SNN architectures; e.g., convolution or pooling functions. +2. We can avoid "reinventing the wheel" by repurposing functions from the [`torch.nn.functional`](https://pytorch.org/docs/stable/nn.functional.html) PyTorch submodule in our SNN architectures; e.g., convolution or pooling functions. -The concept that the neuron spike ordering and their relative timing encode information is a central theme in neuroscience. [Markram et al. (1997)](http://www.caam.rice.edu/~caam415/lec_gab/g4/markram_etal98.pdf) proposed that synapses between neurons should strengthen or degrade based on this relative timing, and prior to that, [Donald Hebb](https://en.wikipedia.org/wiki/Donald_O._Hebb) proposed the theory of Hebbian learning, often simply stated as "Neurons that fire together, wire together." Markram et al.'s extension of the Hebbian theory is known as spike-timing-dependent plasticity (STDP). +The concept that the neuron spike ordering and their relative timing encode information is a central theme in neuroscience. [Markram et al. (1997)](https://doi.org/10.1126/science.275.5297.213) proposed that synapses between neurons should strengthen or degrade based on this relative timing, and prior to that, [Donald Hebb](https://en.wikipedia.org/wiki/Donald_O._Hebb) proposed the theory of Hebbian learning, often simply stated as "Neurons that fire together, wire together." Markram et al.'s extension of the Hebbian theory is known as spike-timing-dependent plasticity (STDP). We are interested in applying SNNs to ML and RL problems. We use STDP to modify weights of synapses connecting pairs or populations of neurons in SNNs. In the context of ML, we want to learn a setting of synapse weights which will generate data-dependent spiking activity in SNNs. This activity will allow us to subsequently perform some ML task of interest; e.g., discriminating or clustering input data. In the context of RL, we may think of the spiking neural network as an RL agent, whose spiking activity may be converted into actions in an environment's action space. -We have provided some simple starter scripts for doing unsupervised learning (learning a fully-connected or convolutional representation via STDP), supervised learning (clamping output neurons to desired spiking behavior depending on data labels), and reinforcement learning (converting observations from the Atari game Space Invaders to input to an SNN, and converting network activity back to actions in the game). +We have provided some simple starter scripts for doing unsupervised learning (learning a fully-connected or convolutional representation via STDP), supervised learning (clamping output neurons to desired spiking behavior depending on data labels), and reinforcement learning (converting observations from the Atari game Breakout to input to an SNN, and converting network activity back to actions in the game; see `examples/breakout`). ## Benchmarking We simulated a network with a population of n Poisson input neurons with firing rates (in Hertz) drawn randomly from U(0, 100), connected all-to-all with a equally-sized population of leaky integrate-and-fire (LIF) neurons, with connection weights sampled from N(0,1). We varied n systematically from 250 to 10,000 in steps of 250, and ran each simulation with every library for 1,000ms with a time resolution dt = 1.0. We tested BindsNET (with CPU and GPU computation), BRIAN2, PyNEST (the Python interface to the NEST SLI interface that runs the C++NEST core simulator), ANNarchy (with CPU and GPU computation), and BRIAN2genn (the BRIAN2 front-end to the GeNN simulator). @@ -143,7 +141,7 @@ Several packages, including BRIAN and PyNEST, allow the setting of certain globa BindsNET%20Benchmark

-All simulations run on Ubuntu 16.04 LTS with Intel(R) Xeon(R) CPU E5-2687W v3 @ 3.10GHz, 128Gb RAM @ 2133MHz, and two GeForce GTX TITAN X (GM200) GPUs. Python 3.6 is used in all cases. Clock time was recorded for each simulation run. +These results are from the 2018 BindsNET paper. All simulations run on Ubuntu 16.04 LTS with Intel(R) Xeon(R) CPU E5-2687W v3 @ 3.10GHz, 128Gb RAM @ 2133MHz, and two GeForce GTX TITAN X (GM200) GPUs. Python 3.6 is used in all cases. Clock time was recorded for each simulation run. ## Citation diff --git a/bindsnet/analysis/plotting.py b/bindsnet/analysis/plotting.py index 2c2ebc044..4faea784a 100644 --- a/bindsnet/analysis/plotting.py +++ b/bindsnet/analysis/plotting.py @@ -11,8 +11,8 @@ from bindsnet.utils import ( reshape_conv2d_weights, - reshape_locally_connected_weights, reshape_local_connection_2d_weights, + reshape_locally_connected_weights, ) plt.ion() @@ -337,7 +337,7 @@ def plot_locally_connected_weights( # language=rst """ Plot a connection weight matrix of a :code:`Connection` with `locally connected - structure _. + structure `_. :param weights: Weight matrix of Conv2dConnection object. :param n_filters: No. of convolution kernels in use. @@ -415,7 +415,7 @@ def plot_local_connection_2d_weights( # language=rst """ Plot a connection weight matrix of a :code:`Connection` with `locally connected - structure _. + structure `_. :param lc: An object of the class LocalConnection2D :param input_channel: The input channel to plot its corresponding weights, default is the first channel :param output_channel: If not None, will only plot the weights corresponding to this output channel (filter) diff --git a/bindsnet/conversion/conversion.py b/bindsnet/conversion/conversion.py index 3febb0f2b..9728b566d 100644 --- a/bindsnet/conversion/conversion.py +++ b/bindsnet/conversion/conversion.py @@ -66,8 +66,8 @@ def forward(self, x: torch.Tensor) -> Dict[nn.Module, torch.Tensor]: """ Forward pass of the feature extractor. - :param x: Input data for the ``submodule''. - :return: A dictionary mapping + :param x: Input data for the ``submodule``. + :return: A dictionary mapping the name of each layer to its output. """ activations = {"input": x} for name, module in self.submodule._modules.items(): diff --git a/bindsnet/datasets/davis.py b/bindsnet/datasets/davis.py index c494d8941..1c9a27feb 100644 --- a/bindsnet/datasets/davis.py +++ b/bindsnet/datasets/davis.py @@ -34,7 +34,8 @@ def __init__( ): # language=rst """ - Class to read the DAVIS dataset + Class to read the DAVIS dataset. + :param root: Path to the DAVIS folder that contains JPEGImages, Annotations, etc. folders. :param task: Task to load the annotations, choose between semi-supervised or diff --git a/bindsnet/datasets/preprocess.py b/bindsnet/datasets/preprocess.py index 37ce1dc5d..2a716e2f6 100644 --- a/bindsnet/datasets/preprocess.py +++ b/bindsnet/datasets/preprocess.py @@ -62,8 +62,8 @@ def subsample(image: np.ndarray, x: int, y: int) -> np.ndarray: class Rescale(object): """Rescale image and bounding box. - Args: - output_size (tuple or int): Desired output size. If int, square crop + + :param output_size: Desired output size (tuple or int). If int, square crop is made. """ diff --git a/bindsnet/encoding/encoders.py b/bindsnet/encoding/encoders.py index c6a91e1ed..6949f86ec 100644 --- a/bindsnet/encoding/encoders.py +++ b/bindsnet/encoding/encoders.py @@ -90,7 +90,7 @@ def __init__(self, time: int, dt: float = 1.0, approx: bool = False, **kwargs): # language=rst """ Creates a callable PoissonEncoder which encodes as defined in - ``bindsnet.encoding.poisson` + ``bindsnet.encoding.poisson``. :param time: Length of Poisson spike train per input variable. :param dt: Simulation time step. diff --git a/bindsnet/environment/cue_reward.py b/bindsnet/environment/cue_reward.py index 113e6f557..e0b2aa606 100644 --- a/bindsnet/environment/cue_reward.py +++ b/bindsnet/environment/cue_reward.py @@ -11,8 +11,8 @@ class CueRewardSimulator: """ This simulator provides basic cues and rewards according to the - network's choice, as described in the Backpropamine paper: - https://openreview.net/pdf?id=r1lrAiA5Ym + network's choice, as described in the Backpropamine paper + (https://openreview.net/pdf?id=r1lrAiA5Ym). :param epdur: int: duration (timesteps) of an episode; default = 200 :param cuebits: int: max number of bits to hold a cue (max value = 2^n for n bits) diff --git a/bindsnet/environment/dot_simulator.py b/bindsnet/environment/dot_simulator.py index 69ef03215..922e2719d 100644 --- a/bindsnet/environment/dot_simulator.py +++ b/bindsnet/environment/dot_simulator.py @@ -73,16 +73,15 @@ class DotSimulator: :param fpath: string: optional file path for saving grids to file :param diag: Bool: allow diagonal movement. :param bound_hand: str: bounds handling when a dot reaches the world's end. - 'stay': dots will simply be prevented from crossing the edges. - 'bounce': dot positions and directions will be reflected. - 'trans': dot positions will be mirrored to the opposite edge. - :param fit_func: str: Fitness function. - 'euc': Single Euclidean (Pythagorean) distance value - 'disp': Tuple of x,y displacement values - 'rng' : Range rings--the closer the ring, the lower the number - 'dir' : directional--+1 if moving in the right direction - -1 if moving in the wrong direction - 0 if neither. + ``'stay'``: dots are prevented from crossing the edges. + ``'bounce'``: dot positions and directions are reflected. + ``'trans'``: dot positions are mirrored to the opposite edge. + :param fit_func: str: fitness function. + ``'euc'``: single Euclidean (Pythagorean) distance value. + ``'disp'``: tuple of x, y displacement values. + ``'rng'``: range rings; the closer the ring, the lower the number. + ``'dir'``: directional; +1 if moving in the right direction, -1 if moving + in the wrong direction, 0 if neither. :param ring_size: int: set range ring size for range ring fitness function. :param bullseye: int: set reward for successful intercept; default = 10.0 :param teleport: Bool: teleport network dot after intercept; default = true diff --git a/bindsnet/learning/MCC_learning.py b/bindsnet/learning/MCC_learning.py index a6ef5538c..94c867e8d 100644 --- a/bindsnet/learning/MCC_learning.py +++ b/bindsnet/learning/MCC_learning.py @@ -1,9 +1,9 @@ -from abc import ABC, abstractmethod -from typing import Union, Optional, Sequence import warnings +from abc import ABC, abstractmethod +from typing import Optional, Sequence, Union -import torch import numpy as np +import torch from ..network.nodes import SRM0Nodes from ..network.topology import ( diff --git a/bindsnet/learning/learning.py b/bindsnet/learning/learning.py index cf45ed9a8..898bf815b 100644 --- a/bindsnet/learning/learning.py +++ b/bindsnet/learning/learning.py @@ -9,6 +9,7 @@ from torch.nn.modules.utils import _pair from bindsnet.utils import im2col_indices + from ..network.nodes import SRM0Nodes from ..network.topology import ( AbstractConnection, @@ -2147,7 +2148,9 @@ def __init__( :param reduction: Method for reducing parameter updates along the minibatch dimension. :param weight_decay: Coefficient controlling rate of decay of the weights each iteration. + Keyword arguments: + :param float tc_plus: Time constant for pre-synaptic firing trace. :param float tc_minus: Time constant for post-synaptic firing trace. :param float tc_e_trace: Time constant for the eligibility trace. diff --git a/bindsnet/models/models.py b/bindsnet/models/models.py index a5027e0c6..d5a52309e 100644 --- a/bindsnet/models/models.py +++ b/bindsnet/models/models.py @@ -3,8 +3,8 @@ import numpy as np import torch from scipy.spatial.distance import euclidean -from torch.nn.modules.utils import _pair from torch import device +from torch.nn.modules.utils import _pair from bindsnet.learning import PostPre from bindsnet.learning.MCC_learning import DiehlAndCook as MMCDiehlAndCook diff --git a/bindsnet/network/monitors.py b/bindsnet/network/monitors.py index d91e6420e..00d875d15 100644 --- a/bindsnet/network/monitors.py +++ b/bindsnet/network/monitors.py @@ -4,10 +4,6 @@ import numpy as np import torch -import numpy as np - -from abc import ABC -from typing import Union, Optional, Iterable, Dict from bindsnet.network.nodes import Nodes from bindsnet.network.topology import ( @@ -79,8 +75,8 @@ def get(self, var: str) -> torch.Tensor: :param var: State variable recording to return. :return: Tensor of shape ``[time, n_1, ..., n_k]``, where ``[n_1, ..., n_k]`` is the shape of the recorded state - variable. - Note, if time == `None`, get return the logs and empty the monitor variable + variable. If ``time`` is ``None``, the logs are returned and the monitor + is emptied. """ if self.clean: @@ -119,7 +115,7 @@ def record(self) -> None: def reset_state_variables(self) -> None: # language=rst """ - Resets recordings to empty ``List``s. + Resets recordings to empty lists. """ if self.time is None: self.recording = {v: [] for v in self.state_vars} diff --git a/bindsnet/network/nodes.py b/bindsnet/network/nodes.py index 1fcdd3af9..6609c2153 100644 --- a/bindsnet/network/nodes.py +++ b/bindsnet/network/nodes.py @@ -1171,7 +1171,7 @@ def set_batch_size(self, batch_size) -> None: class IzhikevichNodes(Nodes): # language=rst """ - Layer of `Izhikevich neurons`_. + Layer of `Izhikevich neurons `_. """ def __init__( diff --git a/bindsnet/network/topology.py b/bindsnet/network/topology.py index 9c342a6c3..d74d51244 100644 --- a/bindsnet/network/topology.py +++ b/bindsnet/network/topology.py @@ -1,17 +1,16 @@ +import warnings from abc import ABC, abstractmethod from typing import Optional, Sequence, Tuple, Union -import warnings - import numpy as np import torch -from torch import device import torch.nn.functional as F -from bindsnet.utils import im2col_indices +from torch import device from torch.nn import Module, Parameter from torch.nn.modules.utils import _pair, _triple from bindsnet.network.nodes import CSRMNodes, Nodes +from bindsnet.utils import im2col_indices class AbstractConnection(ABC, Module): @@ -35,7 +34,7 @@ def __init__( :param source: A layer of nodes from which the connection originates. :param target: A layer of nodes to which the connection connects. - :param nu: Learning rate for both pre- and post-synaptic events. It also + :param nu: Learning rate for both pre- and post-synaptic events. It also accepts a pair of tensors to individualize learning rates of each neuron. In this case, their shape should be the same size as the connection weights. :param reduction: Method for reducing parameter updates along the minibatch @@ -246,6 +245,7 @@ def insert_pipeline(self, feature, index) -> None: # language=rst """ insert a feature into the pipeline + :param index: Index for where to insert the feature """ self.pipeline.insert(feature, index) @@ -256,6 +256,7 @@ def remove_pipeline(self, feature) -> None: # language=rst """ remove a feature frome the pipeline + :param feature: feature to be removed """ self.pipeline.remove(feature) @@ -314,7 +315,7 @@ def __init__( :param source: A layer of nodes from which the connection originates. :param target: A layer of nodes to which the connection connects. - :param nu: Learning rate for both pre- and post-synaptic events. It also + :param nu: Learning rate for both pre- and post-synaptic events. It also accepts a pair of tensors to individualize learning rates of each neuron. In this case, their shape should be the same size as the connection weights. :param reduction: Method for reducing parameter updates along the minibatch @@ -671,7 +672,7 @@ def __init__( :param stride: stride for convolution. :param padding: padding for convolution. :param dilation: dilation for convolution. - :param nu: Learning rate for both pre- and post-synaptic events. It also + :param nu: Learning rate for both pre- and post-synaptic events. It also accepts a pair of tensors to individualize learning rates of each neuron. In this case, their shape should be the same size as the connection weights. :param reduction: Method for reducing parameter updates along the minibatch @@ -817,7 +818,7 @@ def __init__( :param stride: Horizontal and vertical stride for convolution. :param padding: Horizontal and vertical padding for convolution. :param dilation: Horizontal and vertical dilation for convolution. - :param nu: Learning rate for both pre- and post-synaptic events. It also + :param nu: Learning rate for both pre- and post-synaptic events. It also accepts a pair of tensors to individualize learning rates of each neuron. In this case, their shape should be the same size as the connection weights. :param reduction: Method for reducing parameter updates along the minibatch @@ -978,7 +979,7 @@ def __init__( :param stride: Depth-wise, horizontal, and vertical stride for convolution. :param padding: Depth-wise, horizontal, and vertical padding for convolution. :param dilation: Depth-wise, horizontal and vertical dilation for convolution. - :param nu: Learning rate for both pre- and post-synaptic events. It also + :param nu: Learning rate for both pre- and post-synaptic events. It also accepts a pair of tensors to individualize learning rates of each neuron. In this case, their shape should be the same size as the connection weights. :param reduction: Method for reducing parameter updates along the minibatch @@ -1439,7 +1440,7 @@ def __init__( :param kernel_size: Horizontal and vertical size of convolutional kernels. :param stride: Horizontal and vertical stride for convolution. :param n_filters: Number of locally connected filters per pre-synaptic region. - :param nu: Learning rate for both pre- and post-synaptic events. It also + :param nu: Learning rate for both pre- and post-synaptic events. It also accepts a pair of tensors to individualize learning rates of each neuron. In this case, their shape should be the same size as the connection weights. :param reduction: Method for reducing parameter updates along the minibatch @@ -1613,18 +1614,21 @@ def __init__( if there are `n_conv` neurons in each post-synaptic patch, then the first `n_conv` neurons in the post-synaptic population correspond to the first receptive field, the second ``n_conv`` to the second receptive field, and so on. + :param source: A layer of nodes from which the connection originates. :param target: A layer of nodes to which the connection connects. :param kernel_size: size of convolutional kernels. :param stride: stride for convolution. :param n_filters: Number of locally connected filters per pre-synaptic region. - :param nu: Learning rate for both pre- and post-synaptic events. It also + :param nu: Learning rate for both pre- and post-synaptic events. It also accepts a pair of tensors to individualize learning rates of each neuron. In this case, their shape should be the same size as the connection weights. :param reduction: Method for reducing parameter updates along the minibatch dimension. :param weight_decay: Constant multiple to decay weights by on each iteration. :param w_dtype: Data type for :code:`w` tensor + Keyword arguments: + :param LearningRule update_rule: Modifies connection parameters according to some rule. :param torch.Tensor w: Strengths of synapses. :param torch.Tensor b: Target population bias. @@ -1675,6 +1679,7 @@ def __init__( def compute(self, s: torch.Tensor) -> torch.Tensor: """ Compute pre-activations given spikes using layer weights. + :param s: Incoming spikes. :return: Incoming spikes multiplied by synaptic weights (with or without decaying spike activation). @@ -1749,18 +1754,21 @@ def __init__( if there are `n_conv` neurons in each post-synaptic patch, then the first `n_conv` neurons in the post-synaptic population correspond to the first receptive field, the second ``n_conv`` to the second receptive field, and so on. + :param source: A layer of nodes from which the connection originates. :param target: A layer of nodes to which the connection connects. :param kernel_size: Horizontal and vertical size of convolutional kernels. :param stride: Horizontal and vertical stride for convolution. :param n_filters: Number of locally connected filters per pre-synaptic region. - :param nu: Learning rate for both pre- and post-synaptic events. It also + :param nu: Learning rate for both pre- and post-synaptic events. It also accepts a pair of tensors to individualize learning rates of each neuron. In this case, their shape should be the same size as the connection weights. :param reduction: Method for reducing parameter updates along the minibatch dimension. :param weight_decay: Constant multiple to decay weights by on each iteration. :param w_dtype: Data type for :code:`w` tensor + Keyword arguments: + :param LearningRule update_rule: Modifies connection parameters according to some rule. :param torch.Tensor w: Strengths of synapses. :param torch.Tensor b: Target population bias. @@ -1821,6 +1829,7 @@ def __init__( def compute(self, s: torch.Tensor) -> torch.Tensor: """ Compute pre-activations given spikes using layer weights. + :param s: Incoming spikes. :return: Incoming spikes multiplied by synaptic weights (with or without decaying spike activation). @@ -1896,18 +1905,21 @@ def __init__( if there are `n_conv` neurons in each post-synaptic patch, then the first `n_conv` neurons in the post-synaptic population correspond to the first receptive field, the second ``n_conv`` to the second receptive field, and so on. + :param source: A layer of nodes from which the connection originates. :param target: A layer of nodes to which the connection connects. :param kernel_size: Horizontal, vertical, and depth-wise size of convolutional kernels. :param stride: Horizontal, vertical, and depth-wise stride for convolution. :param n_filters: Number of locally connected filters per pre-synaptic region. - :param nu: Learning rate for both pre- and post-synaptic events. It also + :param nu: Learning rate for both pre- and post-synaptic events. It also accepts a pair of tensors to individualize learning rates of each neuron. In this case, their shape should be the same size as the connection weights. :param reduction: Method for reducing parameter updates along the minibatch dimension. :param weight_decay: Constant multiple to decay weights by on each iteration. :param w_dtype: Data type for :code:`w` tensor + Keyword arguments: + :param LearningRule update_rule: Modifies connection parameters according to some rule. :param torch.Tensor w: Strengths of synapses. :param torch.Tensor b: Target population bias. @@ -1970,6 +1982,7 @@ def __init__( def compute(self, s: torch.Tensor) -> torch.Tensor: """ Compute pre-activations given spikes using layer weights. + :param s: Incoming spikes. :return: Incoming spikes multiplied by synaptic weights (with or without decaying spike activation). @@ -2041,14 +2054,17 @@ def __init__( # language=rst """ Instantiates a :code:`MeanFieldConnection` object. + :param source: A layer of nodes from which the connection originates. :param target: A layer of nodes to which the connection connects. - :param nu: Learning rate for both pre- and post-synaptic events. It also + :param nu: Learning rate for both pre- and post-synaptic events. It also accepts a pair of tensors to individualize learning rates of each neuron. In this case, their shape should be the same size as the connection weights. :param weight_decay: Constant multiple to decay weights by on each iteration. :param w_dtype: Data type for :code:`w` tensor + Keyword arguments: + :param LearningRule update_rule: Modifies connection parameters according to some rule. :param Union[float, torch.Tensor] w: Strengths of synapses. Can be single value or tensor of size ``target`` @@ -2077,6 +2093,7 @@ def compute(self, s: torch.Tensor) -> torch.Tensor: # language=rst """ Compute pre-activations given spikes using layer weights. + :param s: Incoming spikes. :return: Incoming spikes multiplied by synaptic weights (with or without decaying spike activation). diff --git a/bindsnet/network/topology_features.py b/bindsnet/network/topology_features.py index aa6c16f8d..8426ee62a 100644 --- a/bindsnet/network/topology_features.py +++ b/bindsnet/network/topology_features.py @@ -1,15 +1,16 @@ +import warnings from abc import ABC, abstractmethod -from bindsnet.learning.learning import NoOp -from typing import Union, Tuple, Optional, Sequence +from typing import Optional, Sequence, Tuple, Union import numpy as np import torch -import warnings +import torch.nn as nn +import torch.nn.functional as F from torch import device from torch.nn import Parameter -import torch.nn.functional as F -import torch.nn as nn + import bindsnet.learning +from bindsnet.learning.learning import NoOp class AbstractFeature(ABC): @@ -53,6 +54,7 @@ def __init__( # language=rst """ Instantiates a :code:`Feature` object. Will assign all incoming arguments as class variables + :param name: Name of the feature :param value: Core numeric object for the feature. This parameters function will vary depending on the feature :param value_dtype: Data type for :code:`value` tensor @@ -89,12 +91,12 @@ def __init__( self.is_primed = False from ..learning.MCC_learning import ( - NoOp, - PostPre, - Hebbian, - DiehlAndCook, MSTDP, MSTDPET, + DiehlAndCook, + Hebbian, + NoOp, + PostPre, ) supported_rules = [ @@ -395,6 +397,7 @@ def __init__( # language=rst """ Will run a bernoulli trial using :code:`value` to determine if a signal will successfully traverse the synapse + :param name: Name of the feature :param value: Number(s) in [0, 1] which represent the probability of a signal traversing a synapse. Tensor values assume that probabilities will be matched to adjacent synapses in the connection. Scalars will be applied to @@ -489,6 +492,7 @@ def __init__( # language=rst """ Boolean mask which determines whether or not signals are allowed to traverse certain synapses. + :param name: Name of the feature :param value: Boolean mask. :code:`True` means a signal can pass, :code:`False` means the synapse is impassable :param sparse: Should :code:`value` parameter be sparse tensor or not @@ -604,6 +608,7 @@ def __init__( # language=rst """ Multiplies signals by scalars + :param name: Name of the feature :param value: Values to scale signals by :param value_dtype: Data type for :code:`value` tensor @@ -611,8 +616,10 @@ def __init__( :param norm: Value which all values in :code:`value` will sum to. Normalization of values occurs after each sample and after the value has been updated by the learning rule (if there is one) :param norm_frequency: How often to normalize weights: + * 'sample': weights normalized after each sample * 'time step': weights normalized after each time step + :param learning_rule: Rule which will modify the :code:`value` after each sample :param nu: Learning rate for the learning rule :param reduction: Method for reducing parameter updates along the minibatch @@ -700,6 +707,7 @@ def __init__( # language=rst """ Adds scalars to signals + :param name: Name of the feature :param value: Values to add to the signals :param value_dtype: Data type for :code:`value` tensor @@ -750,6 +758,7 @@ def __init__( # language=rst """ Multiply all signals by a scalar + :param name: Name of the feature :param value: Values to scale signals by :param value_dtype: Data type for :code:`value` tensor @@ -797,11 +806,12 @@ def __init__( """ Degrades propagating spikes according to :code:`degrade_function`. Note: If :code:`parent_feature` is provided, it will override :code:`value`. + :param name: Name of the feature :param value: Value used to degrade feature :param value_dtype: Data type for :code:`value` tensor :param degrade_function: Callable function which takes a single argument (:code:`value`) and returns a tensor or - constant to be *subtracted* from the propagating spikes. + constant to be *subtracted* from the propagating spikes. :param parent_feature: Parent feature with desired :code:`value` to inherit :param sparse: Should :code:`value` parameter be sparse tensor or not :param batch_size: Mini-batch size. @@ -1086,6 +1096,7 @@ def __init__( # language=rst """ Instantiates a :code:`Augment` object. Will assign all incoming arguments as class variables. + :param name: Name of the augment :param parent_feature: Primary feature which the augment will modify """ diff --git a/bindsnet/pipeline/base_pipeline.py b/bindsnet/pipeline/base_pipeline.py index c8c380164..3180aba6f 100644 --- a/bindsnet/pipeline/base_pipeline.py +++ b/bindsnet/pipeline/base_pipeline.py @@ -3,6 +3,7 @@ from typing import Any, Dict, Tuple import torch + from bindsnet.network import Network from bindsnet.network.monitors import Monitor diff --git a/docs/Makefile.old b/docs/Makefile.old deleted file mode 100644 index 42fd05a2e..000000000 --- a/docs/Makefile.old +++ /dev/null @@ -1,20 +0,0 @@ -# Minimal makefile for Sphinx documentation -# - -# You can set these variables from the command line. -SPHINXOPTS = -SPHINXBUILD = python -msphinx -SPHINXPROJ = bindsnet -SOURCEDIR = source -BUILDDIR = build - -# Put it first so that "make" without argument is like "make help". -help: - @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) - -.PHONY: help Makefile - -# Catch-all target: route all unknown targets to Sphinx using the new -# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). -%: Makefile - @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) diff --git a/docs/make.bat.old b/docs/make.bat.old deleted file mode 100644 index 51a31ec39..000000000 --- a/docs/make.bat.old +++ /dev/null @@ -1,36 +0,0 @@ -@ECHO OFF - -pushd %~dp0 - -REM Command file for Sphinx documentation - -if "%SPHINXBUILD%" == "" ( - set SPHINXBUILD=python -msphinx -) -set SOURCEDIR=source -set BUILDDIR=build -set SPHINXPROJ=bindsnet - -if "%1" == "" goto help - -%SPHINXBUILD% >NUL 2>NUL -if errorlevel 9009 ( - echo. - echo.The Sphinx module was not found. Make sure you have Sphinx installed, - echo.then set the SPHINXBUILD environment variable to point to the full - echo.path of the 'sphinx-build' executable. Alternatively you may add the - echo.Sphinx directory to PATH. - echo. - echo.If you don't have Sphinx installed, grab it from - echo.http://sphinx-doc.org/ - exit /b 1 -) - -%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% -goto end - -:help -%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% - -:end -popd diff --git a/docs/pyproject.toml b/docs/pyproject.toml deleted file mode 100644 index 1261166e8..000000000 --- a/docs/pyproject.toml +++ /dev/null @@ -1,11 +0,0 @@ -[project] -name = "bindsnet_docs" -dynamic = ["version"] -dependencies = [ - "sphinx==7.2.6", - "sphinx_rtd_theme==1.3.0", - "readthedocs-sphinx-search==0.3.2", - "imagecodecs == 2023.9.18", - "Jinja2 == 3.1.6", - "wheel == 0.46.2", -] diff --git a/docs/requirements.txt b/docs/requirements.txt index 40e97d17b..7fb494d04 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -1,13 +1,8 @@ -# Defining the exact version will make sure things don't break -#sphinx==6.2.1 -#sphinx_rtd_theme==1.2.2 -#readthedocs-sphinx-search==0.1.1 -#imagecodecs == 2026.3.6 -#Jinja2 == 3.1.6 +# Documentation build (Read the Docs; see .readthedocs.yaml). +# CPU-only torch: autodoc only needs to import bindsnet, not run it on a GPU. +--extra-index-url https://download.pytorch.org/whl/cpu +torch==2.14.0+cpu +torchvision==0.29.0+cpu sphinx==9.0.4 sphinx_rtd_theme==3.1.0 -readthedocs-sphinx-search==0.3.2 -imagecodecs == 2026.3.6 -Jinja2 == 3.1.6 -wheel == 0.48.0 diff --git a/docs/source/bindsnet.analysis.rst b/docs/source/bindsnet.analysis.rst index 49e941d9b..b0ddf74cd 100644 --- a/docs/source/bindsnet.analysis.rst +++ b/docs/source/bindsnet.analysis.rst @@ -29,10 +29,19 @@ bindsnet.analysis.visualization module :show-inheritance: +bindsnet.analysis.dotTrace_plotter module +----------------------------------------- + +.. automodule:: bindsnet.analysis.dotTrace_plotter + :members: + :undoc-members: + :show-inheritance: + Module contents --------------- .. automodule:: bindsnet.analysis + :no-index: :members: :undoc-members: :show-inheritance: diff --git a/docs/source/bindsnet.conversion.rst b/docs/source/bindsnet.conversion.rst index 88781331c..8757deab7 100644 --- a/docs/source/bindsnet.conversion.rst +++ b/docs/source/bindsnet.conversion.rst @@ -33,6 +33,7 @@ Module contents --------------- .. automodule:: bindsnet.conversion + :no-index: :members: :undoc-members: :show-inheritance: diff --git a/docs/source/bindsnet.datasets.rst b/docs/source/bindsnet.datasets.rst index 99205c1a9..9bc345810 100644 --- a/docs/source/bindsnet.datasets.rst +++ b/docs/source/bindsnet.datasets.rst @@ -65,6 +65,7 @@ Module contents --------------- .. automodule:: bindsnet.datasets + :no-index: :members: :undoc-members: :show-inheritance: diff --git a/docs/source/bindsnet.encoding.rst b/docs/source/bindsnet.encoding.rst index 06cf7fe24..e36089a90 100644 --- a/docs/source/bindsnet.encoding.rst +++ b/docs/source/bindsnet.encoding.rst @@ -33,6 +33,7 @@ Module contents --------------- .. automodule:: bindsnet.encoding + :no-index: :members: :undoc-members: :show-inheritance: diff --git a/docs/source/bindsnet.environment.rst b/docs/source/bindsnet.environment.rst index 37bdb88a8..63ab3882e 100644 --- a/docs/source/bindsnet.environment.rst +++ b/docs/source/bindsnet.environment.rst @@ -13,10 +13,27 @@ bindsnet.environment.environment module :show-inheritance: +bindsnet.environment.cue_reward module +-------------------------------------- + +.. automodule:: bindsnet.environment.cue_reward + :members: + :undoc-members: + :show-inheritance: + +bindsnet.environment.dot_simulator module +----------------------------------------- + +.. automodule:: bindsnet.environment.dot_simulator + :members: + :undoc-members: + :show-inheritance: + Module contents --------------- .. automodule:: bindsnet.environment + :no-index: :members: :undoc-members: :show-inheritance: diff --git a/docs/source/bindsnet.evaluation.rst b/docs/source/bindsnet.evaluation.rst index b6a20ffd7..8b2a9c02e 100644 --- a/docs/source/bindsnet.evaluation.rst +++ b/docs/source/bindsnet.evaluation.rst @@ -17,6 +17,7 @@ Module contents --------------- .. automodule:: bindsnet.evaluation + :no-index: :members: :undoc-members: :show-inheritance: diff --git a/docs/source/bindsnet.learning.rst b/docs/source/bindsnet.learning.rst index 48aeec3dc..e06b732a1 100644 --- a/docs/source/bindsnet.learning.rst +++ b/docs/source/bindsnet.learning.rst @@ -21,10 +21,19 @@ bindsnet.learning.reward module :show-inheritance: +bindsnet.learning.MCC_learning module +------------------------------------- + +.. automodule:: bindsnet.learning.MCC_learning + :members: + :undoc-members: + :show-inheritance: + Module contents --------------- .. automodule:: bindsnet.learning + :no-index: :members: :undoc-members: :show-inheritance: diff --git a/docs/source/bindsnet.models.rst b/docs/source/bindsnet.models.rst index 2409eae51..541dd26c2 100644 --- a/docs/source/bindsnet.models.rst +++ b/docs/source/bindsnet.models.rst @@ -17,6 +17,7 @@ Module contents --------------- .. automodule:: bindsnet.models + :no-index: :members: :undoc-members: :show-inheritance: diff --git a/docs/source/bindsnet.network.rst b/docs/source/bindsnet.network.rst index d299abed8..3496d0da5 100644 --- a/docs/source/bindsnet.network.rst +++ b/docs/source/bindsnet.network.rst @@ -37,10 +37,19 @@ bindsnet.network.topology module :show-inheritance: +bindsnet.network.topology_features module +----------------------------------------- + +.. automodule:: bindsnet.network.topology_features + :members: + :undoc-members: + :show-inheritance: + Module contents --------------- .. automodule:: bindsnet.network + :no-index: :members: :undoc-members: :show-inheritance: diff --git a/docs/source/bindsnet.pipeline.rst b/docs/source/bindsnet.pipeline.rst index 0d5221c63..665bb4fc2 100644 --- a/docs/source/bindsnet.pipeline.rst +++ b/docs/source/bindsnet.pipeline.rst @@ -41,6 +41,7 @@ Module contents --------------- .. automodule:: bindsnet.pipeline + :no-index: :members: :undoc-members: :show-inheritance: diff --git a/docs/source/bindsnet.preprocessing.rst b/docs/source/bindsnet.preprocessing.rst index ab2f866e4..ccae3e6ab 100644 --- a/docs/source/bindsnet.preprocessing.rst +++ b/docs/source/bindsnet.preprocessing.rst @@ -17,6 +17,7 @@ Module contents --------------- .. automodule:: bindsnet.preprocessing + :no-index: :members: :undoc-members: :show-inheritance: diff --git a/docs/source/bindsnet.rst b/docs/source/bindsnet.rst index 3719b55c2..216b5dd07 100644 --- a/docs/source/bindsnet.rst +++ b/docs/source/bindsnet.rst @@ -34,6 +34,7 @@ Module contents --------------- .. automodule:: bindsnet + :no-index: :members: :undoc-members: :show-inheritance: diff --git a/docs/source/conf.py b/docs/source/conf.py index e7909d188..8953df1ed 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -57,24 +57,28 @@ # General information about the project. project = "bindsnet" -copyright = "2019, Daniel Saunders, Hananel Hazan" +copyright = "2018-2026, BindsNET contributors" author = "Daniel Saunders, Hananel Hazan" # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the # built documents. -# -# The short X.Y version. -# version = "0.2.5" +from importlib.metadata import PackageNotFoundError +from importlib.metadata import version as _pkg_version + +try: + release = _pkg_version("bindsnet") +except PackageNotFoundError: # building without installing the package + release = "" +version = ".".join(release.split(".")[:2]) # The full version, including alpha/beta/rc tags. -# release = "0.2.5" # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. # # This is also used if you do content translation via gettext catalogs. # Usually you set "language" from the command line for these cases. -language = None +language = "en" # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. @@ -103,22 +107,13 @@ # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". -html_static_path = ["_static"] +html_static_path = [] # Custom sidebar templates, must be a dictionary that maps document names # to template names. # # This is required for the alabaster theme # refs: http://alabaster.readthedocs.io/en/latest/installation.html#sidebars -html_sidebars = { - "**": [ - "about.html", - "navigation.html", - "relations.html", # needs 'show_related': True theme option to display - "searchbox.html", - "donate.html", - ] -} # -- Options for HTMLHelp output ------------------------------------------ diff --git a/docs/source/guide/guide_part_i.rst b/docs/source/guide/guide_part_i.rst index 20414e769..770a80563 100644 --- a/docs/source/guide/guide_part_i.rst +++ b/docs/source/guide/guide_part_i.rst @@ -28,11 +28,11 @@ supports dynamics minibatch size, this argument can safely be ignored. It is use and synaptic variables, and may provide a small speedup if specified beforehand. The :code:`learning` argument acts to enable or disable updates to adaptive parameters of network components; e.g., -synapse weights or adaptive voltage thresholds. See `Using Learning Rules`_ for more details. +synapse weights or adaptive voltage thresholds. See :ref:`guide_part_ii` for more details. The :code:`reward_fn` argument takes in class that specifies how a scalar reward signal will be computed and fed to the network and its components. Typically, the output of this callable class will be used in certain "reward-modulated", or -"three-factor" learning rules. See `Using Learning Rules`_ for more details. +"three-factor" learning rules. See :ref:`guide_part_ii` for more details. Adding Network Components ------------------------- diff --git a/docs/source/index.rst b/docs/source/index.rst index 91c9faa55..5a7cc9163 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -10,15 +10,14 @@ BindsNET is built on top of the `PyTorch `_ deep learning p of spiking neural networks (SNNs) and is geared towards machine learning and reinforcement learning. BindsNET takes advantage of the :code:`torch.Tensor` object to build spiking neurons and connections between them, and -simulate them on CPUs or GPUs (for strong acceleration / parallelization) without any extra work. Recently, -:code:`torchvision.datasets` has been integrated into the library to allow the use of popular vision datasets in +simulate them on CPUs or GPUs (for strong acceleration / parallelization) without any extra work. :code:`torchvision.datasets` is integrated into the library to allow the use of popular vision datasets in training SNNs for computer vision tasks. Neural network functionality contained in :code:`torch.nn.functional` module is used to implement more complex connections between populations of spiking neurons. Spiking neural networks are sometimes referred to as the `third generation of neural networks `_. Rather than the simple linear layers and nonlinear activation functions of deep learning neural networks, SNNs are composed of neural units which more accurately capture properties of their biological counterparts. An important difference between spiking neurons and the artificial neurons of deep learning are the former's integration of input *in time*; they are naturally short-term memory devices by their maintenance of a (possibly decaying) membrane voltage. As a result, some have argued that SNNs are particularly well-suited to model time-varying data. -Neurons are connected together with directed edges (*synapses*) which are (in general) plastic. Synapses may have their own dynamics as well, which may or may not `depend on pre- and post-synaptic neural activity https://www.ncbi.nlm.nih.gov/pmc/articles/PMC3395004/` or `other biological signals https://www.ncbi.nlm.nih.gov/pmc/articles/PMC4717313/`. The modification of synaptic strengths is thought to be an important mechanism by which organisms learn. Accordingly, BindsNET provides a module (**bindsnet.learning**) which contains functions used for the updating of synapse weights. +Neurons are connected together with directed edges (*synapses*) which are (in general) plastic. Synapses may have their own dynamics as well, which may or may not `depend on pre- and post-synaptic neural activity `_ or `other biological signals `_. The modification of synaptic strengths is thought to be an important mechanism by which organisms learn. Accordingly, BindsNET provides a module (**bindsnet.learning**) which contains functions used for the updating of synapse weights. At its core, BindsNET provides software objects and methods which support the simulation of groups of different types of neurons (**bindsnet.network.nodes**), as well as different types of connections between them (**bindsnet.network.topology**). These may be arbitrarily combined together under a single **bindsnet.network.Network** object, which is responsible for the coordination of the simulation logic of all underlying components. On creation of a network, the user can specify a simulation timestep constant, :math:`dt`, which determines the granularity of the simulation. Choosing this parameter induces a trade-off between simulation speed and numerical precision: large values result in fast simulation, but poor simulation accuracy, and vice versa. Monitors (**bindsnet.network.monitors**) are available for recording state variables from arbitrary network components (e.g., the voltage :math:`v` of a group of neurons). diff --git a/docs/source/modules.rst b/docs/source/modules.rst deleted file mode 100644 index 4b5242d96..000000000 --- a/docs/source/modules.rst +++ /dev/null @@ -1,7 +0,0 @@ -bindsnet -======== - -.. toctree:: - :maxdepth: 4 - - bindsnet diff --git a/examples/benchmark/lowering_precision.py b/examples/benchmark/lowering_precision.py index c3927b0c1..e0a2c0ecd 100644 --- a/examples/benchmark/lowering_precision.py +++ b/examples/benchmark/lowering_precision.py @@ -1,5 +1,5 @@ -import re import os +import re import subprocess from statistics import mean diff --git a/examples/benchmark/sparse_compute and foldable pipeline/_bench_common.py b/examples/benchmark/sparse_compute and foldable pipeline/_bench_common.py index 91c21cffe..d02699d03 100644 --- a/examples/benchmark/sparse_compute and foldable pipeline/_bench_common.py +++ b/examples/benchmark/sparse_compute and foldable pipeline/_bench_common.py @@ -33,10 +33,10 @@ sys.path.insert(0, _p) import torch +from example_network import ExampleNetwork from bindsnet.network.topology import MulticompartmentConnection from bindsnet.network.topology_features import Degradation, Probability -from example_network import ExampleNetwork # ExampleNetwork sizes per device: 20k excitatory neurons on GPU (where the fold # shines), a smaller net on CPU so the baseline finishes in reasonable time. diff --git a/examples/benchmark/sparse_vs_dense_tensors.py b/examples/benchmark/sparse_vs_dense_tensors.py index 228fdc4af..79afed86d 100644 --- a/examples/benchmark/sparse_vs_dense_tensors.py +++ b/examples/benchmark/sparse_vs_dense_tensors.py @@ -1,6 +1,7 @@ -import torch -import time import argparse +import time + +import torch from bindsnet.evaluation import all_activity, assign_labels, proportion_weighting diff --git a/examples/mnist/MCC_reservoir.py b/examples/mnist/MCC_reservoir.py index ff91876ff..acf61fd68 100644 --- a/examples/mnist/MCC_reservoir.py +++ b/examples/mnist/MCC_reservoir.py @@ -1,10 +1,10 @@ +import argparse import os + +import matplotlib.pyplot as plt import numpy as np import torch import torch.nn as nn -import argparse -import matplotlib.pyplot as plt - from torchvision import transforms from tqdm import tqdm @@ -17,13 +17,12 @@ from bindsnet.datasets import MNIST from bindsnet.encoding import PoissonEncoder from bindsnet.network import Network -from bindsnet.network.nodes import Input -from bindsnet.network.topology_features import Probability, Weight, Mask # Build a simple two-layer, input-output network. from bindsnet.network.monitors import Monitor -from bindsnet.network.nodes import LIFNodes +from bindsnet.network.nodes import Input, LIFNodes from bindsnet.network.topology import MulticompartmentConnection +from bindsnet.network.topology_features import Mask, Probability, Weight from bindsnet.utils import get_square_weights parser = argparse.ArgumentParser() diff --git a/examples/mnist/loc1d_mnist.py b/examples/mnist/loc1d_mnist.py index ec652d14c..0a238caec 100644 --- a/examples/mnist/loc1d_mnist.py +++ b/examples/mnist/loc1d_mnist.py @@ -1,26 +1,20 @@ ### Toy example to test LocanConnection1D (the dataset used is MNIST but each image is raveled (each sample has shape (784,)). -import torch -from torch.nn.modules.utils import _pair - -from tqdm import tqdm import os -from bindsnet.network.monitors import Monitor +from time import time as t import torch +from torch.nn.modules.utils import _pair from torchvision import transforms from tqdm import tqdm -from time import time as t -from torchvision import transforms +from bindsnet.datasets import MNIST +from bindsnet.encoding import PoissonEncoder from bindsnet.learning import PostPre - -from bindsnet.network.nodes import AdaptiveLIFNodes -from bindsnet.network.nodes import Input +from bindsnet.network.monitors import Monitor from bindsnet.network.network import Network +from bindsnet.network.nodes import AdaptiveLIFNodes, Input from bindsnet.network.topology import Connection, LocalConnection1D -from bindsnet.encoding import PoissonEncoder -from bindsnet.datasets import MNIST # Hyperparameters in_channels = 1 diff --git a/examples/mnist/loc2d_mnist.py b/examples/mnist/loc2d_mnist.py index 37cc34f40..ed7f63c15 100644 --- a/examples/mnist/loc2d_mnist.py +++ b/examples/mnist/loc2d_mnist.py @@ -1,26 +1,20 @@ -import torch -from torch.nn.modules.utils import _pair - -from tqdm import tqdm import os -from bindsnet.network.monitors import Monitor +from time import time as t + import matplotlib.pyplot as plt import torch +from torch.nn.modules.utils import _pair from torchvision import transforms from tqdm import tqdm from bindsnet.analysis.plotting import plot_local_connection_2d_weights - -from time import time as t -from torchvision import transforms +from bindsnet.datasets import MNIST +from bindsnet.encoding import PoissonEncoder from bindsnet.learning import PostPre - -from bindsnet.network.nodes import AdaptiveLIFNodes -from bindsnet.network.nodes import Input +from bindsnet.network.monitors import Monitor from bindsnet.network.network import Network +from bindsnet.network.nodes import AdaptiveLIFNodes, Input from bindsnet.network.topology import Connection, LocalConnection2D -from bindsnet.encoding import PoissonEncoder -from bindsnet.datasets import MNIST # Hyperparameters in_channels = 1 diff --git a/examples/mnist/loc3d_mnist.py b/examples/mnist/loc3d_mnist.py index 6ef45ab48..cb257c8f2 100644 --- a/examples/mnist/loc3d_mnist.py +++ b/examples/mnist/loc3d_mnist.py @@ -1,27 +1,21 @@ ### Toy example to test LocalConnection3D (the dataset used is MNIST but with a dimension replicated ### for each image (each sample has size (28, 28, 28)) -import torch -from torch.nn.modules.utils import _triple - -from tqdm import tqdm import os -from bindsnet.network.monitors import Monitor +from time import time as t import torch +from torch.nn.modules.utils import _triple from torchvision import transforms from tqdm import tqdm -from time import time as t -from torchvision import transforms +from bindsnet.datasets import MNIST +from bindsnet.encoding import PoissonEncoder from bindsnet.learning import PostPre - -from bindsnet.network.nodes import AdaptiveLIFNodes -from bindsnet.network.nodes import Input +from bindsnet.network.monitors import Monitor from bindsnet.network.network import Network +from bindsnet.network.nodes import AdaptiveLIFNodes, Input from bindsnet.network.topology import Connection, LocalConnection3D -from bindsnet.encoding import PoissonEncoder -from bindsnet.datasets import MNIST # Hyperparameters in_channels = 1 diff --git a/logs/init/events.out.tfevents.1656543178.TempWin b/logs/init/events.out.tfevents.1656543178.TempWin deleted file mode 100644 index 210c362df..000000000 Binary files a/logs/init/events.out.tfevents.1656543178.TempWin and /dev/null differ diff --git a/logs/init/events.out.tfevents.1656548905.TempWin b/logs/init/events.out.tfevents.1656548905.TempWin deleted file mode 100644 index 13009682b..000000000 Binary files a/logs/init/events.out.tfevents.1656548905.TempWin and /dev/null differ diff --git a/logs/init/events.out.tfevents.1673646087.Spike b/logs/init/events.out.tfevents.1673646087.Spike deleted file mode 100644 index 8a50eada9..000000000 Binary files a/logs/init/events.out.tfevents.1673646087.Spike and /dev/null differ diff --git a/logs/init/events.out.tfevents.1673648326.Spike b/logs/init/events.out.tfevents.1673648326.Spike deleted file mode 100644 index 88b45f2d5..000000000 Binary files a/logs/init/events.out.tfevents.1673648326.Spike and /dev/null differ diff --git a/logs/init/events.out.tfevents.1678117372.Spike b/logs/init/events.out.tfevents.1678117372.Spike deleted file mode 100644 index ba8eab497..000000000 Binary files a/logs/init/events.out.tfevents.1678117372.Spike and /dev/null differ diff --git a/logs/init/events.out.tfevents.1682712186.Spike b/logs/init/events.out.tfevents.1682712186.Spike deleted file mode 100644 index 273569a20..000000000 Binary files a/logs/init/events.out.tfevents.1682712186.Spike and /dev/null differ diff --git a/logs/init/events.out.tfevents.1687464074.Spike b/logs/init/events.out.tfevents.1687464074.Spike deleted file mode 100644 index 2312550d9..000000000 Binary files a/logs/init/events.out.tfevents.1687464074.Spike and /dev/null differ diff --git a/logs/init/events.out.tfevents.1687464505.Spike b/logs/init/events.out.tfevents.1687464505.Spike deleted file mode 100644 index a61c0c852..000000000 Binary files a/logs/init/events.out.tfevents.1687464505.Spike and /dev/null differ diff --git a/logs/init/events.out.tfevents.1687736499.Spike b/logs/init/events.out.tfevents.1687736499.Spike deleted file mode 100644 index ee09c2c72..000000000 Binary files a/logs/init/events.out.tfevents.1687736499.Spike and /dev/null differ diff --git a/logs/init/events.out.tfevents.1694374827.Spike b/logs/init/events.out.tfevents.1694374827.Spike deleted file mode 100644 index 4ae2c5994..000000000 Binary files a/logs/init/events.out.tfevents.1694374827.Spike and /dev/null differ diff --git a/logs/init/events.out.tfevents.1694374969.Spike b/logs/init/events.out.tfevents.1694374969.Spike deleted file mode 100644 index b193b999c..000000000 Binary files a/logs/init/events.out.tfevents.1694374969.Spike and /dev/null differ diff --git a/logs/init/events.out.tfevents.1694375010.Spike b/logs/init/events.out.tfevents.1694375010.Spike deleted file mode 100644 index d3824aa58..000000000 Binary files a/logs/init/events.out.tfevents.1694375010.Spike and /dev/null differ diff --git a/logs/init/events.out.tfevents.1700165624.Spike b/logs/init/events.out.tfevents.1700165624.Spike deleted file mode 100644 index f554bf97e..000000000 Binary files a/logs/init/events.out.tfevents.1700165624.Spike and /dev/null differ diff --git a/logs/init/events.out.tfevents.1703700212.Spike b/logs/init/events.out.tfevents.1703700212.Spike deleted file mode 100644 index febaf04de..000000000 Binary files a/logs/init/events.out.tfevents.1703700212.Spike and /dev/null differ diff --git a/logs/init/events.out.tfevents.1711672057.Spike b/logs/init/events.out.tfevents.1711672057.Spike deleted file mode 100644 index 51e2b3df5..000000000 Binary files a/logs/init/events.out.tfevents.1711672057.Spike and /dev/null differ diff --git a/logs/init/events.out.tfevents.1711672140.Spike b/logs/init/events.out.tfevents.1711672140.Spike deleted file mode 100644 index e2410d554..000000000 Binary files a/logs/init/events.out.tfevents.1711672140.Spike and /dev/null differ diff --git a/logs/init/events.out.tfevents.1711673241.Spike b/logs/init/events.out.tfevents.1711673241.Spike deleted file mode 100644 index 7d66c02c3..000000000 Binary files a/logs/init/events.out.tfevents.1711673241.Spike and /dev/null differ diff --git a/logs/init/events.out.tfevents.1711673760.Spike b/logs/init/events.out.tfevents.1711673760.Spike deleted file mode 100644 index efd1469e1..000000000 Binary files a/logs/init/events.out.tfevents.1711673760.Spike and /dev/null differ diff --git a/logs/init/events.out.tfevents.1711674764.Spike b/logs/init/events.out.tfevents.1711674764.Spike deleted file mode 100644 index 43ffbc3a4..000000000 Binary files a/logs/init/events.out.tfevents.1711674764.Spike and /dev/null differ diff --git a/logs/init/events.out.tfevents.1711675116.Spike b/logs/init/events.out.tfevents.1711675116.Spike deleted file mode 100644 index ae08c15c1..000000000 Binary files a/logs/init/events.out.tfevents.1711675116.Spike and /dev/null differ diff --git a/logs/init/events.out.tfevents.1711675170.Spike b/logs/init/events.out.tfevents.1711675170.Spike deleted file mode 100644 index 68bcf48e7..000000000 Binary files a/logs/init/events.out.tfevents.1711675170.Spike and /dev/null differ diff --git a/logs/init/events.out.tfevents.1711675181.Spike b/logs/init/events.out.tfevents.1711675181.Spike deleted file mode 100644 index 2ce350972..000000000 Binary files a/logs/init/events.out.tfevents.1711675181.Spike and /dev/null differ diff --git a/logs/init/events.out.tfevents.1711675321.Spike b/logs/init/events.out.tfevents.1711675321.Spike deleted file mode 100644 index 0d73f89e2..000000000 Binary files a/logs/init/events.out.tfevents.1711675321.Spike and /dev/null differ diff --git a/logs/init/events.out.tfevents.1711675865.Spike b/logs/init/events.out.tfevents.1711675865.Spike deleted file mode 100644 index 5fe52b4d2..000000000 Binary files a/logs/init/events.out.tfevents.1711675865.Spike and /dev/null differ diff --git a/logs/init/events.out.tfevents.1711721119.Spike b/logs/init/events.out.tfevents.1711721119.Spike deleted file mode 100644 index 89c0d8608..000000000 Binary files a/logs/init/events.out.tfevents.1711721119.Spike and /dev/null differ diff --git a/logs/init/events.out.tfevents.1711723694.Spike b/logs/init/events.out.tfevents.1711723694.Spike deleted file mode 100644 index 4e288a475..000000000 Binary files a/logs/init/events.out.tfevents.1711723694.Spike and /dev/null differ diff --git a/logs/init/events.out.tfevents.1720719086.Spike b/logs/init/events.out.tfevents.1720719086.Spike deleted file mode 100644 index d2b0aa457..000000000 Binary files a/logs/init/events.out.tfevents.1720719086.Spike and /dev/null differ diff --git a/logs/init/events.out.tfevents.1720719342.Spike b/logs/init/events.out.tfevents.1720719342.Spike deleted file mode 100644 index fb8c7797f..000000000 Binary files a/logs/init/events.out.tfevents.1720719342.Spike and /dev/null differ diff --git a/logs/runs/events.out.tfevents.1656543178.TempWin b/logs/runs/events.out.tfevents.1656543178.TempWin deleted file mode 100644 index f7e728ea4..000000000 Binary files a/logs/runs/events.out.tfevents.1656543178.TempWin and /dev/null differ diff --git a/logs/runs/events.out.tfevents.1656548905.TempWin b/logs/runs/events.out.tfevents.1656548905.TempWin deleted file mode 100644 index c12129114..000000000 Binary files a/logs/runs/events.out.tfevents.1656548905.TempWin and /dev/null differ diff --git a/logs/runs/events.out.tfevents.1673646087.Spike b/logs/runs/events.out.tfevents.1673646087.Spike deleted file mode 100644 index f2380edff..000000000 Binary files a/logs/runs/events.out.tfevents.1673646087.Spike and /dev/null differ diff --git a/logs/runs/events.out.tfevents.1673648326.Spike b/logs/runs/events.out.tfevents.1673648326.Spike deleted file mode 100644 index 18797cf2a..000000000 Binary files a/logs/runs/events.out.tfevents.1673648326.Spike and /dev/null differ diff --git a/logs/runs/events.out.tfevents.1678117372.Spike b/logs/runs/events.out.tfevents.1678117372.Spike deleted file mode 100644 index cb2402309..000000000 Binary files a/logs/runs/events.out.tfevents.1678117372.Spike and /dev/null differ diff --git a/logs/runs/events.out.tfevents.1682712186.Spike b/logs/runs/events.out.tfevents.1682712186.Spike deleted file mode 100644 index 6a4652a81..000000000 Binary files a/logs/runs/events.out.tfevents.1682712186.Spike and /dev/null differ diff --git a/logs/runs/events.out.tfevents.1687464074.Spike b/logs/runs/events.out.tfevents.1687464074.Spike deleted file mode 100644 index b06e2c14b..000000000 Binary files a/logs/runs/events.out.tfevents.1687464074.Spike and /dev/null differ diff --git a/logs/runs/events.out.tfevents.1687464505.Spike b/logs/runs/events.out.tfevents.1687464505.Spike deleted file mode 100644 index c61567a6d..000000000 Binary files a/logs/runs/events.out.tfevents.1687464505.Spike and /dev/null differ diff --git a/logs/runs/events.out.tfevents.1687736499.Spike b/logs/runs/events.out.tfevents.1687736499.Spike deleted file mode 100644 index bfffc6491..000000000 Binary files a/logs/runs/events.out.tfevents.1687736499.Spike and /dev/null differ diff --git a/logs/runs/events.out.tfevents.1694374827.Spike b/logs/runs/events.out.tfevents.1694374827.Spike deleted file mode 100644 index 6f8725fd5..000000000 Binary files a/logs/runs/events.out.tfevents.1694374827.Spike and /dev/null differ diff --git a/logs/runs/events.out.tfevents.1694374969.Spike b/logs/runs/events.out.tfevents.1694374969.Spike deleted file mode 100644 index 4c5d4c229..000000000 Binary files a/logs/runs/events.out.tfevents.1694374969.Spike and /dev/null differ diff --git a/logs/runs/events.out.tfevents.1694375010.Spike b/logs/runs/events.out.tfevents.1694375010.Spike deleted file mode 100644 index e875df891..000000000 Binary files a/logs/runs/events.out.tfevents.1694375010.Spike and /dev/null differ diff --git a/logs/runs/events.out.tfevents.1700165624.Spike b/logs/runs/events.out.tfevents.1700165624.Spike deleted file mode 100644 index d69466675..000000000 Binary files a/logs/runs/events.out.tfevents.1700165624.Spike and /dev/null differ diff --git a/logs/runs/events.out.tfevents.1703700212.Spike b/logs/runs/events.out.tfevents.1703700212.Spike deleted file mode 100644 index 3bc63e110..000000000 Binary files a/logs/runs/events.out.tfevents.1703700212.Spike and /dev/null differ diff --git a/logs/runs/events.out.tfevents.1711672057.Spike b/logs/runs/events.out.tfevents.1711672057.Spike deleted file mode 100644 index 8388ac087..000000000 Binary files a/logs/runs/events.out.tfevents.1711672057.Spike and /dev/null differ diff --git a/logs/runs/events.out.tfevents.1711672140.Spike b/logs/runs/events.out.tfevents.1711672140.Spike deleted file mode 100644 index 2127af911..000000000 Binary files a/logs/runs/events.out.tfevents.1711672140.Spike and /dev/null differ diff --git a/logs/runs/events.out.tfevents.1711673241.Spike b/logs/runs/events.out.tfevents.1711673241.Spike deleted file mode 100644 index c91acd31b..000000000 Binary files a/logs/runs/events.out.tfevents.1711673241.Spike and /dev/null differ diff --git a/logs/runs/events.out.tfevents.1711673760.Spike b/logs/runs/events.out.tfevents.1711673760.Spike deleted file mode 100644 index f9ced10f2..000000000 Binary files a/logs/runs/events.out.tfevents.1711673760.Spike and /dev/null differ diff --git a/logs/runs/events.out.tfevents.1711674764.Spike b/logs/runs/events.out.tfevents.1711674764.Spike deleted file mode 100644 index d430428c2..000000000 Binary files a/logs/runs/events.out.tfevents.1711674764.Spike and /dev/null differ diff --git a/logs/runs/events.out.tfevents.1711675116.Spike b/logs/runs/events.out.tfevents.1711675116.Spike deleted file mode 100644 index 40db99ccd..000000000 Binary files a/logs/runs/events.out.tfevents.1711675116.Spike and /dev/null differ diff --git a/logs/runs/events.out.tfevents.1711675170.Spike b/logs/runs/events.out.tfevents.1711675170.Spike deleted file mode 100644 index 07f0d19ac..000000000 Binary files a/logs/runs/events.out.tfevents.1711675170.Spike and /dev/null differ diff --git a/logs/runs/events.out.tfevents.1711675181.Spike b/logs/runs/events.out.tfevents.1711675181.Spike deleted file mode 100644 index d1fb8926b..000000000 Binary files a/logs/runs/events.out.tfevents.1711675181.Spike and /dev/null differ diff --git a/logs/runs/events.out.tfevents.1711675321.Spike b/logs/runs/events.out.tfevents.1711675321.Spike deleted file mode 100644 index 1a6250b15..000000000 Binary files a/logs/runs/events.out.tfevents.1711675321.Spike and /dev/null differ diff --git a/logs/runs/events.out.tfevents.1711675865.Spike b/logs/runs/events.out.tfevents.1711675865.Spike deleted file mode 100644 index 07ef43bca..000000000 Binary files a/logs/runs/events.out.tfevents.1711675865.Spike and /dev/null differ diff --git a/logs/runs/events.out.tfevents.1711721119.Spike b/logs/runs/events.out.tfevents.1711721119.Spike deleted file mode 100644 index f8f6084d9..000000000 Binary files a/logs/runs/events.out.tfevents.1711721119.Spike and /dev/null differ diff --git a/logs/runs/events.out.tfevents.1711723694.Spike b/logs/runs/events.out.tfevents.1711723694.Spike deleted file mode 100644 index 43192108a..000000000 Binary files a/logs/runs/events.out.tfevents.1711723694.Spike and /dev/null differ diff --git a/logs/runs/events.out.tfevents.1720719086.Spike b/logs/runs/events.out.tfevents.1720719086.Spike deleted file mode 100644 index be6e75986..000000000 Binary files a/logs/runs/events.out.tfevents.1720719086.Spike and /dev/null differ diff --git a/logs/runs/events.out.tfevents.1720719342.Spike b/logs/runs/events.out.tfevents.1720719342.Spike deleted file mode 100644 index 3a7dabf7e..000000000 Binary files a/logs/runs/events.out.tfevents.1720719342.Spike and /dev/null differ diff --git a/pyproject.toml b/pyproject.toml index 9d5844aad..d5cbb2bc1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -76,7 +76,7 @@ line_length = 88 src_paths = ["bindsnet", "test"] [tool.black] -target-version = ['py38'] +target-version = ['py311', 'py312', 'py313'] include = '\.pyi?$' exclude = ''' /( diff --git a/test/network/test_connections.py b/test/network/test_connections.py index fec421da2..d308bc604 100644 --- a/test/network/test_connections.py +++ b/test/network/test_connections.py @@ -1,6 +1,9 @@ -import torch import math +import torch + +import bindsnet.learning.MCC_learning as mcc +import bindsnet.network.topology_features as tf from bindsnet.learning import ( MSTDP, MSTDPET, @@ -13,8 +16,6 @@ from bindsnet.network import Network from bindsnet.network.nodes import Input, LIFNodes, SRM0Nodes from bindsnet.network.topology import * -import bindsnet.learning.MCC_learning as mcc -import bindsnet.network.topology_features as tf class TestConnection: diff --git a/test/network/test_learning_rule_specs.py b/test/network/test_learning_rule_specs.py index 7e64b547b..5dc343cec 100644 --- a/test/network/test_learning_rule_specs.py +++ b/test/network/test_learning_rule_specs.py @@ -85,11 +85,11 @@ from bindsnet.learning import ( DiehlAndCook, Hebbian, + MCC_learning, PostPre, Rmax, WeightDependentPostPre, ) -from bindsnet.learning import MCC_learning from bindsnet.models import DiehlAndCook2015 from bindsnet.network import Network from bindsnet.network.nodes import Input, LIFNodes, SRM0Nodes diff --git a/test/network/test_mstdp_florian.py b/test/network/test_mstdp_florian.py index 478a74b76..c147abe06 100644 --- a/test/network/test_mstdp_florian.py +++ b/test/network/test_mstdp_florian.py @@ -34,12 +34,12 @@ from bindsnet.network.nodes import Input, LIFNodes from bindsnet.network.topology import ( Connection, + Conv1dConnection, + Conv2dConnection, Conv3dConnection, LocalConnection1D, LocalConnection2D, LocalConnection3D, - Conv1dConnection, - Conv2dConnection, ) TOL = 1e-5 diff --git a/test/network/test_network.py b/test/network/test_network.py index 1cfcde255..4010d611c 100644 --- a/test/network/test_network.py +++ b/test/network/test_network.py @@ -1,4 +1,5 @@ import os + import pytest from bindsnet.network import Network, load diff --git a/test/network/test_perf_equivalence.py b/test/network/test_perf_equivalence.py index 0735fed5a..ba575e19d 100644 --- a/test/network/test_perf_equivalence.py +++ b/test/network/test_perf_equivalence.py @@ -26,8 +26,14 @@ import torch from bindsnet.encoding import rank_order -from bindsnet.learning import MSTDP, MSTDPET, Hebbian, PostPre, WeightDependentPostPre -from bindsnet.learning import MCC_learning +from bindsnet.learning import ( + MSTDP, + MSTDPET, + Hebbian, + MCC_learning, + PostPre, + WeightDependentPostPre, +) from bindsnet.learning.learning import ( _cached_decay, _dense_outer_update_ok,