安装带有量化支持的Tensorflow [英] Install Tensorflow with Quantization Support
问题描述
这是我另一个问题的跟进: Tensorflow中8位量化出现错误
This is a follow-up of another question by me : Error with 8-bit Quantization in Tensorflow
基本上,我想安装具有8位量化支持的Tensorflow.目前,我在CentOS 7机器上(没有GPU支持)以pip安装方法安装了Tensorflow 0.9.
Basically, I would like to install the Tensorflow with 8-bit quantization support. Currently, I installed Tensorflow 0.9 with pip installation method on CentOS 7 machine (without GPU support).
我可以编译和运行Pete Warden博客文章中给出的代码.但是,我无法导入Pete Warden的回复中给出的功能.我想添加量化支持.我也没有在Tensorflow文档中找到有关量化部分的任何细节.
I could compile and run the codes as given in Pete Warden's blog post. But, I can't import the functions given in Pete Warden's reply. I would like to add the quantization support. I couldn't find any details about the quantization part in the Tensorflow documentation also.
任何人都可以分享有关操作细节的信息吗?
Can anybody share the details on how to do it?
推荐答案
出于时间考虑,我可以找出一种方法来做到这一点.但仍在等待任何TensorFlow开发人员的官方方法.
For time-being, I could figure out a method to do this. But still waiting for official method from any TensorFlow developers.
- 首先安装tensorflow(我尝试了源代码安装和PIP安装,都很好)
- 从Github存储库中获取tensorflow源,并转到tensorflow根目录(我将其称为
tensorflow_root
. - 现在按照 Pete Warden的博客
- First install the tensorflow ( I tried both source installation as well as PIP installation, both are fine)
- Get the tensorflow source from the Github repo and go to the tensorflow root directory (I would call it
tensorflow_root
. - Now compile the quantization script as given in Pete Warden's blog
bazel build tensorflow/contrib/quantization/tools:quantize_graph
这将为量化版本创建ops库.转到tensorflow_root/bazel-bin/tensorflow/contrib/quantization,您应该看到两个库文件:_quantized_ops.so
和kernels/_quantized_kernels.so
This wil create ops libraries for quantized versions. Go to tensorflow_root/bazel-bin/tensorflow/contrib/quantization and you should see two library files : _quantized_ops.so
and kernels/_quantized_kernels.so
- 现在在脚本中,您应该与tensorflow一起使用专用的tensorflow函数导入这两个库文件
您可以使用 tf.load_op_library()函数
import tensorflow as tf
qops = tf.load_op_library('[tensorflow_root]/bazel-bin/tensorflow/contrib/quantization/_quantized_ops.so')
qkernelops = tf.load_op_library('[tensorflow_root]/bazel-bin/tensorflow/contrib/quantization/kernels/_quantized_kernels.so')
这篇关于安装带有量化支持的Tensorflow的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!