Open JackCaster opened 2 months ago
You can write a function which make a traversal in your model to set initial membrane potential. For example:
def set_initial(model, value):
for module in model.modules():
if isinstance(module, neuron):
module.v = value
You can write a function which make a traversal in your model to set initial membrane potential. For example:
def set_initial(model, value): for module in model.modules(): if isinstance(module, neuron): module.v = value
Thanks, this is close to what I was looking for! But I was wondering if it would be possible to have the initial value being a parameter to learn
You can write a function which make a traversal in your model to set initial membrane potential. For example:
def set_initial(model, value): for module in model.modules(): if isinstance(module, neuron): module.v = value
Thanks, this is close to what I was looking for! But I was wondering if it would be possible to have the initial value being a parameter to learn
Then you need to use nn.parameter to represent the initial value.
Yes exactly, I think I need a parameter v_init
that by default is set to 0.0
. Where is the right place to add this parameter. I usually subclass the base neuron to add these kind of changes, but I struggle to find the right way to add this parameter in there.
Yes exactly, I think I need a parameter
v_init
that by default is set to0.0
. Where is the right place to add this parameter. I usually subclass the base neuron to add these kind of changes, but I struggle to find the right way to add this parameter in there.
Just like this:
class Neuron():
def __init__(self):
self.init_v = nn.parameter([1])
Note that this code is only a draft for illustration. And you should also write a new reset function to set v to be equal with v_init after a timestep.
Issue type
SpikingJelly version
0.0.0.0.15
Description Hi @fangwei123456, in a custom neuron, is it possible to add a parameter to set the initial value for
v
? Instead of starting from 0.0, I'd like to let the network figure out what is the best starting value. I'd need this as I am looking at fitting some timeseries that I chunked (so later chunks may be more likely to have already a starting value for the membrane potential). How would you go about it?