I tried to use
nengo_converter = nengo_dl.Converter(model, allow_fallback=False, swap_activations={tf.nn.relu: nengo.SpikingRectifiedLinear()})
as you suggested, but looks like the neurons are not converted to Spiking
model = tf.keras.models.load_model(os.path.join(CHECKPOINT_FILE_PATH, MODEL_NAME))
nengo_converter = nengo_dl.Converter(model,
allow_fallback=False,
swap_activations={tf.nn.relu: nengo.SpikingRectifiedLinear()})
net = nengo_converter.net
for ensemble in net.ensembles: print(ensemble, ensemble.neuron_type)
assert nengo_converter.verify()
the ensemble prints:
<Ensemble "conv2d_4.0"> RectifiedLinear()
<Ensemble "conv2d_5.0"> RectifiedLinear()
<Ensemble "conv2d_6.0"> RectifiedLinear()
<Ensemble "conv2d_7.0"> RectifiedLinear()
<Ensemble "conv2d_8.0"> RectifiedLinear()
<Ensemble "conv2d_9.0"> RectifiedLinear()
Then I tried to use swap_activations={nengo.RectifiedLinear(): nengo.SpikingRectifiedLinear()}
as suggested from Daniel from a different topic. This time, the neuron converted to spiking however, an error raised from function
assert nengo_converter.verify()
ValueError: Output of Keras model does not match output of converted Nengo network
My questions are
- Is it a known issue with
swap_activations={tf.nn.relu: nengo.SpikingRectifiedLinear()}
? - Is it safe to use
swap_activations={nengo.RectifiedLinear(): nengo.SpikingRectifiedLinear()}
in nengo_dl.Converter to make sure the model transfered to spiking.
swap_activations={tf.nn.relu: nengo:SpikingRectifiedLinear()}
makes more sense to me since I’m loading a keras model. Theassert nengo_converter.verify()
can’t work either. Are there any other parameters that I should be aware of to make the spiking conversion pass the verification function? Thank you