Doc format fixes.
PiperOrigin-RevId: 340494524 Change-Id: I7662470f5d63b860896b2845cd48a4abc00d5348
This commit is contained in:
parent
d7a91161c0
commit
3113c71abd
@ -70,17 +70,17 @@ class DeviceSpecV2(object):
|
||||
With eager execution disabled (by default in TensorFlow 1.x and by calling
|
||||
disable_eager_execution() in TensorFlow 2.x), the following syntax
|
||||
can be used:
|
||||
|
||||
|
||||
```python
|
||||
tf.compat.v1.disable_eager_execution()
|
||||
|
||||
|
||||
# Same as previous
|
||||
device_spec = DeviceSpec(job="ps", device_type="GPU", device_index=0)
|
||||
# No need of .to_string() method.
|
||||
with tf.device(device_spec):
|
||||
my_var = tf.Variable(..., name="my_variable")
|
||||
squared_var = tf.square(my_var)
|
||||
```
|
||||
```
|
||||
|
||||
If a `DeviceSpec` is partially specified, it will be merged with other
|
||||
`DeviceSpec`s according to the scope in which it is defined. `DeviceSpec`
|
||||
@ -160,39 +160,43 @@ class DeviceSpecV2(object):
|
||||
def parse_from_string(self, spec):
|
||||
"""Parse a `DeviceSpec` name into its components.
|
||||
|
||||
2.x behavior change:
|
||||
In TensorFlow 1.x, this function mutates its own state and returns itself.
|
||||
In 2.x, DeviceSpecs are immutable, and this function will return a
|
||||
DeviceSpec which contains the spec.
|
||||
**2.x behavior change**:
|
||||
|
||||
Recommended:
|
||||
```
|
||||
# my_spec and my_updated_spec are unrelated.
|
||||
my_spec = tf.DeviceSpec.from_string("/CPU:0")
|
||||
my_updated_spec = tf.DeviceSpec.from_string("/GPU:0")
|
||||
with tf.device(my_updated_spec):
|
||||
...
|
||||
```
|
||||
In TensorFlow 1.x, this function mutates its own state and returns itself.
|
||||
In 2.x, DeviceSpecs are immutable, and this function will return a
|
||||
DeviceSpec which contains the spec.
|
||||
|
||||
Will work in 1.x and 2.x (though deprecated in 2.x):
|
||||
```
|
||||
my_spec = tf.DeviceSpec.from_string("/CPU:0")
|
||||
my_updated_spec = my_spec.parse_from_string("/GPU:0")
|
||||
with tf.device(my_updated_spec):
|
||||
...
|
||||
```
|
||||
* Recommended:
|
||||
|
||||
Will NOT work in 2.x:
|
||||
```
|
||||
my_spec = tf.DeviceSpec.from_string("/CPU:0")
|
||||
my_spec.parse_from_string("/GPU:0") # <== Will not update my_spec
|
||||
with tf.device(my_spec):
|
||||
...
|
||||
```
|
||||
```
|
||||
# my_spec and my_updated_spec are unrelated.
|
||||
my_spec = tf.DeviceSpec.from_string("/CPU:0")
|
||||
my_updated_spec = tf.DeviceSpec.from_string("/GPU:0")
|
||||
with tf.device(my_updated_spec):
|
||||
...
|
||||
```
|
||||
|
||||
In general, `DeviceSpec.from_string` should completely replace
|
||||
`DeviceSpec.parse_from_string`, and `DeviceSpec.replace` should
|
||||
completely replace setting attributes directly.
|
||||
* Will work in 1.x and 2.x (though deprecated in 2.x):
|
||||
|
||||
```
|
||||
my_spec = tf.DeviceSpec.from_string("/CPU:0")
|
||||
my_updated_spec = my_spec.parse_from_string("/GPU:0")
|
||||
with tf.device(my_updated_spec):
|
||||
...
|
||||
```
|
||||
|
||||
* Will NOT work in 2.x:
|
||||
|
||||
```
|
||||
my_spec = tf.DeviceSpec.from_string("/CPU:0")
|
||||
my_spec.parse_from_string("/GPU:0") # <== Will not update my_spec
|
||||
with tf.device(my_spec):
|
||||
...
|
||||
```
|
||||
|
||||
In general, `DeviceSpec.from_string` should completely replace
|
||||
`DeviceSpec.parse_from_string`, and `DeviceSpec.replace` should
|
||||
completely replace setting attributes directly.
|
||||
|
||||
Args:
|
||||
spec: an optional string of the form
|
||||
|
@ -4003,7 +4003,7 @@ def batch_to_space_v2(input, block_shape, crops, name=None): # pylint: disable=
|
||||
|
||||
Examples:
|
||||
|
||||
(1) For the following input of shape `[4, 1, 1, 1]`,
|
||||
1. For the following input of shape `[4, 1, 1, 1]`,
|
||||
`block_shape = [2, 2]`, and `crops = [[0, 0], [0, 0]]`:
|
||||
|
||||
```python
|
||||
@ -4020,7 +4020,7 @@ def batch_to_space_v2(input, block_shape, crops, name=None): # pylint: disable=
|
||||
[[3], [4]]]]
|
||||
```
|
||||
|
||||
(2) For the following input of shape `[4, 1, 1, 3]`,
|
||||
2. For the following input of shape `[4, 1, 1, 3]`,
|
||||
`block_shape = [2, 2]`, and `crops = [[0, 0], [0, 0]]`:
|
||||
|
||||
```python
|
||||
@ -4037,7 +4037,7 @@ def batch_to_space_v2(input, block_shape, crops, name=None): # pylint: disable=
|
||||
[[7, 8, 9], [10, 11, 12]]]]
|
||||
```
|
||||
|
||||
(3) For the following
|
||||
3. For the following
|
||||
input of shape `[4, 2, 2, 1]`,
|
||||
`block_shape = [2, 2]`, and `crops = [[0, 0], [0, 0]]`:
|
||||
|
||||
@ -4057,7 +4057,7 @@ def batch_to_space_v2(input, block_shape, crops, name=None): # pylint: disable=
|
||||
[[13], [14], [15], [16]]]
|
||||
```
|
||||
|
||||
(4) For the following input of shape
|
||||
4. For the following input of shape
|
||||
`[8, 1, 3, 1]`,
|
||||
`block_shape = [2, 2]`, and `crops = [[0, 0], [2, 0]]`:
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user