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