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 method accepts all the parameters accepted by DeviceSpec constructor.
Returns: It returns a DeviceSpec object.
Example 1:
Python3
import tensorflow as tf
device_spec = tf.DeviceSpec(job = "gfg" , replica = 5 )
print ( 'Device Spec: ' , device_spec.to_string())
new_device_spec = device_spec.replace(job = "gfg2" )
print ( 'New Device Spec: ' , new_device_spec.to_string())
|
Output:
Device Spec: /job:gfg/replica:5
New Device Spec: /job:gfg2/replica:5
Example 2:
Python3
import tensorflow as tf
device_spec = tf.DeviceSpec(job = "gfg" , replica = 5 )
print ( 'Device Spec: ' , device_spec.to_string())
new_device_spec = device_spec.replace(job = "gfg2" , device_type = "CPU" )
print ( 'New Device Spec: ' , new_device_spec.to_string())
|
Output:
Device Spec: /job:gfg/replica:5
New Device Spec: /job:gfg2/replica:5/device:CPU:*
Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape,
GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out -
check it out now!
Last Updated :
01 Aug, 2020
Like Article
Save Article