TensorFlow是Google設計的開源Python庫,用於開發機器學習模型和深度學習神經網絡。
to_string()用於獲取DeviceSpec對象規範的字符串表示形式。
用法:tensorflow.DeviceSpec.to_string()
返回值:它返回一個字符串。
範例1:
Python3
# Importing the library
import tensorflow as tf
# Initializing Device Specification
device_spec = tf.DeviceSpec(job ="gfg", replica = 5)
# Printing the DeviceSpec
print('Device Spec:', device_spec.to_string())
輸出:
Device Spec: /job:gfg/replica:5
範例2:
Python3
# Importing the library
import tensorflow as tf
# Initializing Device Specification
device_spec = tf.DeviceSpec(job ="gfg", replica = 5, device_type = "CPU")
# Printing the DeviceSpec
print('Device Spec:', device_spec.to_string())
輸出:
Device Spec: /job:gfg/replica:5/device:CPU:*
相關用法
注:本文由純淨天空篩選整理自aman neekhara大神的英文原創作品 Python – tensorflow.DeviceSpec.to_string()。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。