如何量化除特定节点之外的所有节点?

A. *_*Sam 19 tensorflow

我正在使用张量流图形变换工具来量化图形

input_names = ["prefix/input"]
output_names = ["final_result"]


transforms1 = ["strip_unused_nodes","fold_constants(ignore_errors=true)",  "fold_batch_norms",  "fold_old_batch_norms","quantize_weights" ]

transformed_graph_def = TransformGraph(graph.as_graph_def(), input_names,output_names, transforms1)
Run Code Online (Sandbox Code Playgroud)

我使用该选项quantize_weights来量化权重曲线,我知道某些节点可以通过改变门槛仍然未量化minimum_sizequantize_weights,所以留下一些节点未量化的当然是可能的.

我想量化除名称为K的特定节点或名称为K(set)的节点集之外的所有节点的权重.怎么能实现这一目标?

Yuv*_*val 1

编辑:之前的答案提到了 Tensorflow Lite 代码。我更新了它以引用 Tensorflow。

查看Tensorflow 的 quantize_weights的实现,这些是权重未量化的实例:

  1. 不是 float 类型的张量
  2. 权重少于 1024 个的张量(或参数指定的另一个数字minimum_size

如果您能够修改图中的节点,以便将它们排除在上述规则之一之外,然后进行量化,然后将节点恢复到量化前的状态,您也许能够做到这一点。