Spiking version of EfficientNetB0

Has anyone been able to convert EfficientNetB0, or any keras.application model, without issues? All my attempts have failed, usually with an error like nengo.exceptions.ValidationError: TensorNode.shape_in: Element 0 must be an int (got type ‘tuple’)

Hi @javierz, and welcome to the Nengo forums!

The NengoDL codebase does test with the keras.application model as part of the automated build process. The test code can be viewed here.

As for your error, I think that there may be an issue with the values you provided as the input_shape to the network. The input_shape should be a tuple of ints, and it might have got a tuple of tuple instead.

Hi @xchoo I’ve tried different input shapes for EfficientNetB0 and I keep getting errors. I also tried using the default values for the model and that didn’t work either. I did run what you had with DenseNet and it worked, so I tried something similar with EfficientNet and still got errors. Would you happen to have a working model using EfficientNet? Or know where I can find an example that uses it?

Hi @javierz,

I have been able to replicate the error on my local machine, so it is an issue. We don’t have any examples of working models with EfficientNet, so I won’t be able to help you there. I also haven’t personally used EfficientNet, so I’m unsure why this error is occuring.

Do you have any examples of EfficientNet working within TensorFlow (just TensorFlow by itself)? I’m wondering if it could be a mistake within TensorFlow.

Regardless, I have opened up an issue on the NengoDL Github, and our NengoDL devs will look at it whenever they are available.

Hello @xchoo,

Thank you for making that an issue. EffecientNet does work by itself with TensorFlow, so I don’t think it’s TensorFlow.

On another note, and maybe you can’t answer this because it isn’t specifically Nengo related, but do you know how I could get a keras_spiking.ModelEnergy of DenseNet? I keep failing because of the example_data. I can’t figure out what value to put there.

I haven’t used KerasSpiking myself, but looking at the documentation the example_data argument is data that is fed to the network to estimate the activity (and thus energy usage) of the model. The specifics for example_data would depend on the network structure.

As per the ModelEnergy documentation, the shape of example_data is identical to what you would use with tf.keras.Model.predict. If the model is non-temporal (i.e., no recurrence), the data should have a shape (batch_size, dim0, dim1, ...), and if the model is temporal, the data should have a shape (batch_size, num_timesteps, dim0, dim1, ...)