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