tf.equal (API r1.3)

tf.equal (API r1.3)

https://github.com/tensorflow/docs/tree/r1.3/site/en/api_docs/api_docs/python/tf
site/en/api_docs/api_docs/python/tf/equal.md

equal(
    x,
    y,
    name=None
)

Defined in tensorflow/python/ops/gen_math_ops.py.
See the guide: Control Flow > Comparison Operators

Returns the truth value of (x == y) element-wise.
對輸入的 x 和 y 兩個 Tensor 逐元素 (element-wise) 做 (x == y) 邏輯比較,返回 bool 類型的 Tensor。

NOTE: Equal supports broadcasting. (Equal 支持 broadcasting。)

1. Args

x: A Tensor. Must be one of the following types: half, float32, float64, uint8, int8, int16, int32, int64, complex64, quint8, qint8, qint32, string, bool, complex128.
y: A Tensor. Must have the same type as x. (y 的類型必須與 x 相同。)
name: A name for the operation (optional). (給這個操作取一個名字,可選。)

2. Returns

A Tensor of type bool.
bool 類型的 Tensor。

3. x 和 y 具有相同的 shape and type

#!/usr/bin/env python
# -*- coding: utf-8 -*-

from __future__ import absolute_import
from __future__ import print_function
from __future__ import division

import os
import sys
import numpy as np
import tensorflow as tf

sys.path.append(os.path.dirname(os.path.abspath(__file__)))
current_directory = os.path.dirname(os.path.abspath(__file__))

print(16 * "++--")
print("current_directory:", current_directory)
print(16 * "++--")

t1 = tf.constant([[0, 4, 2], [3, 3, 6]], dtype=np.int32)
t2 = tf.constant([[0, 1, 2], [3, 4, 5]], dtype=np.int32)

y = tf.equal(t1, t2)

with tf.Session() as sess:
    output_equal = sess.run(y)
    print("output_equal.shape:\n", output_equal.shape)
    print("output_equal:\n", output_equal)
/usr/bin/python2.7 /home/strong/tensorflow_work/R2CNN_Faster-RCNN_Tensorflow/yongqiang.py
++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--
current_directory: /home/strong/tensorflow_work/R2CNN_Faster-RCNN_Tensorflow
++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--
2019-08-16 10:47:00.052143: I tensorflow/core/platform/cpu_feature_guard.cc:137] Your CPU supports instructions that this TensorFlow binary was not compiled to use: SSE4.1 SSE4.2 AVX AVX2 FMA
2019-08-16 10:47:00.137906: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:892] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
2019-08-16 10:47:00.138152: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1030] Found device 0 with properties: 
name: GeForce GTX 1080 major: 6 minor: 1 memoryClockRate(GHz): 1.7335
pciBusID: 0000:01:00.0
totalMemory: 7.92GiB freeMemory: 7.40GiB
2019-08-16 10:47:00.138163: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1120] Creating TensorFlow device (/device:GPU:0) -> (device: 0, name: GeForce GTX 1080, pci bus id: 0000:01:00.0, compute capability: 6.1)
output_equal.shape:
 (2, 3)
output_equal:
 [[ True False  True]
 [ True False False]]

Process finished with exit code 0
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章