Skip to main content
PB1
Associate III
May 16, 2023
Solved

What is the right shape for the quantization accuracy data?

  • May 16, 2023
  • 2 replies
  • 1979 views

Sorry if this question is basic, but I was not able to find an answer in the documentation. I have a very simple Keras model with one input and one output, for your reference the architecture is:

model = tf.keras.Sequential()

model.add(tf.keras.layers.Dense(16, activation='relu', input_shape=(1,)))

model.add(tf.keras.layers.Dense(16, activation='relu'))

model.add(tf.keras.layers.Dense(1))

I have two vectors x_test and y_test with shape (200,), the same shape of my validation arrays used during the training phase, and I saved a .npz dataset to quantize the network as follows:

np.savez('testdata.npz',x_test=x_test,y_test=y_test)

I am using the STM32.AI developer cloud to quantize the network. Quantization fails, and the log displays the message:

Executing with: {'model': '...

Converting original model to TFLite...

cannot reshape array of size 200 into shape (1,1)

So apparently the problem is the shape of the data in the .npz file. Which shape should have the test vectors in the .npz file?

Best,

Pietro

    This topic has been closed for replies.
    Best answer by jean-michel.d

    Hello Pietro,

    Your way to create the npz seems correct. We have perhaps an issue in the associated Cloud service to manage this simple case: input_shape=(1,), investigation is on-going on our side (including the documentation aspect). However, normaly if before to save the npz file, you reshape the input -> (200, 1), it should be correctly managed by the quantization service.

    Best,

    Jean-Michel

    2 replies

    jean-michel.dBest answer
    ST Employee
    May 17, 2023

    Hello Pietro,

    Your way to create the npz seems correct. We have perhaps an issue in the associated Cloud service to manage this simple case: input_shape=(1,), investigation is on-going on our side (including the documentation aspect). However, normaly if before to save the npz file, you reshape the input -> (200, 1), it should be correctly managed by the quantization service.

    Best,

    Jean-Michel

    PB1
    PB1Author
    Associate III
    May 19, 2023

    Thank you. The reshaping workaround works.