ERROR Input to reshape is a tensor with 33 values, but the requested

Hi,
I’m having a lot of trouble while training my model on EI. I’m not doing anything exotic at all.
I’m training around 200 samples of accelerometer, sent via the impulse-cli from my 33Sense
Using a classification model based on both spectral analysis + flatten variables, with all default parameters.

I use the suggested NN, with a 20 neuron dense, and 10 neuron dense.

It behaves as if edge impulse was not able to take into account the second block of variables: it finds 33 instead of 54!). However all my features are generated correctly and they are in green.

I always get the following error:

Saving best performing model...
Converting TensorFlow Lite float32 model...
Converting TensorFlow Lite int8 quantized model with int8 input and output...
Calculating performance metrics...
Profiling float32 model...
Unable to execute TensorFlow Lite float32 model:
Input to reshape is a tensor with 33 values, but the requested shape has 54 [Op:Reshape]
Traceback (most recent call last):
  File "./resources/libraries/ei_tensorflow/profiling.py", line 435, 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), train_dataset, Y_train, test_dataset, Y_real_test)
  File "./resources/libraries/ei_tensorflow/profiling.py", line 152, 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.6/dist-packages/tensorflow/python/util/dispatch.py", line 201, in wrapper
    return target(*args, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/ops/array_ops.py", line 195, in reshape
    result = gen_array_ops.reshape(tensor, shape, name)
  File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/ops/gen_array_ops.py", line 8368, in reshape
    _ops.raise_from_not_ok_status(e, name)
  File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/ops.py", line 6862, 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 33 values, but the requested shape has 54 [Op:Reshape]
Profiling int8 model...
Unable to execute TensorFlow Lite int8 model:
Input to reshape is a tensor with 33 values, but the requested shape has 54 [Op:Reshape]
Traceback (most recent call last):
  File "./resources/libraries/ei_tensorflow/profiling.py", line 466, 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), train_dataset, Y_train, test_dataset, Y_real_test)
  File "./resources/libraries/ei_tensorflow/profiling.py", line 152, 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.6/dist-packages/tensorflow/python/util/dispatch.py", line 201, in wrapper
    return target(*args, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/ops/array_ops.py", line 195, in reshape
    result = gen_array_ops.reshape(tensor, shape, name)
  File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/ops/gen_array_ops.py", line 8368, in reshape
_ops.raise_from_not_ok_status(e, name)

File “/usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/ops.py”, line 6862, in raise_from_not_ok_status
six.raise_from(core._status_to_exception(e.code, message), None)
File “”, line 3, in raise_from
tensorflow.python.framework.errors_impl.InvalidArgumentError: Input to reshape is a tensor with 33 values, but the requested shape has 54 [Op:Reshape]

Hi @fleurda,

This may happen if you have added the second DSP block afterwards.
Could you try deleting/adding again the NN block in the Impulse Design?

Aurelien

Thanks for the answer, deleting all blocks and starting again from scratch did the trick.

2 Likes