Hello all, I have few general questions along with how to do prediction on batches of test data with a converted spiking network. I am attaching my script here for downloading and running. The error I am facing in this script is: SimulationError: Number of saved parameters in ./keras_to_snn_params (7) != number of variables in the model (4)
. I looked around for a bit and found this but probably it was related to an old bug, as I am using the latest version of nengo-dl.
Nengo version: 3.0.0
NengoDL version: 3.2.0
Tensorflow version: 2.2.0
1> During training of a nengo-dl model, I can see it using the GPU, but while prediction it doesn’t. It uses the CPU. If it’s must for nengo-dl to use CPU in inference mode, can someone show me how to parallelize the prediction over multiple CPUs?
2> My script uses batches for training… how do I change it to enforce regularization over firing rates? From the tutorial nengo objects are used and not the names of the layers as passed in dict for batch training.
3> Is there a way to simultaneously train and test in the same simulation context (i.e. under one with nengo_dl.Simulator(converter.net, minibatch_size=batch_size) as sim
) with due note of using rate neurons (tf.nn.relu) while training and using spiking neurons while testing?
4> Any tips other than regularization of firing rates during training to improve inference performance would be very much appreciated!
Thanks!
Update-1: If I remove inference_only=True
from the nengo-dl model to predict on test data, the script runs ahead but fails with InvalidArgumentError
(a small part of Traceback):
<ipython-input-10-82d2ac427759> in <module>
19
20 test_data = get_test_batches(batch_size)
---> 21 data = nengo_sim.predict(test_data, steps=10)
22
23 accuracy = get_accuracy(data[nengo_output], test_labels)
which indicates that the way I am passing test data to predict()
isn’t correct. For a quick look, following is the way I am constructing test_data
generator:
def get_test_batches(batch_size, n_steps=20):
for i in range(0, test_images.shape[0], batch_size):
ip = test_images[i:i+batch_size]
label = test_labels[i:i+batch_size]
yield(
{
"input_1": ip,
"n_steps": np.ones((batch_size, 1), dtype=np.int32)* n_steps,
"conv2d.0.bias": np.ones((batch_size, 32, 1), dtype=np.int32),
"conv2d_1.0.bias": np.ones((batch_size, 64, 1), dtype=np.int32),
"dense.0.bias": np.ones((batch_size, 10, 1), dtype=np.int32)
})
Am I missing something? I am constructing it similar to the way mentioned here in get_batches()
function. This brings me to the next point… can someone please explain the exact use case of inference_only=True
? I wasn’t able to follow the API documentation very clearly.