Python – tensorflow.device()
TensorFlow is open-source Python library designed by Google to develop Machine Learning models and deep learning neural networks.
device() is used to explicitly specify the device in which operation should be performed.
Syntax: tensorflow.device( device_name )
- device_name: It specifies the device name to be used in this context.
Returns: It returns a context manager that specifies the default device to use for newly created ops.
Device Spec: /job:localhost/replica:0/device:CPU:* Executing op MatMul in device /job:localhost/replica:0/task:0/device:CPU:0
Example 2: In this example device specification specifies GPU to be used but system couldn’t find GPU so it will run the operation on CPU.
Device Spec: /job:localhost/replica:0/device:GPU:* Executing op MatMul in device /job:localhost/replica:0/task:0/device:CPU:0
My Personal Notes arrow_drop_up
Please Login to comment...