cv_loss#
- class braintools.fit.losses.cv_loss(prediction, target)#
Compute the squared difference of the mean inter-spike-interval CV.
\[L = \left(\langle \mathrm{CV} \rangle_{\mathrm{pred}} - \langle \mathrm{CV} \rangle_{\mathrm{target}}\right)^2,\]where \(\langle \mathrm{CV} \rangle\) averages
cv()over the neurons whose CV is defined (at least 3 spikes); neurons with ananCV are ignored [1].- Parameters:
- Returns:
Scalar loss (dimensionless).
nanif every neuron of either input has an undefined CV.- Return type:
Array- Raises:
TypeError – If an input is not a
SpikeTrains.
See also
Notes
Works under
jax.jitandjax.vmapand is differentiable with respect to the spike times; the ignored neurons contribute neither value nornangradient.References
Examples
>>> import jax.numpy as jnp >>> from braintools.fit import losses >>> from braintools.spike import SpikeTrains >>> regular = jnp.zeros((100, 3)).at[::10].set(1.) # CV 0 >>> bursty = jnp.zeros((100, 3)).at[jnp.array([0, 2, 6]), :2].set(1.) >>> pred = SpikeTrains.from_dense(regular, dt=1.) >>> target = SpikeTrains.from_dense(bursty, dt=1.) # CV 1/3; neuron 2 is silent >>> round(float(losses.cv_loss(pred, target)), 6) 0.111111