Post training Quantization on Cats and dogs dataset (changing input shape to int8)

Skip to first unread message

Mohsen Paryavi

Feb 10, 2021, 2:08:01 PMFeb 10
to SIG Micro
Hi everyone!

I was inspired by your integer quantization code on the MNIST dataset. 
I wanna do the same with your cats and dogs transfer learning code to run in on my Raspberry Pi 4 to test my transfer learning code eventually, so I added integer quantization at the end of it, but it gets rank error;


More Detail:
I was able to run your mobile SSD object detection inference on my Pi 4 which has int8 as input using Pi Camera, so I used the following code to convert my code from float 32 to int 8 using representative_data_gen() function, but it results in a rank error;

rescaled_image = rescale(tf.expand_dims(first_image, 0))
images = tf.cast(rescaled_image[0], tf.float32)
catdog_ds =
def representative_data_gen():
  for input_value in catdog_ds.take(100):
    # Model has only one input so each data point has one element.
    yield [input_value]
converter.representative_dataset = representative_data_gen

ValueError: Unbatching a dataset is only supported for rank >= 1

How can I solve this problem? 

Best Regards,

Reply all
Reply to author
0 new messages