📜  Python – tensorflow.DeviceSpec

📅  最后修改于: 2022-05-13 01:55:23.899000             🧑  作者: Mango

Python – tensorflow.DeviceSpec

TensorFlow 是由 Google 设计的开源Python库,用于开发机器学习模型和深度学习神经网络。

DeviceSpec表示 TensorFlow 设备的规格。该规范可能是部分的。如果一个 DeviceSpec 被部分指定,它将根据定义的范围与其他 DeviceSpec 合并。

示例 1:

Python3
# Importing the library
import tensorflow as tf
  
# Initializing Device Specification
device_spec = tf.DeviceSpec(job ="gfg", device_type ="GPU", device_index = 0)
  
# Printing the result
print('DeviceSpec: ', device_spec)


Python3
# Importing the library
import tensorflow as tf
  
# Initializing Device Specification
device_spec = tf.DeviceSpec(job ="gfg", device_type ="CPU", device_index = 0)
  
# Printing the result
print('DeviceSpec: ', device_spec)


输出:

DeviceSpec:  

示例 2:

Python3

# Importing the library
import tensorflow as tf
  
# Initializing Device Specification
device_spec = tf.DeviceSpec(job ="gfg", device_type ="CPU", device_index = 0)
  
# Printing the result
print('DeviceSpec: ', device_spec)

输出:

DeviceSpec: