brainpy / BrainPy

Brain Dynamics Programming in Python
https://brainpy.readthedocs.io/
GNU General Public License v3.0
491 stars 90 forks source link

Question about customizing a synapse model #654

Closed PikaPei closed 3 months ago

PikaPei commented 3 months ago

Hello!

I would like to customize a synapse model. I have read:

However, I feel confused about these interfaces. In most cases, I think building a synapse can be done with bp.Projection. Here are the questions I have:

  1. The case for using ProjAlignPostMg2 or ProjAlignPreMg2. I get their difference from the figures, which is the synaptic variables aligning to either pre or post. But I don't know when to use which model?

  2. The case for using EventCSRLinear. I also found CSRLinear in the documentation. I guess, in spiking network, we should use EventCSRLinear because it is event-driven. Am I getting it wrong?

  3. What does *.desc do? I saw https://brainpy.readthedocs.io/en/latest/apis/generated/brainpy.mixin.ParamDesc.html, but I don't understand what it does.

  4. In addition to the questions above, something makes me most confused is which interface I should use. From the links I provided, I found there are methods like (1) bp.dyn.SynDyn, bp.mixin.AlignPost (2) bp.SynConn (3) I also found bp.TwoEndConn in the official book of BrainPy. Could you help me figure these out?

I would be grateful if you could share any relevant documentation that I might have missed. Thank you!

chaoming0625 commented 3 months ago

Thanks for the question. I would like to recommend reading the source code that we have provided.

chaoming0625 commented 3 months ago

For align post, you can read the code of Expon

and DualExponV2

chaoming0625 commented 3 months ago

For align pre, you can read other codes such like Alpha

chaoming0625 commented 3 months ago
  1. The case for using ProjAlignPostMg2 or ProjAlignPreMg2. I get their difference from the figures, which is the synaptic variables aligning to either pre or post. But I don't know when to use which model?

Both models can be used anywhere. The difference is that align pre can apply to any synapse, while align post is only applicable to Exponential-family synapses.

  1. The case for using EventCSRLinear. I also found CSRLinear in the documentation. I guess, in spiking network, we should use EventCSRLinear because it is event-driven. Am I getting it wrong?

Not exactly. For FullProjAlignPreSDMg whose computation flow following pre -> syn -> delay -> comm, the comm should be CSRLinear since the input is the output of syn which is float-valued. While for FullProjAlignPostMg whose computation flow following pre -> delay -> comm, the comm should be EventCSRLinear since the output of pre is the binary spikes.

  1. What does *.desc do? I saw https://brainpy.readthedocs.io/en/latest/apis/generated/brainpy.mixin.ParamDesc.html, but I don't understand what it does.

.desc is the description of the model, rather than the actual initialization of the model.

  1. In addition to the questions above, something makes me most confused is which interface I should use. From the links I provided, I found there are methods like (1) bp.dyn.SynDyn, bp.mixin.AlignPost (2) bp.SynConn (3) I also found bp.TwoEndConn in the official book of BrainPy. Could you help me figure these out?

Using the interface I have linked above. Others are legacy APIs which should be abounded in future.

PikaPei commented 3 months ago

Thanks for helping me figure these out. I will try to read the source codes and documentation of synaptic projections. They are very helpful!