Python – tensorflow.DeviceSpec.make_merged_spec()
TensorFlow 是由 Google 设计的开源Python库,用于开发机器学习模型和深度学习神经网络。
make_merged_spec用于合并两个 DeviceSpec 的规范。
Syntax: tensorflow.DeviceSpec.make_merged_spec( dev )
Parameters:
- dev: It is DeviceSpec.
Returns: It returns a DeviceSpec object with merged specification.
示例 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: