Mil*_*ore 7 tensorflow tensorboard tensorflow-lite
问题:如何将.tflite
(序列化的平面缓冲区)转换为.pb
(冻结模型)?该文档仅讨论一种方式转换。
用例是:我有一个经过训练的模型转换为.tflite
但不幸的是,我没有模型的详细信息,我想检查图表,我该怎么做?
我在这里找到了答案
我们可以使用 Interpreter 来分析模型,相同的代码如下所示:
import numpy as np
import tensorflow as tf
# Load TFLite model and allocate tensors.
interpreter = tf.lite.Interpreter(model_path="converted_model.tflite")
interpreter.allocate_tensors()
# Get input and output tensors.
input_details = interpreter.get_input_details()
output_details = interpreter.get_output_details()
# Test model on random input data.
input_shape = input_details[0]['shape']
input_data = np.array(np.random.random_sample(input_shape), dtype=np.float32)
interpreter.set_tensor(input_details[0]['index'], input_data)
interpreter.invoke()
output_data = interpreter.get_tensor(output_details[0]['index'])
print(output_data)
Run Code Online (Sandbox Code Playgroud)
Netron是我发现的最好的分析/可视化工具,它可以理解很多格式,包括.tflite
.
归档时间: |
|
查看次数: |
8845 次 |
最近记录: |