Failed to load Classification (err code: -5)

Hi EI team,

Question/Issue:
When deploying the trained model on broswer or phone i get this error: Failed to load Classification failed (err code: -5)
I have read here that a imbalanced dataset might cause that. But even when i “balance it out” i still get the same error

Project ID:
290754

Context/Use case:
Sound recognition for ESP32.

Hi @edsteve

I see it too hmm @04rlowe do you know if this bug has been reported? @AlexE could is be a DSP issue?

Best

Eoin

@edsteve can you try changing to the MFCC or Spectrogram processing block??

Don’t forget to tick the input features again when changing blocks:

If this resolves the issue let us know and I will log this as a bug for MFE. Thanks!

Best

Eoin

Hi,
and thanks for your fast reply.
I tried both. But when i change to MFCC or Spectrogram. I get errors like these when i try to train:
Should i change all the layer structure as well?

Training model...
Training on 806 inputs, validating on 202 inputs
Using batch size: 32
Epoch 1/100
Traceback (most recent call last):
  File "/home/train.py", line 296, in <module>
    main_function()
  File "/home/train.py", line 225, in main_function
    model, disable_per_channel_quantization, akida_model, akida_edge_model = train_model(train_dataset, validation_dataset,
  File "/home/train.py", line 168, in train_model
    model.fit(train_dataset, epochs=EPOCHS, validation_data=validation_dataset, verbose=2, callbacks=callbacks, class_weight=ei_tensorflow.training.get_class_weights(Y_train))
  File "/app/keras/.venv/lib/python3.8/site-packages/keras/utils/traceback_utils.py", line 70, in error_handler
    raise e.with_traceback(filtered_tb) from None
  File "/tmp/__autograph_generated_filesf8u4i5d.py", line 15, in tf__train_function
    retval_ = ag__.converted_call(ag__.ld(step_function), (ag__.ld(self), ag__.ld(iterator)), None, fscope)
ValueError: in user code:

    File "/app/keras/.venv/lib/python3.8/site-packages/keras/engine/training.py", line 1249, in train_function  *
        return step_function(self, iterator)
    File "/app/keras/.venv/lib/python3.8/site-packages/keras/engine/training.py", line 1233, in step_function  **
        outputs = model.distribute_strategy.run(run_step, args=(data,))
    File "/app/keras/.venv/lib/python3.8/site-packages/keras/engine/training.py", line 1222, in run_step  **
        outputs = model.train_step(data)
    File "/app/keras/.venv/lib/python3.8/site-packages/keras/engine/training.py", line 1023, in train_step
        y_pred = self(x, training=True)
    File "/app/keras/.venv/lib/python3.8/site-packages/keras/utils/traceback_utils.py", line 70, in error_handler
        raise e.with_traceback(filtered_tb) from None
    File "/app/keras/.venv/lib/python3.8/site-packages/keras/engine/input_spec.py", line 250, in assert_input_compatibility
        raise ValueError(

    ValueError: Exception encountered when calling layer 'sequential' (type Sequential).
    
    Input 0 of layer "conv1d" is incompatible with the layer: expected min_ndim=3, found ndim=2. Full shape received: (None, 12935)
    
    Call arguments received by layer 'sequential' (type Sequential):
      • inputs=tf.Tensor(shape=(None, 12935), dtype=float32)
      • training=True
      • mask=None

Application exited with code 1
Job failed (see above)

Hi @edsteve

You need to generate the features again and go through each step again before training when you change a block.

BEst

Eoin

fyi -

Hi and thanks for your reply @Eoin

Hmm. Strange. That’s exactly what i did. And i just did it again. These are the steps:

  1. I go to Create Impulse, remove MFE, add Spectrogram, set a hook on Spectrogram. Then Save
  2. I go to Spectrogram, click on Save Parameters, then Generate features
  3. Then go to Classifier and click on train… but get this error:
Training model...
Training on 806 inputs, validating on 202 inputs
Using batch size: 32
Epoch 1/100
Traceback (most recent call last):
  File "/home/train.py", line 297, in <module>
    main_function()
  File "/home/train.py", line 226, in main_function
    model, disable_per_channel_quantization, akida_model, akida_edge_model = train_model(train_dataset, validation_dataset,
  File "/home/train.py", line 169, in train_model
    model.fit(train_dataset, epochs=EPOCHS, validation_data=validation_dataset, verbose=2, callbacks=callbacks, class_weight=ei_tensorflow.training.get_class_weights(Y_train))
  File "/app/keras/.venv/lib/python3.8/site-packages/keras/utils/traceback_utils.py", line 70, in error_handler
    raise e.with_traceback(filtered_tb) from None
  File "/tmp/__autograph_generated_fileuptkvd0k.py", line 15, in tf__train_function
    retval_ = ag__.converted_call(ag__.ld(step_function), (ag__.ld(self), ag__.ld(iterator)), None, fscope)
ValueError: in user code:

    File "/app/keras/.venv/lib/python3.8/site-packages/keras/engine/training.py", line 1249, in train_function  *
        return step_function(self, iterator)
    File "/app/keras/.venv/lib/python3.8/site-packages/keras/engine/training.py", line 1233, in step_function  **
        outputs = model.distribute_strategy.run(run_step, args=(data,))
    File "/app/keras/.venv/lib/python3.8/site-packages/keras/engine/training.py", line 1222, in run_step  **
        outputs = model.train_step(data)
    File "/app/keras/.venv/lib/python3.8/site-packages/keras/engine/training.py", line 1023, in train_step
        y_pred = self(x, training=True)
    File "/app/keras/.venv/lib/python3.8/site-packages/keras/utils/traceback_utils.py", line 70, in error_handler
        raise e.with_traceback(filtered_tb) from None
    File "/app/keras/.venv/lib/python3.8/site-packages/keras/layers/reshaping/reshape.py", line 118, in _fix_unknown_dimension
        raise ValueError(msg)

    ValueError: Exception encountered when calling layer 'reshape' (type Reshape).
    
    total size of new array must be unchanged, input_shape = [12935], output_shape = [404, 32]
    
    Call arguments received by layer 'reshape' (type Reshape):
      • inputs=tf.Tensor(shape=(None, 12935), dtype=float32)

Application exited with code 1
Job failed (see above)

Can the browser cash have something to do with it or anything else localy on my PC?

I think your training test still uses MFE

Hmmm strange, not sure why it worked for me on your project. Try a new browser, but I dont know what parts would be cached as its cloud based training.

I’ve highlighted this as an issue to our DSP team so let me know how you get on with alternate processing blocks / browsers.

Best

Eoin

Okay. The error from training came from the reshape layer. I didn’t renew the network architecture (layers) for training after changing the DSP. So the reshape layer was still set to 32. After renewing the architecture. The reshape layer has now 13 and training works without errors.

Back to the main topic: Deployment works with MFCC.

1 Like