Coder Social home page Coder Social logo

lava-nc / lava-dnf Goto Github PK

View Code? Open in Web Editor NEW
41.0 12.0 19.0 13.04 MB

Dynamic Neural Fields with Lava

License: BSD 3-Clause "New" or "Revised" License

Python 0.90% Jupyter Notebook 99.10%
dynamic-neural-fields python neuromorphic neuromorphic-computing

lava-dnf's Introduction

Dynamic Neural Fields

Introduction

Dynamic Neural Fields (DNF) are neural attractor networks that generate stabilized activity patterns in recurrently connected populations of neurons. These activity patterns form the basis of neural representations, decision making, working memory, and learning. DNFs are the fundamental building block of dynamic field theory, a mathematical and conceptual framework for modeling cognitive processes in a closed behavioral loop.

2D DNF tracking bias input
Voltage of a selective dynamic neural field tracking moving input

What is lava-dnf?

lava-dnf is a library within the Lava software framework. The main building blocks in Lava are processes. lava-dnf provides processes and other software infrastructure to build architectures composed of DNFs. In particular, it provides functions that generate connectivity patterns common to DNF architectures.

The primary focus of lava-dnf today is on robotic applications: sensing and perception, motion control, behavioral organization, map formation, and autonomous (continual) learning. Neuromorphic hardware provides significant gains in both processing speed and energy efficiency compared to conventional implementations of DNFs on a CPU or GPU (e.g., using cedar or cosivina).

Key features

Building DNF architectures

  • Based on spiking neurons
  • DNF dimensionality support for 0D, 1D, 2D, and 3D
  • Recurrent connectivity based on kernel functions
  • Forward connectivity to connect multiple DNFs
  • Structured input from spike generators

Running DNF architectures

  • On CPU (Python simulation)
  • On Loihi 2

Examples demonstrating basic DNF regimes and instabilities

  • Detection of input
  • Selection of input
  • Working memory of input
  • Relational networks

Installation

We highly recommend cloning the repository and using poetry to set up lava-dnf, provided you only want to run lava-dnf in simulation. This will automatically also install lava.

Note: For INRC members who want to run lava-dnf on Loihi 2 hardware, we recommend following the install instructions for the Lava-on-Loihi extension.

Linux/MacOS

$ cd $HOME
$ git clone [email protected]:lava-nc/lava-dnf.git
$ cd lava-dnf
$ curl -sSL https://install.python-poetry.org | python3
$ poetry config virtualenvs.in-project true
$ poetry install
$ source .venv/bin/activate
$ pytest

Windows (PowerShell)

# Commands using PowerShell
cd $HOME
git clone https://github.com/lava-nc/lava-dnf.git
cd lava-dnf
python -m venv .venv
set-executionpolicy remotesigned  # only required on first execution
.venv\Scripts\activate
curl.exe -sSL https://install.python-poetry.org | python -
# Include the directory where poetry was installed into the PATH variable.
pip install -U pip
poetry config virtualenvs.in-project true
poetry install
pytest

You should expect the following output after running the unit tests with pytest.

$ pytest
================================================= test session starts =================================================
platform win32 -- Python 3.9.12, pytest-7.2.0, pluggy-1.0.0
rootdir: C:\Users\username\lava-dnf, configfile: pyproject.toml, testpaths: tests
plugins: cov-3.0.0
collected 210 items

tests\lava\lib\dnf\acceptance\test_connecting_with_ops.py .......                                                [  3%]
tests\lava\lib\dnf\acceptance\test_gauss_spike_generator.py .                                                    [  3%]
tests\lava\lib\dnf\connect\test_connect.py .............                                                         [ 10%]
tests\lava\lib\dnf\connect\test_exceptions.py .                                                                  [ 10%]
[...]
tests\lava\lib\dnf\utils\test_plotting.py ....                                                                   [ 96%]
tests\lava\lib\dnf\utils\test_validation.py .....                                                                [ 98%]
tests\lava\tutorials\test_tutorials.py sss                                                                       [100%]

=============================== warnings summary ===============================
[...]

---------- coverage: platform win32, python 3.9.12-final-0 -----------
Name                                                     Stmts   Miss  Cover   Missing
--------------------------------------------------------------------------------------
src\lava\lib\dnf\connect\connect.py                         49      0   100%
src\lava\lib\dnf\connect\exceptions.py                       6      1    83%   20
[...]
src\lava\lib\dnf\utils\plotting.py                          29      0   100%
src\lava\lib\dnf\utils\validation.py                        18      2    89%   28, 38
--------------------------------------------------------------------------------------
TOTAL                                                      806     13    98%

Required test coverage of 65.0% reached. Total coverage: 98.39%
===================================== 207 passed, 3 skipped, 2 warnings in 28.78s =====================================

Example

from lava.proc.lif.process import LIF
from lava.lib.dnf.kernels.kernels import SelectiveKernel
from lava.lib.dnf.connect.connect import connect
from lava.lib.dnf.operations.operations import Convolution

# Create a population of 20x20 spiking neurons.
dnf = LIF(shape=(20, 20))

# Create a selective kernel.
kernel = SelectiveKernel(amp_exc=18, width_exc=[4, 4], global_inh=-15)

# Apply the kernel to the population to create a DNF with a selective regime.
connect(dnf.s_out, dnf.a_in, [Convolution(kernel)])

Recommend Projects

  • React photo React

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

  • Vue.js photo Vue.js

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

  • Typescript photo Typescript

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

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

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

Recommend Topics

  • javascript

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

  • web

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

  • server

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

  • Machine learning

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

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

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

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

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

  • D3 photo D3

    Data-Driven Documents codes.