TensorFlow的异常Reciprocal[T=DT_INT32](Variable_1/read)
来源:互联网 发布:军工人工智能概念股300 编辑:程序博客网 时间:2024/05/16 09:18
在TF里,使用32位整数来计算倒数时会抛出这个异常:
Traceback (most recent call last):
File "C:\python35\lib\site-packages\tensorflow\python\client\session.py", line 1022, in _do_call
return fn(*args)
File "C:\python35\lib\site-packages\tensorflow\python\client\session.py", line 1000, in _run_fn
self._extend_graph()
File "C:\python35\lib\site-packages\tensorflow\python\client\session.py", line 1049, in _extend_graph
self._session, graph_def.SerializeToString(), status)
File "C:\python35\lib\contextlib.py", line 66, in __exit__
next(self.gen)
File "C:\python35\lib\site-packages\tensorflow\python\framework\errors_impl.py", line 469, in raise_exception_on_not_ok_status
pywrap_tensorflow.TF_GetCode(status))
tensorflow.python.framework.errors_impl.InvalidArgumentError: No OpKernel was registered to support Op 'Reciprocal' with these attrs. Registered devices: [CPU,GPU], Registered kernels:
device='CPU'; T in [DT_FLOAT]
device='CPU'; T in [DT_HALF]
device='CPU'; T in [DT_DOUBLE]
device='CPU'; T in [DT_COMPLEX64]
device='CPU'; T in [DT_COMPLEX128]
device='GPU'; T in [DT_FLOAT]
device='GPU'; T in [DT_HALF]
device='GPU'; T in [DT_DOUBLE]
device='GPU'; T in [DT_INT64]
[[Node: Reciprocal = Reciprocal[T=DT_INT32](Variable_1/read)]]
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "D:\work\csdn\TF_API\src\TFAPI_6\TFAPI_6\TFAPI_17.py", line 31, in <module>
demo.run_graph()
File "D:\work\csdn\TF_API\src\TFAPI_6\TFAPI_6\TFAPI_17.py", line 21, in run_graph
sess.run(init)
File "C:\python35\lib\site-packages\tensorflow\python\client\session.py", line 767, in run
run_metadata_ptr)
File "C:\python35\lib\site-packages\tensorflow\python\client\session.py", line 965, in _run
feed_dict_string, options, run_metadata)
File "C:\python35\lib\site-packages\tensorflow\python\client\session.py", line 1015, in _do_run
target_list, options, run_metadata)
File "C:\python35\lib\site-packages\tensorflow\python\client\session.py", line 1035, in _do_call
raise type(e)(node_def, op, message)
tensorflow.python.framework.errors_impl.InvalidArgumentError: No OpKernel was registered to support Op 'Reciprocal' with these attrs. Registered devices: [CPU,GPU], Registered kernels:
device='CPU'; T in [DT_FLOAT]
device='CPU'; T in [DT_HALF]
device='CPU'; T in [DT_DOUBLE]
device='CPU'; T in [DT_COMPLEX64]
device='CPU'; T in [DT_COMPLEX128]
device='GPU'; T in [DT_FLOAT]
device='GPU'; T in [DT_HALF]
device='GPU'; T in [DT_DOUBLE]
device='GPU'; T in [DT_INT64]
[[Node: Reciprocal = Reciprocal[T=DT_INT32](Variable_1/read)]]
Caused by op 'Reciprocal', defined at:
File "<string>", line 1, in <module>
File "C:\python35\lib\idlelib\run.py", line 130, in main
ret = method(*args, **kwargs)
File "C:\python35\lib\idlelib\run.py", line 357, in runcode
exec(code, self.locals)
File "D:\work\csdn\TF_API\src\TFAPI_6\TFAPI_6\TFAPI_17.py", line 30, in <module>
demo = DemoTF()
File "D:\work\csdn\TF_API\src\TFAPI_6\TFAPI_6\TFAPI_17.py", line 16, in __init__
self.reciprocal = tf.reciprocal(self.num2)
File "C:\python35\lib\site-packages\tensorflow\python\ops\gen_math_ops.py", line 1964, in reciprocal
result = _op_def_lib.apply_op("Reciprocal", x=x, name=name)
File "C:\python35\lib\site-packages\tensorflow\python\framework\op_def_library.py", line 763, in apply_op
op_def=op_def)
File "C:\python35\lib\site-packages\tensorflow\python\framework\ops.py", line 2395, in create_op
original_op=self._default_original_op, op_def=op_def)
File "C:\python35\lib\site-packages\tensorflow\python\framework\ops.py", line 1264, in __init__
self._traceback = _extract_stack()
InvalidArgumentError (see above for traceback): No OpKernel was registered to support Op 'Reciprocal' with these attrs. Registered devices: [CPU,GPU], Registered kernels:
device='CPU'; T in [DT_FLOAT]
device='CPU'; T in [DT_HALF]
device='CPU'; T in [DT_DOUBLE]
device='CPU'; T in [DT_COMPLEX64]
device='CPU'; T in [DT_COMPLEX128]
device='GPU'; T in [DT_FLOAT]
device='GPU'; T in [DT_HALF]
device='GPU'; T in [DT_DOUBLE]
device='GPU'; T in [DT_INT64]
[[Node: Reciprocal = Reciprocal[T=DT_INT32](Variable_1/read)]]
从异常信息上来看,它是不支持tf.int32的类型运算的,所以抛出异常。只支持下面的类型:
device='CPU'; T in [DT_FLOAT]
device='CPU'; T in [DT_HALF]
device='CPU'; T in [DT_DOUBLE]
device='CPU'; T in [DT_COMPLEX64]
device='CPU'; T in [DT_COMPLEX128]
device='GPU'; T in [DT_FLOAT]
device='GPU'; T in [DT_HALF]
device='GPU'; T in [DT_DOUBLE]
device='GPU'; T in [DT_INT64]
代码如下:
#python 3.5.3/TensorFlow 1.0/win 10 #2017-04-01 蔡军生 http://blog.csdn.net/caimouse ##导入要使用的库import tensorflow as tfimport numpy as np#演示API的类class DemoTF: def __init__(self): '''构造函数''' self.num1 = tf.Variable([1, -2, -3], dtype = tf.int32) self.num2 = tf.Variable([4, 5, -6], dtype = tf.int32) self.sign = tf.sign(self.num1) self.reciprocal = tf.reciprocal(self.num2) def run_graph(self): init = tf.global_variables_initializer() # 初始化变量 with tf.Session() as sess: sess.run(init) self.main(sess) #运行主函数 def main(self, sess): '''主函数''' print(sess.run(self.sign)) print(sess.run(self.reciprocal)) #主程序入口if __name__ == "__main__": demo = DemoTF() demo.run_graph()
1. TensorFlow API攻略
3. C++标准模板库从入门到精通
http://edu.csdn.net/course/detail/3324
4.跟老菜鸟学C++
5. 跟老菜鸟学python
6. 在VC2015里学会使用tinyxml库
7. 在Windows下SVN的版本管理与实战
http://edu.csdn.net/course/detail/2579
8.Visual Studio 2015开发C++程序的基本使用
http://edu.csdn.net/course/detail/2570
9.在VC2015里使用protobuf协议
10.在VC2015里学会使用MySQL数据库
- TensorFlow的异常Reciprocal[T=DT_INT32](Variable_1/read)
- iOS国际化时遇到的异常:read failed: the data couldn't be read because it isn't in the correct format
- 混淆打包出现 java.io.IOException: Can't write、Can't read 异常
- tensorflow中tfrecords文件的save和read
- Reciprocal cycles
- Android SQLite 数据库 java.lang.IllegalStateException: Couldn't read row 0, col -1 from CursorWindow异常
- java.lang.IllegalStateException: Couldn't read row 0, col 6 from CursorWindow异常
- java.lang.IllegalStateException: Couldn't read row 0, col 1 from CursorWindow.异常
- java.lang.IllegalStateException: Couldn't read row 0, col -1 from CursorWindow异常
- ExpandableListView异常Couldn't read row 0, col -1 from CursorWindow
- 封装异常处理的read和write函数
- openjdk7的ImageIO.read()导致jvm异常crash
- windows TensorFlow GPU版本的安装|TensorFlow can't cudat80_64.dll
- xsession can't read .profile
- iOS国际化时遇到的错误:read failed: the data couldn't be read because it isn't in the correct format.
- Tensorflow 04_: tensorboard或者tensorflow的一个"异常"
- Reciprocal Multiplication, a tutorial
- No_26:Reciprocal cycles
- property的默认属性 (2012-01-13 10:39:09)
- cccc L2-018. 多项式A除以B
- How to grab video frames directly from QCamera
- 点击移除样式,再点击新增样式jq代码
- HDU-4849 Wow! Such City!,最短路!
- TensorFlow的异常Reciprocal[T=DT_INT32](Variable_1/read)
- JavaScript算法-排序算法
- java数据结构链表,堆栈,队列相关专题分析与扯谈-堆栈
- zookeeper功能和应用
- RecyclerView加载动画
- java数据结构链表,堆栈,队列等相关专题分析与扯谈-队列
- 最新最全面的QT+Opencv+CMake配置
- java数据结构链表,堆栈,队列,串相关专题分析与扯谈-串结构
- windows 下安装redis