TensorFlow是Google设计的开源Python库,用于开发机器学习模型和深度学习神经网络。
__eq__()用于检查两个DeviceSpec对象的相等性。
用法:tensorflow.DeviceSpec.__eq__( other )
参数:
- other:它是一个DeviceSpec对象。
返回值:如果DeviceSpec对象规范相同,则返回True,否则返回False。
范例1:
Python3
# Importing the library
import tensorflow as tf
# Initializing Device Specification
device_spec = tf.DeviceSpec(job ="gfg2", replica = 5, task = 2, device_type ="GPU", device_index = 1)
device_spec2 = tf.DeviceSpec(job ="gfg2", replica = 5, task = 2, device_type ="GPU", device_index = 1)
# Printing the DeviceSpec object
print('Device Spec:', device_spec.to_string())
print('Device Spec2:', device_spec2.to_string())
# Finding the result
res = device_spec.__eq__(device_spec2)
# Printing the result
print('Res:', res)
输出:
Device Spec: /job:gfg2/replica:5/task:2/device:GPU:1 Device Spec2: /job:gfg2/replica:5/task:2/device:GPU:1 Res: True
范例2:
Python3
# Importing the library
import tensorflow as tf
# Initializing Device Specification
device_spec = tf.DeviceSpec(job ="gfg2", replica = 5, task = 2, device_type ="GPU", device_index = 1)
device_spec2 = tf.DeviceSpec(job ="gfg2", replica = 5, task = 2, device_type ="CPU", device_index = 2)
# Printing the DeviceSpec object
print('Device Spec:', device_spec.to_string())
print('Device Spec2:', device_spec2.to_string())
# Finding the result
res = device_spec.__eq__(device_spec2)
# Printing the result
print('Res:', res)
输出:
Device Spec: /job:gfg2/replica:5/task:2/device:GPU:1 Device Spec2: /job:gfg2/replica:5/task:2/device:CPU:2 Res: False
相关用法
注:本文由纯净天空筛选整理自aman neekhara大神的英文原创作品 Python – tensorflow.DeviceSpec.__eq__()。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。