Skip to content

Move Defaults to to end of arg docstring and standardise values #17748

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions keras/applications/convnext.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@

Args:
include_top: Whether to include the fully-connected
layer at the top of the network. Defaults to True.
layer at the top of the network. Defaults to `True`.
weights: One of `None` (random initialization),
`"imagenet"` (pre-training on ImageNet-1k), or the path to the weights
file to be loaded. Defaults to `"imagenet"`.
Expand All @@ -135,7 +135,7 @@
if `include_top` is False.
It should have exactly 3 inputs channels.
pooling: Optional pooling mode for feature extraction
when `include_top` is `False`. Defaults to None.
when `include_top` is `False`.
- `None` means that the output of the model will be
the 4D tensor output of the last convolutional layer.
- `avg` means that global average pooling
Expand All @@ -144,16 +144,16 @@
the output of the model will be a 2D tensor.
- `max` means that global max pooling will
be applied.
Defaults to `None`.
classes: Optional number of classes to classify images
into, only to be specified if `include_top` is True, and
if no `weights` argument is specified. Defaults to 1000 (number of
ImageNet classes).
if no `weights` argument is specified. 1000 is how many
ImageNet classes there are. Defaults to `1000`.
classifier_activation: A `str` or callable. The activation function to use
on the "top" layer. Ignored unless `include_top=True`. Set
`classifier_activation=None` to return the logits of the "top" layer.
Defaults to `"softmax"`.
When loading pretrained weights, `classifier_activation` can only
be `None` or `"softmax"`.
be `None` or `"softmax"`. Defaults to `"softmax"`.

Returns:
A `keras.Model` instance.
Expand Down Expand Up @@ -754,10 +754,10 @@ def preprocess_input(x, data_format=None):

Args:
x: A floating point `numpy.array` or a `tf.Tensor`.
data_format: Optional data format of the image tensor/array. Defaults to
None, in which case the global setting
`tf.keras.backend.image_data_format()` is used (unless you changed it,
it defaults to "channels_last").{mode}
data_format: Optional data format of the image tensor/array. `None` means
the global setting `tf.keras.backend.image_data_format()` is used
(unless you changed it, it uses "channels_last").{mode}.
Defaults to `None`.

Returns:
Unchanged `numpy.array` or `tf.Tensor`.
Expand Down
16 changes: 8 additions & 8 deletions keras/applications/efficientnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@

Args:
include_top: Whether to include the fully-connected
layer at the top of the network. Defaults to True.
layer at the top of the network. Defaults to `True`.
weights: One of `None` (random initialization),
'imagenet' (pre-training on ImageNet),
or the path to the weights file to be loaded. Defaults to 'imagenet'.
Expand All @@ -203,7 +203,7 @@
if `include_top` is False.
It should have exactly 3 inputs channels.
pooling: Optional pooling mode for feature extraction
when `include_top` is `False`. Defaults to None.
when `include_top` is `False`. Defaults to `None`.
- `None` means that the output of the model will be
the 4D tensor output of the
last convolutional layer.
Expand All @@ -215,8 +215,8 @@
be applied.
classes: Optional number of classes to classify images
into, only to be specified if `include_top` is True, and
if no `weights` argument is specified. Defaults to 1000 (number of
ImageNet classes).
if no `weights` argument is specified. 1000 is how many
ImageNet classes there are. Defaults to `1000`.
classifier_activation: A `str` or callable. The activation function to use
on the "top" layer. Ignored unless `include_top=True`. Set
`classifier_activation=None` to return the logits of the "top" layer.
Expand Down Expand Up @@ -852,10 +852,10 @@ def preprocess_input(x, data_format=None):

Args:
x: A floating point `numpy.array` or a `tf.Tensor`.
data_format: Optional data format of the image tensor/array. Defaults to
None, in which case the global setting
`tf.keras.backend.image_data_format()` is used (unless you changed it,
it defaults to "channels_last").{mode}
data_format: Optional data format of the image tensor/array. `None` means
the global setting `tf.keras.backend.image_data_format()` is used
(unless you changed it, it uses "channels_last").{mode}.
Defaults to `None`.

Returns:
Unchanged `numpy.array` or `tf.Tensor`.
Expand Down
19 changes: 10 additions & 9 deletions keras/applications/efficientnet_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,7 @@

