Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Processes for Event-based data loading and pre-processing #514
Processes for Event-based data loading and pre-processing #514
Changes from 4 commits
452e68e
77dc965
d1ac4f5
5a89aa6
9018466
18fff7d
ddb3bb7
877ed67
093605f
ee81533
57c8929
6b15db9
1bd6346
be276bd
4869e31
3554e89
fc79a24
0c54139
1bbcc66
5e48595
34e752a
08415dc
dc02db1
1581cac
5fbac8b
4ab5d1e
082c9c9
7c4f1b4
099259f
3f5ee2d
283b296
6d8a4dc
2617193
a6778a4
ffac5f6
5a8ceb2
354340a
d795530
20a85bf
b358462
d1c7e89
fbe3653
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This has to be a tuple with a single entry, right? With
typing
you could doNot sure whether that also works with regular types as type annotations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
implemented this, it does indeed show a warning if we give a tuple with more than one entry. Do you think the validation step that checks if the shape is invalid can be deleted then?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Leave it in for now. The shape always having to be one-dimensional is a bit odd anyway, so better make sure that users get an error when they do not see this. The warning only shows up in IDEs that support it and will not have any impact on running the code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove
kwargs
if you are not using them.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing type annotations
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In Lava, we usually do not validate types. We use type annotations instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done, implemented every where type annotations were not used
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Keep in mind though that the type annotations are just hints, they do not check anything at runtime (see my other comment above). So, wherever you think it is crucial, I would still add a validation that throws an exception. Otherwise, just leave it out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For now if the user inputs an invalid dimension or negative values in the shapes it throws an error. I guess we can keep it like this for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would move this into the
self._encode_data_and_indices
method. You don't need the split up data in therun_spk
method again.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done,
events
is sent intoself._encode_data_and_indices
as a parameter but we're not sure of the type of "events", will have to look into this further.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like some sort of
dict
, maybetyping.Dict[str, int]
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's what we put in for now, yes. I guess it will do, but Ghassen thinks it is some sort of numpy specific type (something like structured arrays?). It shouldn't really matter though as the data is accessed in the same way as in a dict.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does this do?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this makes it so that once we reach the end of the file we loop back to the beginning. Added a comment for clarity.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, nice! This should also be documented later in the docstring, in particular, since this behavior cannot be switched off at the moment. In the future, I would expect a
loop: bool
flag in the Process but we can do that feature later.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems like a function that could be used for any event-data. Can we make this a function instead that takes
data
,indices
, and amax_events
and then does the subsampling independently of theAedatDataLoader
class?You can then also remove the random number generator from the class.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_sub_sample
has been made a function (sub_sample
), that takesdata, indices, max_events,
andseed_random
. It is called in therun_spk
of theaedat_data_loader
, and should also be available outside the class. Should it stay in aedat_data_loader.py or should it be moved somewhere else?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That will have to be moved somewhere else, maybe a new module
lava/src/lava/utils/events.py
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add the warning and remove the TODO.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done, warning is:
warnings.warn(f"Read {data.shape[0]} events. Maximum number of events is {max_events}. " f"Removed {data.shape[0] - max_events} events by subsampling.")
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it would be nice to add the percentage of removed events to the warning.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done