cancel
Showing results for 
Search instead for 
Did you mean: 

What is the right shape for the quantization accuracy data?

PB1
Associate III

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

1 ACCEPTED SOLUTION

Accepted Solutions
jean-michel.d
ST Employee

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

View solution in original post

2 REPLIES 2
jean-michel.d
ST Employee

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
Associate III

Thank you. The reshaping workaround works.