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

MSE regression #98

Merged
merged 26 commits into from
Jul 8, 2024
Merged

MSE regression #98

merged 26 commits into from
Jul 8, 2024

Conversation

neworderofjamie
Copy link
Contributor

@neworderofjamie neworderofjamie commented Jun 25, 2024

This PR extends the existing mechanism in the EventProp compiler used to support 'per-timestep' cross-entropy loss to also supports mean-squared error loss for regression tasks. Using this, the pattern recognition task (previously used as an e-prop example) has been implemented as an EventProp example (encountering #101 and #102 in the process)

Also, this PR fixes a number of corner cases involving recording of non-batched variables in batched simulations and implements ConnVarRecorder for recording from Connection objects.

Fixes #52

tnowotny and others added 10 commits June 24, 2024 18:03
…the per

timestep errors that drive lambda_V.
Added code to fill the ringbuffer and code for the drive of lambda_V.
… and runs but not yet successful in doing a regression.

Also fixed n error in spike_recorder where the event recording flag was missing. Fixed two occurrences of pull_var_from_device.
… the pattern_recognition example.

Everythig is compiling and running but there is no learning; in particular, no detectable systematic changes
across epochs - not even in terms of regularisation of the hidden layer.
…e's fix for this. Changed how the per_times_step_loss

code block is activated for loss_mse.
@neworderofjamie neworderofjamie added enhancement New feature or request EventProp labels Jun 27, 2024
@neworderofjamie neworderofjamie added this to the mlGeNN 2.3 milestone Jun 27, 2024
Copy link
Contributor Author

@neworderofjamie neworderofjamie left a comment

Choose a reason for hiding this comment

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

All looks good aside from some very minor formatting I've suggested

ml_genn/ml_genn/compilers/event_prop_compiler.py Outdated Show resolved Hide resolved
ml_genn/ml_genn/compilers/event_prop_compiler.py Outdated Show resolved Hide resolved
ml_genn/ml_genn/compilers/event_prop_compiler.py Outdated Show resolved Hide resolved
ml_genn/ml_genn/compilers/event_prop_compiler.py Outdated Show resolved Hide resolved
ml_genn/ml_genn/compilers/event_prop_compiler.py Outdated Show resolved Hide resolved
Comment on lines 98 to 107
'''
for (pop,pypop) in compiled_net.neuron_populations.items():
print(pypop.model.get_sim_code())
for var in pypop.model.get_vars():
print(var.name)
for para in pypop.model.get_params():
print(para.name)
for dp in pypop.model.get_derived_params():
print(dp.name)
'''
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Suggested change
'''
for (pop,pypop) in compiled_net.neuron_populations.items():
print(pypop.model.get_sim_code())
for var in pypop.model.get_vars():
print(var.name)
for para in pypop.model.get_params():
print(para.name)
for dp in pypop.model.get_derived_params():
print(dp.name)
'''

Comment on lines 120 to 122
VarRecorder(output, genn_var="LambdaV", key="output_lambdav"),
VarRecorder(output, genn_var="LambdaI", key="output_lambdai"),
SynVarRecorder(h2o, genn_var="dw", key="h2o_dw"),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure if we want to record all internal state in the example

ml_genn/ml_genn/callbacks/spike_recorder.py Outdated Show resolved Hide resolved
ml_genn/ml_genn/callbacks/var_recorder.py Show resolved Hide resolved
tnowotny and others added 8 commits June 27, 2024 09:47
…not be recorded correctly in batched simulations
* Added in corner case fixed from ``VarRecorder``
* Added ``get_underlying_conn`` helper to handle getting connectivity from ``Layer`` objects
* Added source and target neuron masks for recording
Those all look good.

Co-authored-by: neworderofjamie <[email protected]>
@codecov-commenter
Copy link

codecov-commenter commented Jun 27, 2024

Codecov Report

Attention: Patch coverage is 59.71223% with 56 lines in your changes missing coverage. Please review.

Project coverage is 66.08%. Comparing base (42c7fae) to head (fa2b6f7).
Report is 5 commits behind head on master.

Files Patch % Lines
ml_genn/ml_genn/compilers/event_prop_compiler.py 4.25% 45 Missing ⚠️
ml_genn/ml_genn/callbacks/conn_var_recorder.py 89.55% 7 Missing ⚠️
ml_genn/ml_genn/utils/network.py 75.00% 2 Missing ⚠️
ml_genn/ml_genn/callbacks/var_recorder.py 92.30% 1 Missing ⚠️
ml_genn_tf/ml_genn_tf/converters/spike_norm.py 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master      #98      +/-   ##
==========================================
+ Coverage   65.92%   66.08%   +0.15%     
==========================================
  Files         100      101       +1     
  Lines        4024     4125     +101     
==========================================
+ Hits         2653     2726      +73     
- Misses       1371     1399      +28     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@tnowotny tnowotny left a comment

Choose a reason for hiding this comment

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

I think this is ready to be merged as far as I can see?

@neworderofjamie neworderofjamie marked this pull request as ready for review July 1, 2024 09:00
Copy link
Contributor Author

@neworderofjamie neworderofjamie left a comment

Choose a reason for hiding this comment

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

couple of typos but all looks good aside from a bit of documentation on ConnVarRecorder

ml_genn/ml_genn/callbacks/__init__.py Outdated Show resolved Hide resolved
ml_genn/ml_genn/losses/mean_square_error.py Outdated Show resolved Hide resolved
Copy link
Member

@tnowotny tnowotny left a comment

Choose a reason for hiding this comment

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

I think this looks good to go.

@neworderofjamie neworderofjamie merged commit 42216b4 into master Jul 8, 2024
1 check passed
@neworderofjamie neworderofjamie deleted the mse_regression branch July 8, 2024 13:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request EventProp
Projects
None yet
Development

Successfully merging this pull request may close these issues.

VarRecorder should be able to record connection variables
3 participants