Skip to content

Commit

Permalink
[keras/applications/convnext.py,keras/applications/efficientnet.py,ke…
Browse files Browse the repository at this point in the history
…ras/applications/efficientnet_v2.py,keras/applications/imagenet_utils.py,keras/applications/inception_v3.py,keras/applications/mobilenet.py,keras/applications/mobilenet_v3.py,keras/applications/regnet.py,keras/applications/resnet_rs.py] Standardise docstring usage of "Default to"
  • Loading branch information
SamuelMarks committed Apr 13, 2023
1 parent 0f8e81f commit f4445f1
Show file tree
Hide file tree
Showing 9 changed files with 72 additions and 68 deletions.
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").
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

0 comments on commit f4445f1

Please sign in to comment.