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

23 views
Skip to first unread message

Mohsen Paryavi

unread,
Feb 10, 2021, 2:08:01 PM2/10/21
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;

Colabhttps://colab.research.google.com/drive/1hlTykr4-rUYqI-n10icVEywxUhyar364?usp=sharing#scrollTo=wi2Ir_FwI-TY

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 = tf.data.Dataset.from_tensor_slices((images)).batch(1)
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,
Mohsen



Reply all
Reply to author
Forward
0 new messages