0

I used Keract to visualize the feature maps of a TensorFlow/Keras model.

I have applied quantization with TensorFlow Lite. I would like to visualize the feature maps generated by the TensorFlow Lite model during an inference. Do you know a way to do this?

The reason is that I don't fully understand the interaction between weights, activations and scale/zero-point coefficients. So I would like to do the inference process step by step for a quantized network.

Thank you for your help

ThoG_Sor
  • 3
  • 2

1 Answers1

0

There are several ways to extract information about weights, scales and zero-point values.

way one:

You can also find additional information about the below code from the TensorFlow website.

import tensorflow as tf
import numpy as np

#Load your TFLite model.
TF_LITE_MODEL_FILE_NAME = "Your_TFLite_file.tflite" 
interpreter = tf.lite.Interpreter(model_path=TF_LITE_MODEL_FILE_NAME)

#Gives you input and output details
input_details = interpreter.get_input_details()
output_details = interpreter.get_output_details()

#Gives you all tensor details index-wise. you will find all the quantization_parameters here
interpreter.get_tensor_details()

#get individual tensor value. interpreter.get_tensor(give_index_number). You will find the index for individual tensor index from get_tensor_details
interpreter.allocate_tensors()
r= interpreter.get_tensor(12).astype(np.float32)
print('Tensors', r)

Way two (the easy way):

Upload your TFLite file on the Netron Website. There you can get lots of information about your TFlite file. You can install Netron on your PC also. Here, is the Netron git link to install Netron on your PC.

Amit
  • 51
  • 5