Args:
include_top: Boolean, whether to include the fully-connected
layer at the top of the network. Defaults to True.
layer at the top of the network. Defaults to `True`.
weights: One of `None` (random initialization),
`"imagenet"` (pre-training on ImageNet),
or the path to the weights file to be loaded. Defaults to `"imagenet"`.
Expand All @@ -585,7 +585,7 @@
if `include_top` is False.
It should have exactly 3 inputs channels.
pooling: Optional pooling mode for feature extraction
when `include_top` is `False`. Defaults to None.
when `include_top` is `False`.
- `None` means that the output of the model will be
the 4D tensor output of the
last convolutional layer.
Expand All @@ -595,16 +595,17 @@
the output of the model will be a 2D tensor.
- `"max"` means that global max pooling will
be applied.
Defaults to `None`.
classes: Optional number of classes to classify images
into, only to be specified if `include_top` is True, and
if no `weights` argument is specified. Defaults to 1000 (number of
ImageNet classes).
if no `weights` argument is specified. 1000 is how many
ImageNet classes there are. Defaults to `1000`.
classifier_activation: A string or callable. The activation function to use
on the `"top"` layer. Ignored unless `include_top=True`. Set
`classifier_activation=None` to return the logits of the "top" layer.
Defaults to `"softmax"`.
When loading pretrained weights, `classifier_activation` can only
be `None` or `"softmax"`.
Defaults to `"softmax"`.

Returns:
A `keras.Model` instance.
Expand Down Expand Up @@ -1342,10 +1343,10 @@ def preprocess_input(x, data_format=None):

Args:
x: A floating point `numpy.array` or a `tf.Tensor`.
data_format: Optional data format of the image tensor/array. Defaults to
None, in which case the global setting
`tf.keras.backend.image_data_format()` is used (unless you changed it,
it defaults to "channels_last").{mode}
data_format: Optional data format of the image tensor/array. `None` means
the global setting `tf.keras.backend.image_data_format()` is used
(unless you changed it, it uses "channels_last").{mode}.
Defaults to `None`.

Returns:
Unchanged `numpy.array` or `tf.Tensor`.
Expand Down
11 changes: 6 additions & 5 deletions keras/applications/imagenet_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@
The preprocessed data are written over the input data
if the data types are compatible. To avoid this
behaviour, `numpy.copy(x)` can be used.
data_format: Optional data format of the image tensor/array. Defaults to
None, in which case the global setting
`tf.keras.backend.image_data_format()` is used (unless you changed it,
it defaults to "channels_last").{mode}
data_format: Optional data format of the image tensor/array. None, means
the global setting `tf.keras.backend.image_data_format()` is used
(unless you changed it, it uses "channels_last").{mode}
Defaults to `None`.

