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()。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。