如何可视化TensorFlow Lite模型的特征图



我使用Keract来可视化TensorFlow/Keras模型的特征图。

我已经使用TensorFlow Lite应用了量化。我想在推理过程中可视化TensorFlow Lite模型生成的特征图。你知道怎么做吗?

原因是我不完全理解权重、激活和比例/零点系数之间的相互作用。所以我想一步一步地对一个量子化的网络进行推理。

感谢您的帮助

有几种方法可以提取有关权重、比例和零点值的信息。

方式一:

您还可以从TensorFlow网站上找到有关以下代码的其他信息。

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)

第二种方法(简单方法(:

在Netron网站上传您的TFLite文件。在那里你可以得到很多关于你的TFlite文件的信息。你也可以在电脑上安装Netron。这里,是在你的电脑上安装Netron的Netron git链接。

最新更新