Returns:
Preprocessed `numpy.array` or a `tf.Tensor` with type `float32`.
Expand All @@ -70,7 +70,7 @@
"""

PREPROCESS_INPUT_MODE_DOC = """
mode: One of "caffe", "tf" or "torch". Defaults to "caffe".
mode: One of "caffe", "tf" or "torch".
- caffe: will convert the images from RGB to BGR,
then will zero-center each color channel with
respect to the ImageNet dataset,
Expand All @@ -80,6 +80,7 @@
- torch: will scale pixels between 0 and 1 and then
will normalize each channel with respect to the
ImageNet dataset.
Defaults to "caffe".
"""

PREPROCESS_INPUT_DEFAULT_ERROR_DOC = """
Expand Down
8 changes: 4 additions & 4 deletions keras/applications/inception_v3.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,13 @@ def InceptionV3(

Args:
include_top: Boolean, whether to include the fully-connected
layer at the top, as the last layer of the network. Default to `True`.
layer at the top, as the last layer of the network. Defaults to `True`.
weights: One of `None` (random initialization),
`imagenet` (pre-training on ImageNet),
or the path to the weights file to be loaded. Default to `imagenet`.
or the path to the weights file to be loaded. Defaults to `imagenet`.
input_tensor: Optional Keras tensor (i.e. output of `layers.Input()`)
to use as image input for the model. `input_tensor` is useful for
sharing inputs between multiple different networks. Default to None.
sharing inputs between multiple different networks. Defaults to `None`.
input_shape: Optional shape tuple, only to be specified
if `include_top` is False (otherwise the input shape
has to be `(299, 299, 3)` (with `channels_last` data format)
Expand All @@ -108,7 +108,7 @@ def InceptionV3(
- `max` means that global max pooling will be applied.
classes: optional number of classes to classify images
into, only to be specified if `include_top` is True, and
if no `weights` argument is specified. Default to 1000.
if no `weights` argument is specified. Defaults to 1000.
classifier_activation: A `str` or callable. The activation function to use
on the "top" layer. Ignored unless `include_top=True`. Set
`classifier_activation=None` to return the logits of the "top" layer.
Expand Down
17 changes: 9 additions & 8 deletions keras/applications/mobilenet.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,25 +124,26 @@ def MobileNet(
`channels_last` data format) or (3, 224, 224) (with `channels_first`
data format). It should have exactly 3 inputs channels, and width and
height should be no smaller than 32. E.g. `(200, 200, 3)` would be one
valid value. Default to `None`.
valid value. Defaults to `None`.
`input_shape` will be ignored if the `input_tensor` is provided.
alpha: Controls the width of the network. This is known as the width
multiplier in the MobileNet paper. - If `alpha` < 1.0, proportionally
decreases the number of filters in each layer. - If `alpha` > 1.0,
proportionally increases the number of filters in each layer. - If
`alpha` = 1, default number of filters from the paper are used at each
layer. Default to 1.0.
layer. Defaults to `1.0`.
depth_multiplier: Depth multiplier for depthwise convolution. This is
called the resolution multiplier in the MobileNet paper. Default to 1.0.
dropout: Dropout rate. Default to 0.001.
called the resolution multiplier in the MobileNet paper.
Defaults to `1.0`.
dropout: Dropout rate. Defaults to `0.001`.
include_top: Boolean, whether to include the fully-connected layer at the
top of the network. Default to `True`.
top of the network. Defaults to `True`.
weights: One of `None` (random initialization), 'imagenet' (pre-training
on ImageNet), or the path to the weights file to be loaded. Default to
on ImageNet), or the path to the weights file to be loaded. Defaults to
`imagenet`.
input_tensor: Optional Keras tensor (i.e. output of `layers.Input()`) to
use as image input for the model. `input_tensor` is useful for sharing
inputs between multiple different networks. Default to None.
inputs between multiple different networks. Defaults to `None`.
pooling: Optional pooling mode for feature extraction when `include_top`
is `False`.
- `None` (default) means that the output of the model will be
Expand All @@ -154,7 +155,7 @@ def MobileNet(
- `max` means that global max pooling will be applied.
classes: Optional number of classes to classify images into, only to be
specified if `include_top` is True, and if no `weights` argument is
specified. Defaults to 1000.
specified. Defaults to `1000`.
classifier_activation: A `str` or callable. The activation function to use
on the "top" layer. Ignored unless `include_top=True`. Set
`classifier_activation=None` to return the logits of the "top" layer.
Expand Down
8 changes: 4 additions & 4 deletions keras/applications/mobilenet_v3.py
Original file line number Diff line number Diff line change
Expand Up @@ -679,10 +679,10 @@ def preprocess_input(x, data_format=None):

Args:
x: A floating point `numpy.array` or a `tf.Tensor`.
data_format: Optional data format of the image tensor/array. Defaults to
None, in which case the global setting
`tf.keras.backend.image_data_format()` is used (unless you changed it,
it defaults to "channels_last").{mode}
data_format: Optional data format of the image tensor/array. `None` means
the global setting `tf.keras.backend.image_data_format()` is used
(unless you changed it, it uses "channels_last").{mode}.
Defaults to `None`.

Returns:
Unchanged `numpy.array` or `tf.Tensor`.
Expand Down
20 changes: 10 additions & 10 deletions keras/applications/regnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@

Args:
include_top: Whether to include the fully-connected
layer at the top of the network. Defaults to True.
layer at the top of the network. Defaults to `True`.
weights: One of `None` (random initialization),
`"imagenet"` (pre-training on ImageNet), or the path to the weights
file to be loaded. Defaults to `"imagenet"`.
Expand All @@ -353,7 +353,7 @@
if `include_top` is False.
It should have exactly 3 inputs channels.
pooling: Optional pooling mode for feature extraction
when `include_top` is `False`. Defaults to None.
when `include_top` is `False`.
- `None` means that the output of the model will be
the 4D tensor output of the
last convolutional layer.
Expand All @@ -363,16 +363,16 @@
the output of the model will be a 2D tensor.
- `max` means that global max pooling will
be applied.
Defaults to `None`.
classes: Optional number of classes to classify images
into, only to be specified if `include_top` is True, and
if no `weights` argument is specified. Defaults to 1000 (number of
ImageNet classes).
if no `weights` argument is specified. 1000 is how many
ImageNet classes there are. Defaults to `1000`.
classifier_activation: A `str` or callable. The activation function to use
on the "top" layer. Ignored unless `include_top=True`. Set
`classifier_activation=None` to return the logits of the "top" layer.
Defaults to `"softmax"`.
When loading pretrained weights, `classifier_activation` can only
be `None` or `"softmax"`.
be `None` or `"softmax"`. Defaults to `"softmax"`.

Returns:
A `keras.Model` instance.
Expand Down Expand Up @@ -1819,10 +1819,10 @@ def preprocess_input(x, data_format=None):

Args:
x: A floating point `numpy.array` or a `tf.Tensor`.
data_format: Optional data format of the image tensor/array. Defaults to
None, in which case the global setting
`tf.keras.backend.image_data_format()` is used (unless you changed it,
it defaults to "channels_last").{mode}
data_format: Optional data format of the image tensor/array. `None` means
the global setting `tf.keras.backend.image_data_format()` is used
(unless you changed it, it uses "channels_last").{mode}.
Defaults to `None`.

Returns:
Unchanged `numpy.array` or `tf.Tensor`.
Expand Down
21 changes: 11 additions & 10 deletions keras/applications/resnet_rs.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,9 @@
`classifier_activation=None` to return the logits of the "top"
layer.
include_preprocessing: Boolean, whether to include the preprocessing
layer (`Rescaling`) at the bottom of the network. Defaults to
`True`. Note: Input image is normalized by ImageNet mean and
standard deviation.
layer (`Rescaling`) at the bottom of the network. Note: Input image
is normalized by ImageNet mean and standard deviation.
Defaults to `True`.

Returns:
A `keras.Model` instance.
Expand Down Expand Up @@ -582,9 +582,10 @@ def ResNetRS(
use on the "top" layer. Ignored unless `include_top=True`. Set
`classifier_activation=None` to return the logits of the "top" layer.
include_preprocessing: Boolean, whether to include the preprocessing
layer (`Rescaling`) at the bottom of the network. Defaults to `True`.
Note- Input image is normalized by ImageNet mean and standard
deviation.
layer (`Rescaling`) at the bottom of the network. Note - Input image
is normalized by ImageNet mean and standard deviation.
Defaults to `True`.


Returns:
A `tf.keras.Model` instance.
Expand Down Expand Up @@ -958,10 +959,10 @@ def preprocess_input(x, data_format=None):

Args:
x: A floating point `numpy.array` or a `tf.Tensor`.
data_format: Optional data format of the image tensor/array. Defaults to
None, in which case the global setting
`tf.keras.backend.image_data_format()` is used (unless you changed it,
it defaults to "channels_last").{mode}
data_format: Optional data format of the image tensor/array. `None` means
the global setting `tf.keras.backend.image_data_format()` is used
(unless you changed it, it uses "channels_last").{mode}.
Defaults to `None`.

Returns:
Unchanged `numpy.array` or `tf.Tensor`.
Expand Down
13 changes: 7 additions & 6 deletions keras/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -1901,8 +1901,8 @@ class RandomGenerator(tf.__internal__.tracking.AutoTrackable):
When `rng_type` is "legacy_stateful", the seed will be passed down to
stateful random ops.
rng_type: Type of RNG to use, one of "stateful", "stateless",
"legacy_stateful". It defaults to "stateful" if
`enable_tf_random_generator` has been activated, or to
"legacy_stateful". When `None` it uses "stateful" if
`enable_tf_random_generator` has been activated, or
"legacy_stateful" otherwise.
- When using "stateless", the random ops outputs are constant (the same
inputs result in the same outputs).
Expand All @@ -1913,6 +1913,7 @@ class RandomGenerator(tf.__internal__.tracking.AutoTrackable):
- "legacy_stateful" is backed by TF1 stateful RNG ops
(e.g. `tf.random.uniform`), while "stateful"
is backed by TF2 APIs (e.g. `tf.random.Generator.uniform`).
Defaults to `None`.
"""

RNG_STATELESS = "stateless"
Expand Down Expand Up @@ -6898,11 +6899,11 @@ def random_normal(shape, mean=0.0, stddev=1.0, dtype=None, seed=None):
Args:
shape: A tuple of integers, the shape of tensor to create.
mean: A float, the mean value of the normal distribution to draw
samples. Default to 0.0.
samples. Defaults to `0.0`.
stddev: A float, the standard deviation of the normal distribution
to draw samples. Default to 1.0.
dtype: `tf.dtypes.DType`, dtype of returned tensor. Default to use Keras
backend dtype which is float32.
to draw samples. Defaults to `1.0`.
dtype: `tf.dtypes.DType`, dtype of returned tensor. None uses Keras
backend dtype which is float32. Defaults to `None`.
seed: Integer, random seed. Will use a random numpy integer when not
specified.

Expand Down
Loading