Skip to content

Commit

Permalink
Initial release of lava-dnf v0.1.0 (#8)
Browse files Browse the repository at this point in the history
* Removed placeholder file

* Removed 'lib' from gitignore

Signed-off-by: Mathis Richter <[email protected]>

* Added Population Process and shape validation

Signed-off-by: Mathis Richter <[email protected]>

* Added Population SubProcessModel

Signed-off-by: Mathis Richter <[email protected]>

* Make unit test for Population ProcessModel ports more explicit

Signed-off-by: Mathis Richter <[email protected]>

* Unit test that executes a Population

Signed-off-by: Mathis Richter <[email protected]>

* Modified Population ProcessModel unit test to use get_src_ports/get_dst_ports

Signed-off-by: Mathis Richter <[email protected]>

* Added convenience function num_neurons()

Signed-off-by: Mathis Richter <[email protected]>

* Added first version of connect() function

Signed-off-by: Mathis Richter <[email protected]>

* Added missing __init__ file

Signed-off-by: Mathis Richter <[email protected]>

* Added num_dims function

Signed-off-by: Mathis Richter <[email protected]>

* Added configuration functionality to operations

Signed-off-by: Mathis Richter <[email protected]>

* Added basic configuration of operations in connect()

Signed-off-by: Mathis Richter <[email protected]>

* Added additional top-level lava directory and moved lib inside

Signed-off-by: Mathis Richter <[email protected]>

* Refactored connect unit tests

Signed-off-by: Mathis Richter <[email protected]>

* Added check for multiple operations that change shape (not yet implemented)

Signed-off-by: Mathis Richter <[email protected]>

* Weights are computed for all operations

Signed-off-by: Mathis Richter <[email protected]>

* Fixed linter error

Signed-off-by: Mathis Richter <[email protected]>

* Unit testing only against the public API of connect

Signed-off-by: Mathis Richter <[email protected]>

* Doc strings for operations module

Signed-off-by: Mathis Richter <[email protected]>

* Added exception for misconfigured operations

Signed-off-by: Mathis Richter <[email protected]>

* Refactored validation of operations using exceptions rather than boolean returns

Signed-off-by: Mathis Richter <[email protected]>

* Added Weights operation

Signed-off-by: Mathis Richter <[email protected]>

* Unit test for computing weights now covers shapes of 0d-3d

Signed-off-by: Mathis Richter <[email protected]>

* Major rewrite of operations; now supporting multiple operations that change shape.

Signed-off-by: Mathis Richter <[email protected]>

* Added ReduceDims Operation

Signed-off-by: Mathis Richter <[email protected]>

* Removed redundant unit test for connect function

Signed-off-by: Mathis Richter <[email protected]>

* Added AbstractExpandDimsOperation

Signed-off-by: Mathis Richter <[email protected]>

* Added ExpandDims Operation

Signed-off-by: Mathis Richter <[email protected]>

* Refactored projection function to simplify interface

Signed-off-by: Mathis Richter <[email protected]>

* Added Reorder Operation (wip, some redesign required)

Signed-off-by: Mathis Richter <[email protected]>

* Rough draft of inputs module

Signed-off-by: Mathis Richter <[email protected]>

* Refactored operations, extracting the handling of shapes

Signed-off-by: Mathis Richter <[email protected]>

* Added acceptance tests in tests/acceptance; moved unit tests to tests/unit

Signed-off-by: Mathis Richter <[email protected]>

* Moved operation enums into separate module

Signed-off-by: Mathis Richter <[email protected]>

* Minor changes to docstrings

Signed-off-by: Mathis Richter <[email protected]>

* Added additional top-level 'src' directory and 'lava' directory under 'tests'

Signed-off-by: Mathis Richter <[email protected]>

* GaussInputPattern + SpikeInputGenerator + BiasInputGenerator and draft Source Processes

* updating .gitignore

* Cosmetics on imports

Signed-off-by: Mathis Richter <[email protected]>

* Added is_odd() helper function

Signed-off-by: Mathis Richter <[email protected]>

* Added BorderType enum

Signed-off-by: Mathis Richter <[email protected]>

* Fixed docstrings

Signed-off-by: Mathis Richter <[email protected]>

* Added rudimentary Kernel class to support development of Convolution operation

Signed-off-by: Mathis Richter <[email protected]>

* Added Convolution operation

Signed-off-by: Mathis Richter <[email protected]>

* Fixed linter warnings

Signed-off-by: Mathis Richter <[email protected]>

* Fixed security linter error

Signed-off-by: Mathis Richter <[email protected]>

* GaussInputPattern + SpikeInputGenerator done. SpikeSource not running.

* Updated CI/CD based on lava-optimization

Signed-off-by: Mathis Richter <[email protected]>

* Added pybuilder dependency

Signed-off-by: Mathis Richter <[email protected]>

* First draft of a DNF 101 tutorial

Signed-off-by: Mathis Richter <[email protected]>

* Added gauss() function

* Added SelectiveKernel

* Fixed linter error

* Renamed bias_mant to bias in Population

* Added MultiPeakKernel

* Updated example in README to new API

* SpikeInput refactoring (wip)

* GaussPattern + SpikeGenerator. Missing unit tests and documentation.

* Updated the DNF 101 tutorial

This makes assumptions about future changes to inputs and monitors.

* Reordered sections of DNF tutorial and fixed minor issues

* Documentation + refactor GaussPattern param validation + fixing linting errors.

* Restructuring inputs directory

* Unit testing.

* Temporary placeholder for missing ReshapePorts

* Adding parameters to SpikeGenerator + refactoring unit tests.

* Skipping unit tests that have non-deterministic behavior

* Skipping unit tests that have non-deterministic behavior

* Changed __init__.py files to new Lava convention

* Removed one more __init__.py file

* Removed two more __init__.py files

* Updated tutorial after feedback

* Fixed non-determinism in unit tests (#3)

Co-authored-by: gkarray <[email protected]>

* Update requirements.txt (#2)

* Fixed bugs in tutorial

* Update requirements.txt

* Update build.py

Add project.build_depends_on("lava", url="git+https://github.com/lava-nc/lava.git) to build.py

* ci-build.yml: Only run unit tests on Windows

* Update ci-build.yml

* Moved unit tests to be consistent with lava test directory structure

* Replaced np.bool/np.int with bool/int

* Replaced tau parameters with decay

* Added complete type annotations

* Capitalized comments

* Removed Population Process and replaced it with LIF

* Addressing pending error, RuntimeWarning and adding few comments.

* Update ci-build.yml

* Added preliminary but working raster plot

* Updated tutorial to include Monitors and raster plots

* Cosmetic changes to visible documents

* Updated tutorial to work with new Dense implementations

* Split off examples from DNF 101 tutorial

* Docstring cosmetics

* Minor correction in RateCodeSpikeGen + restructure and unit testing plotting.py

* Operations in connect function are now optional

* Fixed linter errors

* Homogenizing asserts in plotting's unit tests.

* Reverting plotting functions to old (num_time_steps, num_neurons) shape convention

* Refactoring tutorial_dnf_regimes.ipynb

* Adding colorbar to tutorial_dnf_regimes.ipynb plots.

* Updated tutorials

* Adding animated plot for dnf_regimes tutorial

* Fixing linter errors.

* Updated animated plots and added them to DNF regime tutorial

* Fixed unit tests that needed changes but were blocked by PR #96

Signed-off-by: Mathis Richter <[email protected]>

* Removed tags from Process Models, anticipating changes in PR#96

Signed-off-by: Mathis Richter <[email protected]>

* Fixed typo in tutorial

Signed-off-by: Mathis Richter <[email protected]>

Co-authored-by: Ghassen Karray <[email protected]>
Co-authored-by: gkarray <[email protected]>
Co-authored-by: Marcus G K Williams <[email protected]>
  • Loading branch information
4 people authored Nov 29, 2021
1 parent 08be0e3 commit 5deb525
Show file tree
Hide file tree
Showing 57 changed files with 6,658 additions and 39 deletions.
10 changes: 3 additions & 7 deletions .github/workflows/ci-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,9 @@ jobs:
run: |
python -m pip install --upgrade pip
pip install pybuilder
- name: Run pybuilder w/o unit tests
run: |
pyb analyze
security-lint:
name: Security Lint with bandit
runs-on: ubuntu-latest
Expand All @@ -39,17 +37,15 @@ jobs:
run: |
python -m pip install --upgrade pip
pip install pybuilder
- name: Run pybuilder to lint security w/ bandit
run: |
pyb bandit
unit-tests:
name: Run unit tests
runs-on: ${{ matrix.operating-system }}
strategy:
matrix:
operating-system: [ubuntu-latest, windows-latest, macos-latest]
operating-system: [ubuntu-latest, macos-latest]

steps:
- uses: actions/checkout@v2
Expand All @@ -63,7 +59,7 @@ jobs:
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install pybuilder
- name: Run unit tests
run: |
python -m unittest discover -s tests -p "test_*.py" -vvv
pyb -E unit
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@ venv.bak/
.spyderproject
.spyproject

# vscode project settings
.vscode/

# Rope project settings
.ropeproject

Expand Down
20 changes: 6 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,29 +41,21 @@ Examples demonstrating basic DNF regimes and instabilities
- Detection of input
- Selection of input
- Working memory of input
- Neural oscillator

Infrastructure
- Sensor and data input/output
- Plotting

## Example

```python
from lava.lib.dnf.populations import Population
from lava.lib.dnf.kernels import SelectiveKernel
from lava.lib.dnf.connect import connect
from lava.lib.dnf.operations import Instar, OneToOne
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 population of 20x20 spiking neurons
dnf = Population(shape=(20, 20))
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, dnf, [Instar(kernel)])
connect(dnf.s_out, dnf.a_in, [Convolution(kernel)])
```



31 changes: 16 additions & 15 deletions build.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,22 @@
# use_plugin("python.coverage")
use_plugin("python.distutils")
use_plugin("python.sphinx")
use_plugin('python.install_dependencies')
use_plugin("python.install_dependencies")
use_plugin("python.pycharm")
use_plugin('pypi:pybuilder_bandit')
use_plugin("pypi:pybuilder_bandit")

name = "lava-dnf"
default_task = ["analyze", "publish"]
version = "0.1.0"
summary = "A library that provides processes and other software infrastructure to build architectures composed of Dynamic Neural Fields (DNF). This library also provides tools to direct sensory input to neural architectures and to read output, for instance for motor control. Lava-DNF is part of Lava Framework "
summary = "A library that provides processes and other software infrastructure to build architectures composed of Dynamic Neural Fields (DNF)."
url = "https://lava-nc.org"
license = ["BSD-3-Clause"]


@init
def set_properties(project):
project.set_property("dir_source_main_python", "src/lava")
project.set_property("dir_source_unittest_python", "tests")
project.set_property("dir_source_main_python", "src")
project.set_property("dir_source_unittest_python", "tests/lava")
project.set_property("dir_source_main_scripts", "scripts")
project.set_property("dir_docs", "docs")

Expand Down Expand Up @@ -53,20 +53,21 @@ def set_properties(project):
"target/*,.svn,CVS,.bzr,.hg,.git,__pycache__,.pybuilder/*",
)

project.get_property('distutils_commands').append('build')
project.get_property('distutils_commands').append('sdist')
project.get_property('distutils_commands').append('bdist_dumb')
project.get_property("distutils_commands").append("build")
project.get_property("distutils_commands").append("sdist")
project.get_property("distutils_commands").append("bdist_dumb")

project.set_property('bandit_break_build', True)
project.set_property('bandit_include_testsources', False)
project.set_property("bandit_break_build", True)
project.set_property("bandit_include_testsources", False)


@init(environments="unit")
def set_properties_unit(project):
project.set_property("dir_source_main_python", "src/lava")
project.set_property("dir_source_unittest_python", "tests")
project.set_property("dir_source_main_python", "src")
project.set_property("dir_source_unittest_python", "tests/lava")
project.set_property("dir_source_main_scripts", "scripts")
project.set_property("dir_docs", "docs")
project.build_depends_on("lava", url="git+https://github.com/lava-nc/lava.git")

project.set_property("sphinx_config_path", "docs")
project.set_property("sphinx_source_dir", "docs")
Expand All @@ -82,7 +83,7 @@ def set_properties_unit(project):
project.plugin_depends_on("sphinx_tabs")

project.set_property("verbose", True)

project.set_property("coverage_threshold_warn", 0)
project.set_property("coverage_break_build", False)

Expand All @@ -96,5 +97,5 @@ def set_properties_unit(project):

project.set_property("unittest_module_glob", "test_*")

project.set_property('bandit_break_build', True)
project.set_property('bandit_include_testsources', False)
project.set_property("bandit_break_build", True)
project.set_property("bandit_include_testsources", False)
3 changes: 3 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
lava-nc@git+https://github.com/lava-nc/lava.git
numpy
scipy>=1.7.2
11 changes: 9 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import shutil

from sys import version_info

py3 = version_info[0] == 3
py2 = not py3
if py2:
Expand All @@ -41,7 +42,9 @@

def install_pyb():
try:
subprocess.check_call([sys.executable, "-m", "pip", "install", "pybuilder"])
subprocess.check_call(
[sys.executable, "-m", "pip", "install", "pybuilder"]
)
except subprocess.CalledProcessError as e:
sys.exit(e.returncode)

Expand All @@ -64,11 +67,13 @@ def install_pyb():

try:
from pybuilder.cli import main

# verbose, debug, skip all optional...
if main("-v", "-X", "-o", "--reset-plugins", "clean", "package"):
raise RuntimeError("PyBuilder build failed")

from pybuilder.reactor import Reactor

reactor = Reactor.current_instance()
project = reactor.project
dist_dir = project.expand_path("$dir_dist")
Expand All @@ -83,7 +88,9 @@ def install_pyb():
os.remove(target_file_name)
shutil.move(src_file, script_dir)
setup_args = sys.argv[1:]
subprocess.check_call([sys.executable, "setup.py"] + setup_args, cwd=script_dir)
subprocess.check_call(
[sys.executable, "setup.py"] + setup_args, cwd=script_dir
)
except subprocess.CalledProcessError as e:
exit_code = e.returncode
sys.exit(exit_code)
1 change: 0 additions & 1 deletion src/lava/lib/dnf/README.md

This file was deleted.

Loading

0 comments on commit 5deb525

Please sign in to comment.