Confusion matrix not showing after NN model training

Hello,

Once the training is complete, the confusion matrix doesn’t appear:

I’ve run other models with the same features and the matrix does show up as a training output. Do you know what might be causing this issue?

I just started working with edge impulse so I’m sorry if my question sounds obvious.

Thank you in advance for your assistance!

Hey @alefiasolar, it looks like something goes wrong when converting the model and thus the confusion matrix cannot be evaluated. Which project is this for? I only see project 19796 under your account but it’s not this project.

Hey @janjongboom, the number of the project is 17583. If possible, could you please tell me if something’s wrong when converting the model?

@alefiasolar I’ve looked at it and cannot pinpoint why this is. Training seems OK, but executing fails with:

Input to reshape is a tensor with 7865 values, but the requested shape has 8004 [Op:Reshape]
Profiling int8 model...
Traceback (most recent call last):
  File "./resources/libraries/ei_tensorflow/profiling.py", line 396, in get_model_metadata
    float32_perf = profile_tflite_model(model_type, model_float32, file_float32, validation_dataset, Y_test, X_samples, Y_samples, has_samples, memory, mode, prepare_model_tflite_script, prepare_model_tflite_eon_script, len(class_names))
  File "./resources/libraries/ei_tensorflow/profiling.py", line 130, in profile_tflite_model
    feature_explorer_predictions = tflite_predict(model, X_samples, len(Y_samples))
  File "./resources/libraries/ei_tensorflow/profiling.py", line 39, in tflite_predict
    item_as_tensor = tf.reshape(item_as_tensor, input_details[0]['shape'])
  File "/usr/local/lib/python3.7/site-packages/tensorflow/python/util/dispatch.py", line 201, in wrapper
    return target(*args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/tensorflow/python/ops/array_ops.py", line 195, in reshape
    result = gen_array_ops.reshape(tensor, shape, name)
  File "/usr/local/lib/python3.7/site-packages/tensorflow/python/ops/gen_array_ops.py", line 8224, in reshape
    _ops.raise_from_not_ok_status(e, name)
  File "/usr/local/lib/python3.7/site-packages/tensorflow/python/framework/ops.py", line 6843, in raise_from_not_ok_status
    six.raise_from(core._status_to_exception(e.code, message), None)
  File "<string>", line 3, in raise_from
tensorflow.python.framework.errors_impl.InvalidArgumentError: Input to reshape is a tensor with 7865 values, but the requested shape has 8004 [Op:Reshape]
Unable to execute TensorFlow Lite int8 model:
Input to reshape is a tensor with 7865 values, but the requested shape has 8004 [Op:Reshape]
Traceback (most recent call last):
  File "./resources/libraries/ei_tensorflow/profiling.py", line 428, in get_model_metadata
    int8_perf = profile_tflite_model(model_type, model_int8, file_int8, validation_dataset, Y_test, X_samples, Y_samples, has_samples, memory, mode, prepare_model_tflite_script, prepare_model_tflite_eon_script, len(class_names))
  File "./resources/libraries/ei_tensorflow/profiling.py", line 130, in profile_tflite_model
    feature_explorer_predictions = tflite_predict(model, X_samples, len(Y_samples))
  File "./resources/libraries/ei_tensorflow/profiling.py", line 39, in tflite_predict
    item_as_tensor = tf.reshape(item_as_tensor, input_details[0]['shape'])
  File "/usr/local/lib/python3.7/site-packages/tensorflow/python/util/dispatch.py", line 201, in wrapper
    return target(*args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/tensorflow/python/ops/array_ops.py", line 195, in reshape
    result = gen_array_ops.reshape(tensor, shape, name)
  File "/usr/local/lib/python3.7/site-packages/tensorflow/python/ops/gen_array_ops.py", line 8224, in reshape
    _ops.raise_from_not_ok_status(e, name)
  File "/usr/local/lib/python3.7/site-packages/tensorflow/python/framework/ops.py", line 6843, in raise_from_not_ok_status
    six.raise_from(core._status_to_exception(e.code, message), None)
  File "<string>", line 3, in raise_from
tensorflow.python.framework.errors_impl.InvalidArgumentError: Input to reshape is a tensor with 7865 values, but the requested shape has 8004 [Op:Reshape]

@dansitu Any idea? I’ve added you to 17583.

Hi, this also happens to my project, where i tried to train a NN Classifier that could recognize particular audio sound. I wonder why this happens, does it relates to my PC settings ?

Hello @DiDisama,

I see from your project that it contains only one data sample (thus only one class).
Could you try to add at least two classes: e.g. one hello world and one unknown with some noise.
This should fix your issue.

For you to understand better why here is brief explanation:
When you try to do a classification using neural networks, the results of your inference will be a probability that it recognized the right class. If you have only one class, you will always get 100% as your model only knows this one.

Regards,

Louis

1 Like

hi, @louis,
thanks, it does work properly !

2 Likes