You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There is a floating point precision error when using 0.02 at each time step. This issue can be reproduced with the following code:
from spikingjelly.activation_based import neuron
import torch
if_layer = neuron.IFNode(step_mode='s')
print(' -'* 6)
if_layer.reset()
print(f"init v: {if_layer.v}")
x = torch.FloatTensor([0.05])
print(f"input {x}")
print(' -'* 6)
for i in range(100):
out = if_layer(x)
if out == 1:
print(f"if_layer fires at step {i}")
print(' -'* 6)
if_layer.reset()
print(f"init v: {if_layer.v}")
x = torch.FloatTensor([0.02])
print(f"input {x}")
print(' -'* 6)
for i in range(200):
out = if_layer(x)
if out == 1:
print(f"if_layer fires at step {i}")
print(' -'* 6)
if_layer.reset()
print(f"init v: {if_layer.v}")
x = torch.FloatTensor([0.02])
print(f"input {x}")
print(' -'* 6)
for i in range(50):
out = if_layer(x)
print(f"membrane at step 50: {if_layer.v}")
print(f"membrane - 1.0: {if_layer.v - 1.0}")
It appears that the error stems from float32 precision limitations rather than any specific code within this project. I recommend adding a parameter eps with a default value of 1e-6 and changing the judging condition from v >= v_threshold to v + eps >= v_threshold. Or you could just adjust the variable x used in your tutorials (https://spikingjelly.readthedocs.io/zh-cn/0.0.0.0.14/activation_based/neuron.html#id4) to avoid any misunderstanding.
The text was updated successfully, but these errors were encountered:
There is a floating point precision error when using 0.02 at each time step. This issue can be reproduced with the following code:
It appears that the error stems from float32 precision limitations rather than any specific code within this project. I recommend adding a parameter eps with a default value of 1e-6 and changing the judging condition from v >= v_threshold to v + eps >= v_threshold. Or you could just adjust the variable x used in your tutorials (https://spikingjelly.readthedocs.io/zh-cn/0.0.0.0.14/activation_based/neuron.html#id4) to avoid any misunderstanding.
The text was updated successfully, but these errors were encountered: