tensorflow_api_4:tf.equal( )

来源:互联网 发布:mac 炉石传说 插件 编辑:程序博客网 时间:2024/05/17 18:17

tf.equal( )

  • 函数作用:
    逐元素比较两个tensor x, y,返回x == y的真值

  • 参数:
    tf.equal(x, y, name=None)
    x: 一个tensor. 必须是以下类型:half, float32, float64, uint8, int8, int16, int32, int64, complex64, quint8, qint8, qint32, string, bool, complex128
    y: 一个tensor. 必须与x 的数据类型一致。
    name: 自定义操作的名称 (可选)。

  • 返回:
    一个bool类型的tensor

  • 例子:

import tensorflow as tf  A = tf.constant([1, 3, 4, 5, 6]) B = tf.constant([1, 3, 4, 3, 2]) with tf.Session() as sess:      print(sess.run(tf.equal(A, B)))  # 输出[ True  True  True False False]
原创粉丝点击