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

NMNIST tutorial is added #67

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

Conversation

ahmetakman
Copy link

Signed-off-by: ahmetakman [email protected]

Issue Number: #66

The objective of pull request: I have created a notebook that implements the conversion of the network created in the Slayer NMNIST tutorial.

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

Tutorial contribution.

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): Example tutorial addition.

What is the current behavior?

  • Seems working very well, but sometimes NMNIST dataset source download may fail as it is in the slayer NMNIST tutorial.

Does this introduce a breaking change?

  • Yes
  • No

Supplemental information

Signed-off-by: ahmetakman <[email protected]>
if self.transform is not None:
event = self.transform(event)
spike = event.fill_tensor(
np.zeros((2, 34, 34, self.num_time_bins)),
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess the only difference between the dataloader here and the dataloader for training is this line. So I would suggest deriving this NMNISTdataset class from tutorials.lava.lib.dl.slayer.nmnist.NMNISTdataset and just override the getitem(). It would just be conversion of spike from torch to numpy. spike = spike_torch.cpu().data.numpy()

Copy link
Author

Choose a reason for hiding this comment

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

Oh, I see; I did not know that NMNIST is included in the library. I just took the NMNIST slayer tutorial as the reference. Thanks for the advice.

@bamsumit
Copy link
Contributor

bamsumit commented Apr 10, 2022

@ahmetakman Thanks for contributing the tutorial :). I have a few comments/suggestions on run.ipynb.

I would like to point you to the existing lava.proc.io.dataloader.SpikeDataLoader for spike input and lava.proc.io.sink.RingBuffer for reading spike output.

sink.RingBuffer does not accumulate the spike values now. I suggest just accumulating the spikes post-run or even better contributing spike counter functionality to lava.proc.io.sink.RingBuffer. That way the notebook tutorial does not need custom IO process definition and thus becomes more clear. Also these capabilies can be reused by other examples in the future.

@ahmetakman
Copy link
Author

Actually, I first tried to implement using the ring buffers, but I could not make it work. I need to look back and try again for that.

@ahmetakman
Copy link
Author

I am now available to implement with ring buffers. Since my first attempt was unsuccessful could you provide some informational document (or any useful resource) about ring buffers in LAVA?

@bamsumit
Copy link
Contributor

bamsumit commented May 3, 2022

@ahmetakman here is a brief description about RingBuffer sink.

lava.proc.io.sink.RingBuffer just stores the data it gets in its input port. The size of the Ringbuffer is defined by the buffer parameter. Once the data exceeds the buffer, the data gets overwritten from index zero. So, for e.g., if you want spike data for 1000 time steps, your buffer needs to be 1000 for the data to not get overwritten.

Here are a couple of examples of RingBuffer being used to read and log spikes.

@ahmetakman
Copy link
Author

It has been a while and now I have have time to work on the lava again. It has been a wild semester I thought it will never end. I will look through it to finally finish this pull request.

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.

4 participants