tf.assert_equal()

tf.assert_equal()如果x,y不一致就抛出异常
参数:

tf.assert_equal(
    x,
    y,
    data=None,
    summarize=None,
    message=None,
    name=None
)

使用案例:

import tensorflow as tf
x = 1
y = 2
sess = tf.Session()
with tf.control_dependencies([tf.assert_equal(x, y)]):
  output = tf.reduce_sum(x)
  print(sess.run(output))

你可能感兴趣的:(TensorFlow)