版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/u010255642/article/details/82115075
参数 'tensor' 要属于以下类型才能通过 bfloat16, float16, float32, float64,返回原tensorflow。否则报InvalidArgument
错误。
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
"""
Created on Mon Aug 27 11:16:32 2018
@author: myhaspl
"""
import tensorflow as tf
a = tf.constant([[1., 2.], [3., 4.]])
b = tf.constant([[1, 2], [3, 4]])
check_a=tf.check_numerics(a,"non number")
#check_b=tf.check_numerics(b,"non number")
sess=tf.Session()
with sess:
print sess.run(check_a)
# print sess.run(check_b)
[[1. 2.]
[3. 4.]]
去除注释,将报错
TypeError: Value passed to parameter 'tensor' has DataType int32 not in list of allowed values: bfloat16, float16, float32, float64