Python - tensorflow.DeviceSpec.from_string() Last Updated : 01 Aug, 2020 Comments Improve Suggest changes Like Article Like Report TensorFlow is open-source Python library designed by Google to develop Machine Learning models and deep learning neural networks. from_string is used to generate DeviceSpec from string. Syntax: tensorflow.DeviceSpec.from_string( spec ) Parameters: spec: It is a string of the form /job:/replica:/task:/device:CPU: or /job:/replica:/task:/device:GPU with all entries being optional. Returns: It returns a DeviceSpec object generated by the string. Example 1: Python3 # Importing the library import tensorflow as tf # Formatting the string spec = '/job:gfg / replica:1 / task:2' # Initializing Device Specification device_spec = tf.DeviceSpec.from_string(spec) # Printing the DeviceSpec object print('Device Spec: ', device_spec) Output: Device Spec: <tensorflow.python.framework.device_spec.DeviceSpecV2 object at 0x7fadb9428168> Example 2: Python3 # Importing the library import tensorflow as tf # Formatting the string spec = '/job:gfg / replica:2 / task:3' # Initializing Device Specification device_spec = tf.DeviceSpec.from_string(spec) # Printing the DeviceSpec object print('Device Spec: ', device_spec) Output: Device Spec: <tensorflow.python.framework.device_spec.DeviceSpecV2 object at 0x7fadb9428228> Comment More infoAdvertise with us Next Article Python - tensorflow.DeviceSpec.from_string() aman neekhara Follow Improve Article Tags : Python Python-Tensorflow Python Tensorflow-math-functions Practice Tags : python Similar Reads Python - tensorflow.DeviceSpec.parse_from_string() TensorFlow is open-source Python library designed by Google to develop Machine Learning models and deep learning  neural networks. parse_from_string() is used to parse a DeviceSpec name into its components. Syntax: tensorflow.DeviceSpec.parse_from_string( spec ) Parameters: spec: It is a string of 1 min read 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. Exa 1 min read Python - tensorflow.DeviceSpec TensorFlow is open-source Python library designed by Google to develop Machine Learning models and deep learning  neural networks. DeviceSpec represents the specification of TensorFlow device. This specification might be partial. If a DeviceSpec is partially specified, it will be merged with other 1 min read Python - tensorflow.DeviceSpec.__eq__() TensorFlow is open-source Python library designed by Google to develop Machine Learning models and deep learning  neural networks. __eq__() is used to check the equality of two DeviceSpec objects. Syntax: tensorflow.DeviceSpec.__eq__( other ) Parameters: other: It is a DeviceSpec object. Returns: It 2 min read Python - tensorflow.DeviceSpec.replace() TensorFlow is open-source Python library designed by Google to develop Machine Learning models and deep learning  neural networks. replace() is used to override the specification of DeviceSpec object and get the new object. Syntax: tensorflow.DeviceSpec.replace(**kwargs) Parameters: **kwargs: This m 1 min read 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 ) Parameters: device_name: It specifies 2 min read Python - tensorflow.DeviceSpec.make_merged_spec() TensorFlow is open-source Python library designed by Google to develop Machine Learning models and deep learning  neural networks. make_merged_spec is used to merge the specifications of two DeviceSpec. Syntax: tensorflow.DeviceSpec.make_merged_spec( dev ) Parameters: dev: It is DeviceSpec. Returns 2 min read Python - tensorflow.DeviceSpec.job Attribute TensorFlow is open-source Python library designed by Google to develop Machine Learning models and deep learning  neural networks. job is used to get the job from the Device Specification. Syntax: tensorflow.DeviceSpec.job Returns: It returns the job of the DeviceSpec. Example 1: Python3 # Importing 1 min read Python - tensorflow.DeviceSpec.task Attribute 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 # Importing the 1 min read 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: Python 1 min read Like