From f4445f1135a6c2366587895d65efeff78b53b214 Mon Sep 17 00:00:00 2001 From: Samuel Marks <807580+SamuelMarks@users.noreply.github.com> Date: Wed, 12 Apr 2023 20:36:18 -0400 Subject: [PATCH] [keras/applications/convnext.py,keras/applications/efficientnet.py,keras/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" --- keras/applications/convnext.py | 20 ++++++++++---------- keras/applications/efficientnet.py | 16 ++++++++-------- keras/applications/efficientnet_v2.py | 19 ++++++++++--------- keras/applications/imagenet_utils.py | 11 ++++++----- keras/applications/inception_v3.py | 8 ++++---- keras/applications/mobilenet.py | 17 +++++++++-------- keras/applications/mobilenet_v3.py | 8 ++++---- keras/applications/regnet.py | 20 ++++++++++---------- keras/applications/resnet_rs.py | 21 +++++++++++---------- 9 files changed, 72 insertions(+), 68 deletions(-) diff --git a/keras/applications/convnext.py b/keras/applications/convnext.py index 8304d776e5d7..7e5e209bf200 100644 --- a/keras/applications/convnext.py +++ b/keras/applications/convnext.py @@ -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"`. @@ -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 @@ -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. @@ -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`. diff --git a/keras/applications/efficientnet.py b/keras/applications/efficientnet.py index 619499e671ac..cbadfad14d35 100644 --- a/keras/applications/efficientnet.py +++ b/keras/applications/efficientnet.py @@ -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'. @@ -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. @@ -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. @@ -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`. diff --git a/keras/applications/efficientnet_v2.py b/keras/applications/efficientnet_v2.py index 910ba4602a07..715c8f5281ab 100644 --- a/keras/applications/efficientnet_v2.py +++ b/keras/applications/efficientnet_v2.py @@ -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"`. @@ -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. @@ -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. @@ -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`. diff --git a/keras/applications/imagenet_utils.py b/keras/applications/imagenet_utils.py index cc58b47c7628..3aafbad0a174 100644 --- a/keras/applications/imagenet_utils.py +++ b/keras/applications/imagenet_utils.py @@ -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`. @@ -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, @@ -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 = """ diff --git a/keras/applications/inception_v3.py b/keras/applications/inception_v3.py index 4433325538d5..d3ab844e16a9 100644 --- a/keras/applications/inception_v3.py +++ b/keras/applications/inception_v3.py @@ -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) @@ -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. diff --git a/keras/applications/mobilenet.py b/keras/applications/mobilenet.py index 5e4daa174ec3..e3a0cdd09e18 100644 --- a/keras/applications/mobilenet.py +++ b/keras/applications/mobilenet.py @@ -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 @@ -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. diff --git a/keras/applications/mobilenet_v3.py b/keras/applications/mobilenet_v3.py index ac61c9970e16..b79c4a663678 100644 --- a/keras/applications/mobilenet_v3.py +++ b/keras/applications/mobilenet_v3.py @@ -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`. diff --git a/keras/applications/regnet.py b/keras/applications/regnet.py index b12956e514a7..f40c548a196a 100644 --- a/keras/applications/regnet.py +++ b/keras/applications/regnet.py @@ -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"`. @@ -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. @@ -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. @@ -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`. diff --git a/keras/applications/resnet_rs.py b/keras/applications/resnet_rs.py index 2aad806b0940..8a72652c2370 100644 --- a/keras/applications/resnet_rs.py +++ b/keras/applications/resnet_rs.py @@ -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. @@ -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. @@ -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`.