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

The Initial version of CLP in CPU backend #707

Merged
merged 35 commits into from
Jul 18, 2023

Conversation

elvinhajizada
Copy link
Collaborator

@elvinhajizada elvinhajizada commented May 30, 2023

Issue Number: #706

Objective of pull request:
As a user, I want to be able to use the CLP algorithm in Lava, to learn continually from a stream of data in Loihi chip.

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?

  • We don't have any continual learning algorithm in Lava

What is the new behavior?

This PR is the first step in the full implementation of CLP. With this version of CLP, three base processes are implemented in the CPU backend and have been tested in terms of the following behaviors:

  • PrototypeLIF process generates the correct bAP signal if it receives a 3rd-factor input
  • PrototypeLIF process overwrites y1 trace with the value of the received 3rd-factor input, every time such an input is injected
  • The novelty can be detected from the coincidence between the presence of input and the absence of a subsequent output
  • Readout process outputs the predicted label
  • Readout process labels unlabeled winner neurons with user-provided label
  • Readout process checks the correctness of the predicted label against the user-provided actual label

In addition, several integration tests are written to test if LearningDense -> PrototypeLIF -> NoveltyDetection intengration works properly

Does this introduce a breaking change?

  • Yes
  • No

Supplemental information

@elvinhajizada elvinhajizada self-assigned this May 30, 2023
@elvinhajizada elvinhajizada added 1-feature New feature request 0-needs-review For all new issues 2-important/urgent Important and urgent issues labels May 30, 2023
@elvinhajizada
Copy link
Collaborator Author

All check have passes

@elvinhajizada
Copy link
Collaborator Author

Integration tests are added

Copy link
Contributor

@PhilippPlank PhilippPlank left a comment

Choose a reason for hiding this comment

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

Just glanced over it, will review in more detail after some questions.

  1. Why did you call it prototype_lif? It seems like a 3F learning LIF neuron. Also, is this usable in general? If yes, we should not hide it inside clp folder.
  2. What does nsm mean? The process is called Readout, I could not figure out what nsm stands for.
  3. I saw print statements in the PyNoveltyDetectorModel. I assume they are left overs from the development?

@elvinhajizada
Copy link
Collaborator Author

Just glanced over it, will review in more detail after some questions.

  1. Why did you call it prototype_lif? It seems like a 3F learning LIF neuron. Also, is this usable in general? If yes, we should not hide it inside clp folder.
  2. What does nsm mean? The process is called Readout, I could not figure out what nsm stands for.
  3. I saw print statements in the PyNoveltyDetectorModel. I assume they are left overs from the development?

@PhilippPlank

  1. Prototype LIF right now looks like a 3F learning LIF, because it is the first, simple of version. In upcoming releases we will add more features to this neuron model that will make it different from LIF (adaptive learning rate, adaptive threshold etc.) So right now it is just setting the interface that will be filled in later releases.
  2. NSM means "Neural State Machines". I planned it as a folder that will host possibly multiple processes. Right now it has only Readout process, because in this release of CLP, we just reading out network prediction. But later, we will need to receive user labels and create supervisory signals to inject into the network. Based on these we will perform both supervised and unsupervised learning. For that purpose we will need other CPU processes as interface between user and network in Loihi 2. So NSM is a general name for bunch of future processes that will control the learning, prediction, labeling states of the system.
  3. Yes, right I will remove those. Thanks for pointing out.

src/lava/proc/clp/nsm/process.py Outdated Show resolved Hide resolved
src/lava/proc/clp/prototype_lif/models.py Outdated Show resolved Hide resolved
tests/lava/proc/clp/integration/novelty_det_prototypes.py Outdated Show resolved Hide resolved
tests/lava/proc/clp/integration/novelty_det_prototypes.py Outdated Show resolved Hide resolved
tests/lava/proc/clp/integration/novelty_det_prototypes.py Outdated Show resolved Hide resolved
tests/lava/proc/clp/nsm/test_nsm.py Outdated Show resolved Hide resolved
tests/lava/proc/clp/nsm/test_nsm.py Outdated Show resolved Hide resolved
tests/lava/proc/clp/nsm/test_nsm.py Outdated Show resolved Hide resolved
tests/lava/proc/clp/nsm/test_nsm.py Show resolved Hide resolved
tests/lava/proc/clp/nsm/test_nsm.py Outdated Show resolved Hide resolved
Copy link
Contributor

@drager-intel drager-intel left a comment

Choose a reason for hiding this comment

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

Looks good now that all interfaces changes that we discussed have been incorporated. Thanks!

src/lava/proc/clp/novelty_detector/models.py Outdated Show resolved Hide resolved
src/lava/proc/clp/novelty_detector/process.py Outdated Show resolved Hide resolved
src/lava/proc/clp/novelty_detector/process.py Outdated Show resolved Hide resolved
@mgkwill mgkwill requested a review from bamsumit July 17, 2023 20:04
@drager-intel drager-intel merged commit 72fd653 into lava-nc:main Jul 18, 2023
monkin77 pushed a commit to monkin77/thesis-lava that referenced this pull request Jul 12, 2024
* CLP initial commit: PrototypeLIF, NoveltyDetector, Readout procs/tests

* small linting fix

* Novelty detector upgraded to target next neuron; codacy errors fixed

* integration test; small fixes

* removed duplicate code in prototypeLIF process; linting fixes

* linting fixes

* Linting and codacy fixes

* remove duplicate test; some more codacy fixes

* PrototypeLIF spikes when it recieves a 3rd factor input

* a test for PrototypeLIF output spike after 3rd factor input

* Allocation & prototype id tracking is abstracted away from
NoveltyDetector

* Allocator process; Readout proc sends allocation trigger if error

* introduce learning rate Var in PrototypeLIF

* updated integration tests; full system test included

* Linting fixes

* Another small lintint fix

* PrototypeLIF hard reset capability to enable faster temporal  WTA

* allocation mechanism changed; proc interfaces changes; dense conns
added; lr var removed

* small linting fix

* small codacy fix

* prints removed, spelling mistakes fixed

* ignoring one check in an integration test

* Revert "small linting fix"

This reverts commit bde4fa9.

* Fix linting in test_models.py

* Test fix in utils.py

* Fix test of bug fix in utils.py

* Fix utils.py

* Implemented individual threadsafe random call

Signed-off-by: bamsumit <[email protected]>

---------

Signed-off-by: bamsumit <[email protected]>
Co-authored-by: PhilippPlank <[email protected]>
Co-authored-by: Marcus G K Williams <[email protected]>
Co-authored-by: bamsumit <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0-needs-review For all new issues 1-feature New feature request 2-important/urgent Important and urgent issues
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants