我从这里下载了一个量化的移动网络,该图包含训练期间的假量化节点,以模拟测试时间输出。我想从这个网络的最后一个逐点卷积层收集输出。
量化的冻结模型包含额外的 fc、softmax 等层,这些层对我的应用程序没有用处。
我有以下用于加载图表的代码。
def load_graph(frozen_graph_filename):
# We load the protobuf file from the disk and parse it to retrieve the
# unserialized graph_def
with tf.gfile.GFile(frozen_graph_filename, "rb") as f:
graph_def = tf.GraphDef()
graph_def.ParseFromString(f.read())
with tf.Graph().as_default() as graph:
# The name var will prefix every op/nodes in your graph
# Since we load everything in a new graph, this is not needed
tf.import_graph_def(graph_def, name="prefix")
return graph
graph1 = load_graph("./quantized_fake.pb")
input = graph1.get_tensor_by_name('prefix/input:0')
output = graph1.get_tensor_by_name('prefix/MobilenetV1/MobilenetV1/Conv2d_13_pointwise/Conv2D_Fold:0')
然后使用 sess.run() 运行,但是我观察到卷积层的输出没有像在移动设备上运行时那样量化(8 位)。
在我的电脑上运行代码时,如何产生与在移动设备上产生的输出相同的输出。
tflite 文件可以用于 pc 上的推理吗?