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__()。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。