Skip to content

Commit c0d43df

Browse files
committed
last updates/fixes before paper
1 parent 97ff1f9 commit c0d43df

14 files changed

Lines changed: 3615 additions & 9165 deletions

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
project = 'Spyx'
1515
copyright = '2023, Kade Heckel'
1616
author = 'Kade Heckel'
17-
release = 'v0.1.18'
17+
release = 'v0.1.19'
1818

1919
# -- General configuration ---------------------------------------------------
2020
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration

docs/examples/surrogate_gradient/SurrogateGradientTutorial.ipynb

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@
153153
},
154154
"outputs": [],
155155
"source": [
156-
"shd_dl = spyx.data.SHD_loader(256,128,128)"
156+
"shd_dl = spyx.loaders.SHD_loader(256,128,128)"
157157
]
158158
},
159159
{
@@ -259,9 +259,9 @@
259259
"\n",
260260
" # Haiku has the ability to stack multiple layers/recurrent modules as one entity\n",
261261
" core = hk.DeepRNN([\n",
262-
" snn.LIF((64,), activation=spyx.axn.Axon(spyx.axn.triangular())), #LIF neuron layer with triangular activation\n",
262+
" snn.LIF((64,), activation=spyx.axn.triangular()), #LIF neuron layer with triangular activation\n",
263263
" hk.Linear(64, with_bias=False),\n",
264-
" snn.LIF((64,), activation=spyx.axn.Axon(spyx.axn.triangular())),\n",
264+
" snn.LIF((64,), activation=spyx.axn.triangular()),\n",
265265
" hk.Linear(20, with_bias=False),\n",
266266
" snn.LI((20,)) # Non-spiking final layer\n",
267267
" ])\n",
@@ -312,6 +312,9 @@
312312
" # We use optax for our optimizer.\n",
313313
" opt = optax.lion(learning_rate=schedule)\n",
314314
"\n",
315+
" Loss = spyx.fn.integral_crossentropy()\n",
316+
" Acc = spyx.fn.integral_accuracy()\n",
317+
"\n",
315318
" # create and initialize the optimizer\n",
316319
" opt_state = opt.init(params)\n",
317320
" grad_params = params\n",
@@ -321,7 +324,7 @@
321324
" def net_eval(weights, events, targets):\n",
322325
" readout = SNN.apply(weights, events)\n",
323326
" traces, V_f = readout\n",
324-
" return spyx.fn.integral_crossentropy(traces, targets)\n",
327+
" return Loss(traces, targets)\n",
325328
"\n",
326329
" # Use JAX to create a function that calculates the loss and the gradient!\n",
327330
" surrogate_grad = jax.value_and_grad(net_eval)\n",
@@ -357,8 +360,8 @@
357360
" # unpack the final layer outputs and end state of each SNN layer\n",
358361
" traces, V_f = readout\n",
359362
" # compute accuracy, predictions, and loss\n",
360-
" acc, pred = spyx.fn.integral_accuracy(traces, targets)\n",
361-
" loss = spyx.fn.integral_crossentropy(traces, targets)\n",
363+
" acc, pred = Acc(traces, targets)\n",
364+
" loss = Loss(traces, targets)\n",
362365
" # we return the parameters here because of how jax.scan is structured.\n",
363366
" return grad_params, jnp.array([acc, loss])\n",
364367
"\n",
@@ -421,14 +424,17 @@
421424
"source": [
422425
"def test_gd(SNN, params, dl):\n",
423426
"\n",
427+
" Loss = spyx.fn.integral_crossentropy()\n",
428+
" Acc = spyx.fn.integral_accuracy()\n",
429+
"\n",
424430
" @jax.jit\n",
425431
" def test_step(params, data):\n",
426432
" events, targets = data\n",
427433
" events = jnp.unpackbits(events, axis=1)\n",
428434
" readout = SNN.apply(params, events)\n",
429435
" traces, V_f = readout\n",
430-
" acc, pred = spyx.fn.integral_accuracy(traces, targets)\n",
431-
" loss = spyx.fn.integral_crossentropy(traces, targets)\n",
436+
" acc, pred = Acc(traces, targets)\n",
437+
" loss = Loss(traces, targets)\n",
432438
" return params, [acc, loss, pred, targets]\n",
433439
"\n",
434440
" test_data = dl.test_epoch()\n",

docs/examples/surrogate_gradient/shd_sg_neuron_model_comparison.ipynb

Lines changed: 312 additions & 6136 deletions
Large diffs are not rendered by default.

docs/examples/surrogate_gradient/shd_sg_surrogate_comparison.ipynb

Lines changed: 1996 additions & 371 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)