📜  Python – tensorflow.DeviceSpec.make_merged_spec()

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

Python – tensorflow.DeviceSpec.make_merged_spec()

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

make_merged_spec用于合并两个 DeviceSpec 的规范。

示例 1:

Python3
# Importing the library
import tensorflow as tf
  
# Initializing Device Specification
device_spec = tf.DeviceSpec(job ="gfg", replica = 5)
device_spec2 = tf.DeviceSpec(device_type ="CPU")
  
# Printing the DeviceSpec object
print('Device Spec: ', device_spec)
print('Device Spec2: ', device_spec2)
  
# Getting new DeviceSpec object
new_device_spec = device_spec.make_merged_spec(device_spec2)
  
# Printing the result
print('New Device Spec: ', new_device_spec)


Python3
# Importing the library
import tensorflow as tf
  
# Initializing Device Specification
device_spec = tf.DeviceSpec(job ="gfg", replica = 5)
device_spec2 = tf.DeviceSpec(device_type ="CPU", device_index = 2)
  
# Printing the DeviceSpec object
print('Device Spec: ', device_spec)
print('Device Spec2: ', device_spec2)
  
# Getting new DeviceSpec object
new_device_spec = device_spec.make_merged_spec(device_spec2)
  
# Printing the result
print('New Device Spec: ', new_device_spec)


输出:

Device Spec:  
Device Spec2:  
New Device Spec:  

示例 2:

Python3

# Importing the library
import tensorflow as tf
  
# Initializing Device Specification
device_spec = tf.DeviceSpec(job ="gfg", replica = 5)
device_spec2 = tf.DeviceSpec(device_type ="CPU", device_index = 2)
  
# Printing the DeviceSpec object
print('Device Spec: ', device_spec)
print('Device Spec2: ', device_spec2)
  
# Getting new DeviceSpec object
new_device_spec = device_spec.make_merged_spec(device_spec2)
  
# Printing the result
print('New Device Spec: ', new_device_spec)

输出:

Device Spec:  
Device Spec2:  
New Device Spec: