Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev/learning rc 0.5 #332

Merged
merged 65 commits into from
Sep 23, 2022
Merged

Dev/learning rc 0.5 #332

merged 65 commits into from
Sep 23, 2022

Conversation

weidel-p
Copy link
Contributor

@weidel-p weidel-p commented Sep 7, 2022

Issue Number:

Objective of pull request:

This PR enables 2-factor online learning on CPU as a simulation of the Loihi learning engine.

The main changes are:

  • A LoihiLearningRule base class to create custom learning rules
  • STDPLoihi as a readily available learning rule in the Lava Process Library
  • Base class for connections containing all learning related Vars and Ports
  • Only Dense inherits from Connection being the only Process enabling online learning
  • A floating point and bit-approximate version of online learning
  • Two known-value tests for floating and bit-approximate 2F online learning
  • A tutorial to show the usage of STDPLoihi and how to create custom learning rules

Pull request checklist

Your PR fulfills the following requirements:

  • Issue created that explains the change and why it's needed
  • Tests are part of the PR (for bug fixes / features)
  • Docs reviewed and added / updated if needed (for bug fixes / features)
  • PR conforms to Coding Conventions
  • PR applys BSD 3-clause or LGPL2.1+ Licenses to all code files
  • Lint (flakeheaven lint src/lava tests/) and (bandit -r src/lava/.) pass locally
  • Build tests (pytest) passes locally

Pull request type

Please check your PR type:

  • Bugfix
  • Feature
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • Documentation changes
  • Other (please describe):

What is the current behavior?

What is the new behavior?

  • Activates online learning

Does this introduce a breaking change?

  • Yes
  • No

Supplemental information

Copy link
Contributor

@mathisrichter mathisrichter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After the live code review, I suggest the following changes before we merge.

  • Change the Connection base class back to its own LearningDense class for now until we have found a better solution.
  • Reorder the classes and methods in the modules by starting from the most important classes/methods at the top and putting everything that is used right underneath.
  • Create an issue to unit test at least the user interface.
  • Create an issue to refactor the code for reuse (removing the redundant implementation of the floating point and fixed point ProcModels).

Everything else looks good. Great job everyone!

Copy link
Contributor

@mathisrichter mathisrichter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only had a superficial look at the fixed-point ProcModel - looks good overall. See change requests for the PR in public Lava.

src/lava/magma/core/model/py/connection.py Outdated Show resolved Hide resolved
src/lava/magma/core/model/py/connection.py Outdated Show resolved Hide resolved
src/lava/magma/core/model/py/connection.py Show resolved Hide resolved
src/lava/magma/core/model/py/connection.py Show resolved Hide resolved
src/lava/magma/core/model/py/connection.py Show resolved Hide resolved
@weidel-p weidel-p merged commit 9471303 into main Sep 23, 2022
monkin77 pushed a commit to monkin77/thesis-lava that referenced this pull request Jul 12, 2024
* inheritance from base class

* inheritance from base connection

* floating point model

* minor cleanup

* added neuron base class

* separate models from process files

* rm init file

* inherit from Neuron and Connection

* merged LearningDense into Dense

* release candidate 0.5a

* beginning last clean

* clean in progress

* updated tutorial

* changes according to checklist made. missing use of np.where refactor

* changed evaluate_trace to use boolean indexing instead of np.where

* removed BITS_

* lint and poetry update

* moved tutorial to in_depth

* Licenses

* lint tests

* poetry update

* docstrings for connection and learning rule

* fixing typo

* minor optimization for floating point model

* added learning related unit tests

* added other learning related unit tests

* refactored docstrings

* merged Loihi1 and 2 LearningRules and added seed for RNGs

* fixing failing tests

* fixing lint errors

* fixing lint errors

* fixing failing tests

* fixing failing tests

* docstrings and minor changes

* adding apply_mask to learning/utils

* lint and rng seed

* pulled pyproject and poetry from main

* re-add asteval as dependency

* vectorizing decompose_impulses, adding some constants

* typos

* return of the LearningDense class

* Connection base class to reduce code duplication

* lint

* rm learning rule base class

* minor bug fix

* added tutorial for custom learning rules

* added test for LearningDense process

* pull lock and pyproject from main

* added tests for multisynapse learning

* use LearningDense in tests

Co-authored-by: gkarray <[email protected]>
Co-authored-by: Marcus G K Williams <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants