Sunday, November 17, 2024
Google search engine
HomeLanguagesPython – tensorflow.DeviceSpec.to_string()

Python – tensorflow.DeviceSpec.to_string()

TensorFlow is open-source Python library designed by Google to develop Machine Learning models and deep learning  neural networks.

to_string() is used to get the string representation of the DeviceSpec object specifications.

Syntax: tensorflow.DeviceSpec.to_string()

Returns: It returns a string.

Example 1:

Python3




# Importing the library
import tensorflow as tf
  
# Initializing Device Specification
device_spec = tf.DeviceSpec(job ="gfg", replica = 5)
  
# Printing the DeviceSpec 
print('Device Spec: ', device_spec.to_string())


Output:


Device Spec:  /job:gfg/replica:5

Example 2:

Python3




# Importing the library
import tensorflow as tf
  
# Initializing Device Specification
device_spec = tf.DeviceSpec(job ="gfg", replica = 5, device_type = "CPU")
  
# Printing the DeviceSpec 
print('Device Spec: ', device_spec.to_string())


Output:


Device Spec:  /job:gfg/replica:5/device:CPU:*

Dominic Rubhabha-Wardslaus
Dominic Rubhabha-Wardslaushttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Recent Comments