Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/tensorflow/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 带量子化值的张量流tanh_Python_Tensorflow_Quantization - Fatal编程技术网

Python 带量子化值的张量流tanh

Python 带量子化值的张量流tanh,python,tensorflow,quantization,Python,Tensorflow,Quantization,我正在Tensorflow 1.1中对神经网络进行量化实验 根据,tanh操作支持浮点输入以及类型为qint32的定点输入。但是,我无法让它工作: import tensorflow as tf sess = tf.InteractiveSession() x = tf.constant([1.,2.,3.], dtype=tf.float32) from tensorflow.python.ops.gen_array_ops import quantize_v2 x_quant = qu

我正在Tensorflow 1.1中对神经网络进行量化实验

根据,tanh操作支持浮点输入以及类型为
qint32
的定点输入。但是,我无法让它工作:

import tensorflow as tf

sess = tf.InteractiveSession()

x = tf.constant([1.,2.,3.], dtype=tf.float32)

from tensorflow.python.ops.gen_array_ops import quantize_v2
x_quant = quantize_v2(x, min_range=0., max_range=4., T=tf.qint32)

y_quant = tf.nn.tanh(x_quant[0])
该代码将生成一条错误消息:


是有出路还是只是文档中的一个bug?

可能是文档中的一个bug。根据
gen\u math\u ops.py
中的后端函数
\u tanh


由于量化确实是新的,可能新版的
\u tanh
仍在进行中。

在查看文件历史记录后,我可以确认这是2015年7月引入的文档中的一个错误,当时我们还没有发布量化定义,但量化定义还没有完全确定。感谢您澄清这一点!那么,对于使用tanh激活函数的网络,量化推理的最直接的方法是什么呢?
TypeError: Value passed to parameter 'x' has DataType qint32 not in list of 
allowed values: float16, float32, float64, complex64, complex128
def _tanh(x, name=None):
  r"""Computes hyperbolic tangent of `x` element-wise.

  Args:
    x: A `Tensor`. Must be one of the following types: `half`, `float32`, `float64`, `complex64`, `complex128`.
    name: A name for the operation (optional).