Python – tensorflow.DeviceSpec.replica Attribute
TensorFlow is open-source Python library designed by Google to develop Machine Learning models and deep learning neural networks.
replica is used to get the replica index of DeviceSpec.
Syntax: tensorflow.DeviceSpec.replica
Returns: It returns the replica index of the DeviceSpec.
Example 1:
Python3
import tensorflow as tf
device_spec = tf.DeviceSpec(job = "gfg2" , device_type = "GPU" , device_index = 1 )
print ( 'Device Spec: ' , device_spec)
replica = device_spec.replica
print ( 'Replica: ' , replica)
|
Output:
Device Spec: <tensorflow.python.framework.device_spec.DeviceSpecV2 object at 0x7fe5ba981b88>
Replica: None
Example 2:
Python3
import tensorflow as tf
device_spec = tf.DeviceSpec(job = "gfg2" , replica = 5 , device_type = "GPU" , device_index = 1 )
print ( 'Device Spec: ' , device_spec)
replica = device_spec.replica
print ( 'Replica: ' , replica)
|
Output:
Device Spec: <tensorflow.python.framework.device_spec.DeviceSpecV2 object at 0x7fe5ba981d08>
Replica: 5
Last Updated :
28 Jul, 2020
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...