Skip to content

Commit 9ad7371

Browse files
committed
[keras/engine/base_layer.py,keras/engine/base_layer_utils.py,keras/engine/base_layer_v1.py,keras/engine/base_preprocessing_layer.py,keras/engine/data_adapter.py,keras/engine/functional.py,keras/engine/input_layer.py,keras/engine/training.py,keras/engine/training_v1.py] Standardise docstring usage of "Default to"
1 parent 0f8e81f commit 9ad7371

File tree

9 files changed

+45
-42
lines changed

9 files changed

+45
-42
lines changed

keras/engine/base_layer.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,7 @@ def __init__(
458458

459459
# Whether the layer will track any layers that is set as attribute on
460460
# itself as sub-layers, the weights from the sub-layers will be included
461-
# in the parent layer's variables() as well. Default to True, which
461+
# in the parent layer's variables() as well. Defaults to `True`, which
462462
# means auto tracking is turned on. Certain subclass might want to turn
463463
# it off, like Sequential model.
464464
self._auto_track_sub_layers = True
@@ -3830,9 +3830,9 @@ def __init__(
38303830
force_generator: boolean, default to False, whether to force the
38313831
RandomGenerator to use the code branch of tf.random.Generator.
38323832
rng_type: string, the rng type that will be passed to backend
3833-
RandomGenerator. Default to `None`, which will allow RandomGenerator
3834-
to choose types by itself. Valid values are "stateful", "stateless",
3835-
"legacy_stateful".
3833+
RandomGenerator. `None` will allow RandomGenerator to choose
3834+
types by itself. Valid values are "stateful", "stateless",
3835+
"legacy_stateful". Defaults to `None`.
38363836
**kwargs: other keyword arguments that will be passed to the parent
38373837
*class
38383838
"""

keras/engine/base_layer_utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,8 @@ def make_variable(
9898
or "non_trainable_variables" (e.g. BatchNorm mean, stddev).
9999
Note, if the current variable scope is marked as non-trainable
100100
then this parameter is ignored and any added variables are also
101-
marked as non-trainable. `trainable` defaults to `True` unless
102-
`synchronization` is set to `ON_READ`.
101+
marked as non-trainable. `trainable` becomes `True` unless
102+
`synchronization` is set to `ON_READ`. Defaults to `None`.
103103
caching_device: Passed to `tf.Variable`.
104104
validate_shape: Passed to `tf.Variable`.
105105
constraint: Constraint instance (callable).

keras/engine/base_layer_v1.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ def __init__(
237237

238238
# Whether the layer will track any layers that are set as attribute on
239239
# itself as sub-layers, the weights from the sub-layers will be included
240-
# in the parent layer's variables() as well. Default to True, which
240+
# in the parent layer's variables() as well. Defaults to `True`, which
241241
# means auto tracking is turned on. Certain subclass might want to turn
242242
# it off, like the Sequential model.
243243
self._auto_track_sub_layers = True

keras/engine/base_preprocessing_layer.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,14 +140,14 @@ def compile(self, run_eagerly=None, steps_per_execution=None):
140140
"""Configures the layer for `adapt`.
141141
142142
Arguments:
143-
run_eagerly: Bool. Defaults to `False`. If `True`, this `Model`'s
143+
run_eagerly: Bool. If `True`, this `Model`'s
144144
logic will not be wrapped in a `tf.function`. Recommended to leave
145145
this as `None` unless your `Model` cannot be run inside a
146-
`tf.function`.
147-
steps_per_execution: Int. Defaults to 1. The number of batches to run
146+
`tf.function`. Defaults to `False`.
147+
steps_per_execution: Int. The number of batches to run
148148
during each `tf.function` call. Running multiple batches inside a
149149
single `tf.function` call can greatly improve performance on TPUs or
150-
small models with a large Python overhead.
150+
small models with a large Python overhead. Defaults to `1`.
151151
"""
152152
if steps_per_execution is None:
153153
steps_per_execution = 1

keras/engine/data_adapter.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ def __init__(
268268
_check_data_cardinality(inputs)
269269

270270
# If batch_size is not passed but steps is, calculate from the input
271-
# data. Default to 32 for backwards compat.
271+
# data. Defaults to `32` for backwards compatibility.
272272
if not batch_size:
273273
batch_size = int(math.ceil(num_samples / steps)) if steps else 32
274274

@@ -645,7 +645,7 @@ def __init__(
645645
dataset = dataset.shuffle(num_samples)
646646

647647
# If batch_size is not passed but steps is, calculate from the input
648-
# data. Default to 32 for backwards compatibility.
648+
# data. Defaults to `32` for backwards compatibility.
649649
if not batch_size:
650650
batch_size = int(math.ceil(num_samples / steps)) if steps else 32
651651

keras/engine/functional.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1647,8 +1647,8 @@ def __init__(self, module, method_name=None, **kwargs):
16471647
Args:
16481648
module: The `tf.Module` instance to be wrapped.
16491649
method_name: (Optional) str. The name of the method to use as the
1650-
forward pass of the module. If not set, defaults to '__call__' if
1651-
defined, or 'call'.
1650+
forward pass of the module. If not set, becomes '__call__' if
1651+
defined, or 'call'. Defaults to `None`.
16521652
**kwargs: Additional keywrod arguments. See `tf.keras.layers.Layer`.
16531653
16541654
Raises:

keras/engine/input_layer.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,12 @@ class InputLayer(base_layer.Layer):
8888
will use the `tf.TypeSpec` of this tensor rather
8989
than creating a new placeholder tensor.
9090
sparse: Boolean, whether the placeholder created is meant to be sparse.
91-
Default to `False`.
91+
Defaults to `False`.
9292
ragged: Boolean, whether the placeholder created is meant to be ragged.
9393
In this case, values of `None` in the `shape` argument represent
9494
ragged dimensions. For more information about `tf.RaggedTensor`, see
9595
[this guide](https://www.tensorflow.org/guide/ragged_tensor).
96-
Default to `False`.
96+
Defaults to `False`.
9797
type_spec: A `tf.TypeSpec` object to create Input from. This
9898
`tf.TypeSpec` represents the entire batch. When provided, all other
9999
args except name must be `None`.

keras/engine/training.py

Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -673,12 +673,13 @@ def compile(
673673
coefficients.
674674
weighted_metrics: List of metrics to be evaluated and weighted by
675675
`sample_weight` or `class_weight` during training and testing.
676-
run_eagerly: Bool. Defaults to `False`. If `True`, this `Model`'s
677-
logic will not be wrapped in a `tf.function`. Recommended to leave
678-
this as `None` unless your `Model` cannot be run inside a
679-
`tf.function`. `run_eagerly=True` is not supported when using
680-
`tf.distribute.experimental.ParameterServerStrategy`.
681-
steps_per_execution: Int. Defaults to 1. The number of batches to
676+
run_eagerly: Bool. If `True`, this `Model`'s logic will not be
677+
wrapped in a `tf.function`. Recommended to leave this as `None`
678+
unless your `Model` cannot be run inside a `tf.function`.
679+
`run_eagerly=True` is not supported when using
680+
`tf.distribute.experimental.ParameterServerStrategy`. Defaults to
681+
`False`.
682+
steps_per_execution: Int. The number of batches to
682683
run during each `tf.function` call. Running multiple batches
683684
inside a single `tf.function` call can greatly improve performance
684685
on TPUs or small models with a large Python overhead. At most, one
@@ -687,7 +688,7 @@ def compile(
687688
the size of the epoch. Note that if `steps_per_execution` is set
688689
to `N`, `Callback.on_batch_begin` and `Callback.on_batch_end`
689690
methods will only be called every `N` batches (i.e. before/after
690-
each `tf.function` execution).
691+
each `tf.function` execution). Defaults to `1`.
691692
jit_compile: If `True`, compile the model training step with XLA.
692693
[XLA](https://www.tensorflow.org/xla) is an optimizing compiler
693694
for machine learning.
@@ -708,9 +709,10 @@ def compile(
708709
not process the same data. The number of shards should be at least
709710
the number of workers for good performance. A value of 'auto'
710711
turns on exact evaluation and uses a heuristic for the number of
711-
shards based on the number of workers. Defaults to 0, meaning no
712+
shards based on the number of workers. 0, meaning no
712713
visitation guarantee is provided. NOTE: Custom implementations of
713714
`Model.test_step` will be ignored when doing exact evaluation.
715+
Defaults to `0`.
714716
**kwargs: Arguments supported for backwards compatibility only.
715717
"""
716718
if jit_compile and not tf_utils.can_jit_compile(warn=True):
@@ -1457,11 +1459,11 @@ def fit(
14571459
of index `epochs` is reached.
14581460
verbose: 'auto', 0, 1, or 2. Verbosity mode.
14591461
0 = silent, 1 = progress bar, 2 = one line per epoch.
1460-
'auto' defaults to 1 for most cases, but 2 when used with
1462+
'auto' becomes 1 for most cases, but 2 when used with
14611463
`ParameterServerStrategy`. Note that the progress bar is not
14621464
particularly useful when logged to a file, so verbose=2 is
14631465
recommended when not running interactively (eg, in a production
1464-
environment).
1466+
environment). Defaults to 'auto'.
14651467
callbacks: List of `keras.callbacks.Callback` instances.
14661468
List of callbacks to apply during training.
14671469
See `tf.keras.callbacks`. Note
@@ -2059,11 +2061,11 @@ def evaluate(
20592061
they generate batches).
20602062
verbose: `"auto"`, 0, 1, or 2. Verbosity mode.
20612063
0 = silent, 1 = progress bar, 2 = single line.
2062-
`"auto"` defaults to 1 for most cases, and to 2 when used with
2064+
`"auto"` becomes 1 for most cases, and to 2 when used with
20632065
`ParameterServerStrategy`. Note that the progress bar is not
20642066
particularly useful when logged to a file, so `verbose=2` is
20652067
recommended when not running interactively (e.g. in a production
2066-
environment).
2068+
environment). Defaults to 'auto'.
20672069
sample_weight: Optional Numpy array of weights for the test samples,
20682070
used for weighting the loss function. You can either pass a flat
20692071
(1D) Numpy array with the same length as the input samples
@@ -2419,11 +2421,11 @@ def predict(
24192421
(since they generate batches).
24202422
verbose: `"auto"`, 0, 1, or 2. Verbosity mode.
24212423
0 = silent, 1 = progress bar, 2 = single line.
2422-
`"auto"` defaults to 1 for most cases, and to 2 when used with
2424+
`"auto"` becomes 1 for most cases, and to 2 when used with
24232425
`ParameterServerStrategy`. Note that the progress bar is not
24242426
particularly useful when logged to a file, so `verbose=2` is
24252427
recommended when not running interactively (e.g. in a production
2426-
environment).
2428+
environment). Defaults to 'auto'.
24272429
steps: Total number of steps (batches of samples)
24282430
before declaring the prediction round finished.
24292431
Ignored with the default value of `None`. If x is a `tf.data`
@@ -2958,7 +2960,7 @@ def save(self, filepath, overwrite=True, save_format=None, **kwargs):
29582960
SavedModel format arguments:
29592961
include_optimizer: Only applied to SavedModel and legacy HDF5
29602962
formats. If False, do not save the optimizer state.
2961-
Defaults to True.
2963+
Defaults to `True`.
29622964
signatures: Only applies to SavedModel format. Signatures to save
29632965
with the SavedModel. See the `signatures` argument in
29642966
`tf.saved_model.save` for details.
@@ -3051,7 +3053,7 @@ def save_weights(
30513053
target location, or provide the user with a manual prompt.
30523054
save_format: Either 'tf' or 'h5'. A `filepath` ending in '.h5' or
30533055
'.keras' will default to HDF5 if `save_format` is `None`.
3054-
Otherwise `None` defaults to 'tf'.
3056+
Otherwise, `None` becomes 'tf'. Defaults to `None`.
30553057
options: Optional `tf.train.CheckpointOptions` object that specifies
30563058
options for saving weights.
30573059
@@ -3366,17 +3368,17 @@ def summary(
33663368
(e.g. set this to adapt the display to different
33673369
terminal window sizes).
33683370
positions: Relative or absolute positions of log elements
3369-
in each line. If not provided,
3370-
defaults to `[0.3, 0.6, 0.70, 1.]`
3371+
in each line. If not provided, becomes
3372+
`[0.3, 0.6, 0.70, 1.]`. Defaults to `None`.
33713373
print_fn: Print function to use. By default, prints to `stdout`.
33723374
If `stdout` doesn't work in your environment, change to `print`.
33733375
It will be called on each line of the summary.
33743376
You can set it to a custom function
33753377
in order to capture the string summary.
33763378
expand_nested: Whether to expand the nested models.
3377-
If not provided, defaults to `False`.
3379+
Defaults to `False`.
33783380
show_trainable: Whether to show if a layer is trainable.
3379-
If not provided, defaults to `False`.
3381+
Defaults to `False`.
33803382
layer_range: a list or tuple of 2 strings,
33813383
which is the starting layer name and ending layer name
33823384
(both inclusive) indicating the range of layers to be printed
@@ -3942,7 +3944,8 @@ def _get_compile_args(self, user_metrics=True):
39423944
39433945
Args:
39443946
user_metrics: Whether to return user-supplied metrics or `Metric`
3945-
objects. Defaults to returning the user-supplied metrics.
3947+
objects. If True, returns the user-supplied metrics.
3948+
Defaults to `True`.
39463949
39473950
Returns:
39483951
Dictionary of arguments that were used when compiling the model.
@@ -4186,11 +4189,11 @@ def _get_verbosity(verbose, distribute_strategy):
41864189
distribute_strategy._should_use_with_coordinator
41874190
or not io_utils.is_interactive_logging_enabled()
41884191
):
4189-
# Default to epoch-level logging for PSStrategy or using absl
4192+
# Defaults to epoch-level logging for PSStrategy or using absl
41904193
# logging.
41914194
return 2
41924195
else:
4193-
return 1 # Default to batch-level logging otherwise.
4196+
return 1 # Defaults to batch-level logging otherwise.
41944197
return verbose
41954198

41964199

keras/engine/training_v1.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,10 +269,10 @@ def compile(
269269
output names (strings) to scalar coefficients.
270270
sample_weight_mode: If you need to do timestep-wise
271271
sample weighting (2D weights), set this to `"temporal"`.
272-
`None` defaults to sample-wise weights (1D).
272+
`None` becomes sample-wise weights (1D).
273273
If the model has multiple outputs, you can use a different
274274
`sample_weight_mode` on each output by passing a
275-
dictionary or a list of modes.
275+
dictionary or a list of modes. Defaults to `None`.
276276
weighted_metrics: List of metrics to be evaluated and weighted
277277
by sample_weight or class_weight during training and testing.
278278
target_tensors: By default, Keras will create placeholders for the

0 commit comments

Comments
 (0)