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

Fix issue with first spike passing through adaptive synapse #3384

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

clinssen
Copy link
Contributor

The fix for first spike passing through an adaptive synapse in #1672 was erroneous and affects more than just the first spike. This PR fixes the fix.

@clinssen clinssen added the T: Bug Wrong statements in the code or documentation label Dec 16, 2024
@clinssen clinssen requested a review from tomtetzlaff February 24, 2025 10:41
@terhorstd terhorstd added S: High Should be handled next I: No breaking change Previously written code will work as before, no one should note anything changing (aside the fix) labels Feb 26, 2025
@heplesser
Copy link
Contributor

@tomtetzlaff Ping!

Copy link
Contributor

@heplesser heplesser left a comment

Choose a reason for hiding this comment

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

@clinssen Thanks for this PR. It looks mostly good to me, but see my small suggestions inline. Could you add a little more text to the PR description to explain why/how things go wrong with the current implementation? Just for future reference.

tsodyks_params = dict(fac_params, synapse_model="tsodyks_synapse") # for tsodyks_synapse
tsodyks2_params = dict(fac_params, synapse_model="tsodyks2_synapse") # for tsodyks2_synapse
tsodyks_params = dict(dep_params, synapse_model="tsodyks_synapse") # for tsodyks_synapse
tsodyks2_params = dict(dep_params, synapse_model="tsodyks2_synapse") # for tsodyks2_synapse
Copy link
Contributor

Choose a reason for hiding this comment

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

I find it strange that both dep and fac parameters are given above, but only one of the sets is used, without any further explanation. It is also not clear to me why the default is now changed from fac to dep. Wouldn't it be most illustrative to show the effect of both facilitation and depression by creating a network with in total four plastic synapses?

Comment on lines +137 to +140
if self.synapse_parameters["tau_fac"] < 1e-10:
u_decay = 0.0
else:
u_decay = np.exp(-h / self.synapse_parameters["tau_fac"])
Copy link
Contributor

Choose a reason for hiding this comment

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

Based on the comment in the C++ code above, I would suggest here

Suggested change
if self.synapse_parameters["tau_fac"] < 1e-10:
u_decay = 0.0
else:
u_decay = np.exp(-h / self.synapse_parameters["tau_fac"])
if self.synapse_parameters["tau_fac"] == 0:
u_decay = 0.0
else:
u_decay = math.exp( - h / self.synapse_parameters["tau_fac"] )

Do we actually test for both cases, i.e. tau_fac == 0 and tau_fac != 0?
Also, since the exponent looks like a scalar, math.exp() is faster than the NumPy version.

Comment on lines +240 to +241
double x_decay = std::exp( -h / tau_rec_ );
double u_decay = ( tau_fac_ < 1.0e-10 ) ? 0.0 : std::exp( -h / tau_fac_ );
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
double x_decay = std::exp( -h / tau_rec_ );
double u_decay = ( tau_fac_ < 1.0e-10 ) ? 0.0 : std::exp( -h / tau_fac_ );
const double x_decay = std::exp( -h / tau_rec_ );
const double u_decay = ( tau_fac_ == 0 ) ? 0.0 : std::exp( -h / tau_fac_ ); // tau_fac == 0 disables facilitation

I find this check here a bit confusing. Since tau_fac_ == 0 is allowed to turn off facilitation (actually the default), I think it is most sensible to actually test for zero.

Copy link

@tomtetzlaff tomtetzlaff left a comment

Choose a reason for hiding this comment

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

Thanks @clinssen. This solved the issue with the order of update steps. After a period of silence, the synapse now fully recovers, as it should.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
I: No breaking change Previously written code will work as before, no one should note anything changing (aside the fix) S: High Should be handled next T: Bug Wrong statements in the code or documentation
Projects
Status: Review
Development

Successfully merging this pull request may close these issues.

4 participants