Skip to content

Commit 5331dac

Browse files
committed
[keras/legacy_tf_layers/base.py,keras/legacy_tf_layers/migration_utils.py,keras/legacy_tf_layers/variable_scope_shim.py] Standardise docstring usage of "Default to"
1 parent 0f8e81f commit 5331dac

File tree

3 files changed

+15
-11
lines changed

3 files changed

+15
-11
lines changed

keras/legacy_tf_layers/base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -365,8 +365,8 @@ def add_weight(
365365
or "non_trainable_variables" (e.g. BatchNorm mean, stddev).
366366
Note, if the current variable scope is marked as non-trainable
367367
then this parameter is ignored and any added variables are also
368-
marked as non-trainable. `trainable` defaults to `True` unless
369-
`synchronization` is set to `ON_READ`.
368+
marked as non-trainable. `trainable` becomes `True` unless
369+
`synchronization` is set to `ON_READ`. Defaults to `True`.
370370
constraint: constraint instance (callable).
371371
use_resource: Whether to use `ResourceVariable`.
372372
synchronization: Indicates when a distributed a variable will be

keras/legacy_tf_layers/migration_utils.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,11 @@ class DeterministicRandomTestTool(object):
4646
"""
4747

4848
def __init__(self, seed: int = 42, mode="constant"):
49-
"""Set mode to 'constant' or 'num_random_ops'. Defaults to
50-
'constant'."""
49+
"""
50+
Args:
51+
mode: Set mode to 'constant' or 'num_random_ops'. Defaults to
52+
'constant'.
53+
"""
5154
if mode not in {"constant", "num_random_ops"}:
5255
raise ValueError(
5356
"Mode arg must be 'constant' or 'num_random_ops'. "

keras/legacy_tf_layers/variable_scope_shim.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ def get_variable(
215215
Args:
216216
name: The name of the new or existing variable.
217217
shape: Shape of the new or existing variable.
218-
dtype: Type of the new or existing variable (defaults to `DT_FLOAT`).
218+
dtype: Type of the new or existing variable. Defaults to `DT_FLOAT`.
219219
initializer: Initializer for the variable.
220220
regularizer: A (Tensor -> Tensor or None) function; the result of
221221
applying it on a newly created variable will be added to the
@@ -226,16 +226,16 @@ def get_variable(
226226
always forced to be False.
227227
trainable: If `True` also add the variable to the graph collection
228228
`GraphKeys.TRAINABLE_VARIABLES` (see `tf.Variable`). `trainable`
229-
defaults to `True`, unless `synchronization` is set to `ON_READ`, in
230-
which case it defaults to `False`.
229+
becomes `True`, unless `synchronization` is set to `ON_READ`, in
230+
which case it becomes `False`. Defaults to `True`.
231231
collections: List of graph collections keys to add the `Variable` to.
232232
Defaults to `[GraphKeys.GLOBAL_VARIABLES]` (see `tf.Variable`).
233233
caching_device: Optional device string or function describing where
234-
the Variable should be cached for reading. Defaults to the
234+
the Variable should be cached for reading. `None` to use the
235235
Variable's device. If not `None`, caches on another device.
236236
Typical use is to cache on the device where the Ops using the
237237
`Variable` reside, to deduplicate copying through `Switch` and other
238-
conditional statements.
238+
conditional statements. Defaults to `None`.
239239
partitioner: Optional callable that accepts a fully defined
240240
`TensorShape` and dtype of the `Variable` to be created, and returns
241241
a list of partitions for each axis (currently only one axis can be
@@ -245,8 +245,9 @@ def get_variable(
245245
initial_value must be known.
246246
use_resource: If False, creates a regular Variable. If True, creates
247247
instead an experimental ResourceVariable which has well-defined
248-
semantics. Defaults to False (will later change to True). When eager
249-
execution is enabled this argument is always forced to be true.
248+
semantics. When starting off as False it will later change to True.
249+
When eager execution is enabled this argument always True.
250+
Defaults to `False`.
250251
custom_getter: Callable that takes as a first argument the true
251252
getter, and allows overwriting the internal get_variable method. The
252253
signature of `custom_getter` should match that of this method, but

0 commit comments

Comments
 (0)