Module keras.api.keras.applications.efficientnet
Public API for tf.keras.applications.efficientnet namespace.
Expand source code
# This file is MACHINE GENERATED! Do not edit.
# Generated by: tensorflow/python/tools/api/generator/create_python_api.py script.
"""Public API for tf.keras.applications.efficientnet namespace.
"""
from __future__ import print_function as _print_function
import sys as _sys
from keras.applications.efficientnet import EfficientNetB0
from keras.applications.efficientnet import EfficientNetB1
from keras.applications.efficientnet import EfficientNetB2
from keras.applications.efficientnet import EfficientNetB3
from keras.applications.efficientnet import EfficientNetB4
from keras.applications.efficientnet import EfficientNetB5
from keras.applications.efficientnet import EfficientNetB6
from keras.applications.efficientnet import EfficientNetB7
from keras.applications.efficientnet import decode_predictions
from keras.applications.efficientnet import preprocess_input
del _print_function
from tensorflow.python.util import module_wrapper as _module_wrapper
if not isinstance(_sys.modules[__name__], _module_wrapper.TFModuleWrapper):
_sys.modules[__name__] = _module_wrapper.TFModuleWrapper(
_sys.modules[__name__], "keras.applications.efficientnet", public_apis=None, deprecation=True,
has_lite=False)
Functions
def EfficientNetB0(include_top=True, weights='imagenet', input_tensor=None, input_shape=None, pooling=None, classes=1000, classifier_activation='softmax', **kwargs)
-
Instantiates the EfficientNetB0 architecture.
Reference: - EfficientNet: Rethinking Model Scaling for Convolutional Neural Networks (ICML 2019)
This function returns a Keras image classification model, optionally loaded with weights pre-trained on ImageNet.
For image classification use cases, see this page for detailed examples.
For transfer learning use cases, make sure to read the guide to transfer learning & fine-tuning.
Note: each Keras Application expects a specific kind of input preprocessing. For EfficientNet, input preprocessing is included as part of the model (as a
Rescaling
layer), and thustf.keras.applications.efficientnet.preprocess_input
is actually a pass-through function. EfficientNet models expect their inputs to be float tensors of pixels with values in the [0-255] range.Args
include_top
- Whether to include the fully-connected 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'. input_tensor
- Optional Keras tensor
(i.e. output of
layers.Input()
) to use as image input for the model. input_shape
- Optional shape tuple, only to be specified
if
include_top
is False. It should have exactly 3 inputs channels. pooling
- Optional pooling mode for feature extraction
when
include_top
isFalse
. Defaults to None. -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 will be applied to the output of the last convolutional layer, and thus the output of the model will be a 2D tensor. -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 noweights
argument is specified. Defaults to 1000 (number of ImageNet classes). classifier_activation
- A
str
or callable. The activation function to use on the "top" layer. Ignored unlessinclude_top=True
. Setclassifier_activation=None
to return the logits of the "top" layer. Defaults to 'softmax'. When loading pretrained weights,classifier_activation
can only beNone
or"softmax"
.
Returns
A
keras.Model
instance.Expand source code
@keras_export('keras.applications.efficientnet.EfficientNetB0', 'keras.applications.EfficientNetB0') def EfficientNetB0(include_top=True, weights='imagenet', input_tensor=None, input_shape=None, pooling=None, classes=1000, classifier_activation='softmax', **kwargs): return EfficientNet( 1.0, 1.0, 224, 0.2, model_name='efficientnetb0', include_top=include_top, weights=weights, input_tensor=input_tensor, input_shape=input_shape, pooling=pooling, classes=classes, classifier_activation=classifier_activation, **kwargs)
def EfficientNetB1(include_top=True, weights='imagenet', input_tensor=None, input_shape=None, pooling=None, classes=1000, classifier_activation='softmax', **kwargs)
-
Instantiates the EfficientNetB1 architecture.
Reference: - EfficientNet: Rethinking Model Scaling for Convolutional Neural Networks (ICML 2019)
This function returns a Keras image classification model, optionally loaded with weights pre-trained on ImageNet.
For image classification use cases, see this page for detailed examples.
For transfer learning use cases, make sure to read the guide to transfer learning & fine-tuning.
Note: each Keras Application expects a specific kind of input preprocessing. For EfficientNet, input preprocessing is included as part of the model (as a
Rescaling
layer), and thustf.keras.applications.efficientnet.preprocess_input
is actually a pass-through function. EfficientNet models expect their inputs to be float tensors of pixels with values in the [0-255] range.Args
include_top
- Whether to include the fully-connected 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'. input_tensor
- Optional Keras tensor
(i.e. output of
layers.Input()
) to use as image input for the model. input_shape
- Optional shape tuple, only to be specified
if
include_top
is False. It should have exactly 3 inputs channels. pooling
- Optional pooling mode for feature extraction
when
include_top
isFalse
. Defaults to None. -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 will be applied to the output of the last convolutional layer, and thus the output of the model will be a 2D tensor. -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 noweights
argument is specified. Defaults to 1000 (number of ImageNet classes). classifier_activation
- A
str
or callable. The activation function to use on the "top" layer. Ignored unlessinclude_top=True
. Setclassifier_activation=None
to return the logits of the "top" layer. Defaults to 'softmax'. When loading pretrained weights,classifier_activation
can only beNone
or"softmax"
.
Returns
A
keras.Model
instance.Expand source code
@keras_export('keras.applications.efficientnet.EfficientNetB1', 'keras.applications.EfficientNetB1') def EfficientNetB1(include_top=True, weights='imagenet', input_tensor=None, input_shape=None, pooling=None, classes=1000, classifier_activation='softmax', **kwargs): return EfficientNet( 1.0, 1.1, 240, 0.2, model_name='efficientnetb1', include_top=include_top, weights=weights, input_tensor=input_tensor, input_shape=input_shape, pooling=pooling, classes=classes, classifier_activation=classifier_activation, **kwargs)
def EfficientNetB2(include_top=True, weights='imagenet', input_tensor=None, input_shape=None, pooling=None, classes=1000, classifier_activation='softmax', **kwargs)
-
Instantiates the EfficientNetB2 architecture.
Reference: - EfficientNet: Rethinking Model Scaling for Convolutional Neural Networks (ICML 2019)
This function returns a Keras image classification model, optionally loaded with weights pre-trained on ImageNet.
For image classification use cases, see this page for detailed examples.
For transfer learning use cases, make sure to read the guide to transfer learning & fine-tuning.
Note: each Keras Application expects a specific kind of input preprocessing. For EfficientNet, input preprocessing is included as part of the model (as a
Rescaling
layer), and thustf.keras.applications.efficientnet.preprocess_input
is actually a pass-through function. EfficientNet models expect their inputs to be float tensors of pixels with values in the [0-255] range.Args
include_top
- Whether to include the fully-connected 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'. input_tensor
- Optional Keras tensor
(i.e. output of
layers.Input()
) to use as image input for the model. input_shape
- Optional shape tuple, only to be specified
if
include_top
is False. It should have exactly 3 inputs channels. pooling
- Optional pooling mode for feature extraction
when
include_top
isFalse
. Defaults to None. -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 will be applied to the output of the last convolutional layer, and thus the output of the model will be a 2D tensor. -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 noweights
argument is specified. Defaults to 1000 (number of ImageNet classes). classifier_activation
- A
str
or callable. The activation function to use on the "top" layer. Ignored unlessinclude_top=True
. Setclassifier_activation=None
to return the logits of the "top" layer. Defaults to 'softmax'. When loading pretrained weights,classifier_activation
can only beNone
or"softmax"
.
Returns
A
keras.Model
instance.Expand source code
@keras_export('keras.applications.efficientnet.EfficientNetB2', 'keras.applications.EfficientNetB2') def EfficientNetB2(include_top=True, weights='imagenet', input_tensor=None, input_shape=None, pooling=None, classes=1000, classifier_activation='softmax', **kwargs): return EfficientNet( 1.1, 1.2, 260, 0.3, model_name='efficientnetb2', include_top=include_top, weights=weights, input_tensor=input_tensor, input_shape=input_shape, pooling=pooling, classes=classes, classifier_activation=classifier_activation, **kwargs)
def EfficientNetB3(include_top=True, weights='imagenet', input_tensor=None, input_shape=None, pooling=None, classes=1000, classifier_activation='softmax', **kwargs)
-
Instantiates the EfficientNetB3 architecture.
Reference: - EfficientNet: Rethinking Model Scaling for Convolutional Neural Networks (ICML 2019)
This function returns a Keras image classification model, optionally loaded with weights pre-trained on ImageNet.
For image classification use cases, see this page for detailed examples.
For transfer learning use cases, make sure to read the guide to transfer learning & fine-tuning.
Note: each Keras Application expects a specific kind of input preprocessing. For EfficientNet, input preprocessing is included as part of the model (as a
Rescaling
layer), and thustf.keras.applications.efficientnet.preprocess_input
is actually a pass-through function. EfficientNet models expect their inputs to be float tensors of pixels with values in the [0-255] range.Args
include_top
- Whether to include the fully-connected 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'. input_tensor
- Optional Keras tensor
(i.e. output of
layers.Input()
) to use as image input for the model. input_shape
- Optional shape tuple, only to be specified
if
include_top
is False. It should have exactly 3 inputs channels. pooling
- Optional pooling mode for feature extraction
when
include_top
isFalse
. Defaults to None. -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 will be applied to the output of the last convolutional layer, and thus the output of the model will be a 2D tensor. -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 noweights
argument is specified. Defaults to 1000 (number of ImageNet classes). classifier_activation
- A
str
or callable. The activation function to use on the "top" layer. Ignored unlessinclude_top=True
. Setclassifier_activation=None
to return the logits of the "top" layer. Defaults to 'softmax'. When loading pretrained weights,classifier_activation
can only beNone
or"softmax"
.
Returns
A
keras.Model
instance.Expand source code
@keras_export('keras.applications.efficientnet.EfficientNetB3', 'keras.applications.EfficientNetB3') def EfficientNetB3(include_top=True, weights='imagenet', input_tensor=None, input_shape=None, pooling=None, classes=1000, classifier_activation='softmax', **kwargs): return EfficientNet( 1.2, 1.4, 300, 0.3, model_name='efficientnetb3', include_top=include_top, weights=weights, input_tensor=input_tensor, input_shape=input_shape, pooling=pooling, classes=classes, classifier_activation=classifier_activation, **kwargs)
def EfficientNetB4(include_top=True, weights='imagenet', input_tensor=None, input_shape=None, pooling=None, classes=1000, classifier_activation='softmax', **kwargs)
-
Instantiates the EfficientNetB4 architecture.
Reference: - EfficientNet: Rethinking Model Scaling for Convolutional Neural Networks (ICML 2019)
This function returns a Keras image classification model, optionally loaded with weights pre-trained on ImageNet.
For image classification use cases, see this page for detailed examples.
For transfer learning use cases, make sure to read the guide to transfer learning & fine-tuning.
Note: each Keras Application expects a specific kind of input preprocessing. For EfficientNet, input preprocessing is included as part of the model (as a
Rescaling
layer), and thustf.keras.applications.efficientnet.preprocess_input
is actually a pass-through function. EfficientNet models expect their inputs to be float tensors of pixels with values in the [0-255] range.Args
include_top
- Whether to include the fully-connected 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'. input_tensor
- Optional Keras tensor
(i.e. output of
layers.Input()
) to use as image input for the model. input_shape
- Optional shape tuple, only to be specified
if
include_top
is False. It should have exactly 3 inputs channels. pooling
- Optional pooling mode for feature extraction
when
include_top
isFalse
. Defaults to None. -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 will be applied to the output of the last convolutional layer, and thus the output of the model will be a 2D tensor. -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 noweights
argument is specified. Defaults to 1000 (number of ImageNet classes). classifier_activation
- A
str
or callable. The activation function to use on the "top" layer. Ignored unlessinclude_top=True
. Setclassifier_activation=None
to return the logits of the "top" layer. Defaults to 'softmax'. When loading pretrained weights,classifier_activation
can only beNone
or"softmax"
.
Returns
A
keras.Model
instance.Expand source code
@keras_export('keras.applications.efficientnet.EfficientNetB4', 'keras.applications.EfficientNetB4') def EfficientNetB4(include_top=True, weights='imagenet', input_tensor=None, input_shape=None, pooling=None, classes=1000, classifier_activation='softmax', **kwargs): return EfficientNet( 1.4, 1.8, 380, 0.4, model_name='efficientnetb4', include_top=include_top, weights=weights, input_tensor=input_tensor, input_shape=input_shape, pooling=pooling, classes=classes, classifier_activation=classifier_activation, **kwargs)
def EfficientNetB5(include_top=True, weights='imagenet', input_tensor=None, input_shape=None, pooling=None, classes=1000, classifier_activation='softmax', **kwargs)
-
Instantiates the EfficientNetB5 architecture.
Reference: - EfficientNet: Rethinking Model Scaling for Convolutional Neural Networks (ICML 2019)
This function returns a Keras image classification model, optionally loaded with weights pre-trained on ImageNet.
For image classification use cases, see this page for detailed examples.
For transfer learning use cases, make sure to read the guide to transfer learning & fine-tuning.
Note: each Keras Application expects a specific kind of input preprocessing. For EfficientNet, input preprocessing is included as part of the model (as a
Rescaling
layer), and thustf.keras.applications.efficientnet.preprocess_input
is actually a pass-through function. EfficientNet models expect their inputs to be float tensors of pixels with values in the [0-255] range.Args
include_top
- Whether to include the fully-connected 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'. input_tensor
- Optional Keras tensor
(i.e. output of
layers.Input()
) to use as image input for the model. input_shape
- Optional shape tuple, only to be specified
if
include_top
is False. It should have exactly 3 inputs channels. pooling
- Optional pooling mode for feature extraction
when
include_top
isFalse
. Defaults to None. -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 will be applied to the output of the last convolutional layer, and thus the output of the model will be a 2D tensor. -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 noweights
argument is specified. Defaults to 1000 (number of ImageNet classes). classifier_activation
- A
str
or callable. The activation function to use on the "top" layer. Ignored unlessinclude_top=True
. Setclassifier_activation=None
to return the logits of the "top" layer. Defaults to 'softmax'. When loading pretrained weights,classifier_activation
can only beNone
or"softmax"
.
Returns
A
keras.Model
instance.Expand source code
@keras_export('keras.applications.efficientnet.EfficientNetB5', 'keras.applications.EfficientNetB5') def EfficientNetB5(include_top=True, weights='imagenet', input_tensor=None, input_shape=None, pooling=None, classes=1000, classifier_activation='softmax', **kwargs): return EfficientNet( 1.6, 2.2, 456, 0.4, model_name='efficientnetb5', include_top=include_top, weights=weights, input_tensor=input_tensor, input_shape=input_shape, pooling=pooling, classes=classes, classifier_activation=classifier_activation, **kwargs)
def EfficientNetB6(include_top=True, weights='imagenet', input_tensor=None, input_shape=None, pooling=None, classes=1000, classifier_activation='softmax', **kwargs)
-
Instantiates the EfficientNetB6 architecture.
Reference: - EfficientNet: Rethinking Model Scaling for Convolutional Neural Networks (ICML 2019)
This function returns a Keras image classification model, optionally loaded with weights pre-trained on ImageNet.
For image classification use cases, see this page for detailed examples.
For transfer learning use cases, make sure to read the guide to transfer learning & fine-tuning.
Note: each Keras Application expects a specific kind of input preprocessing. For EfficientNet, input preprocessing is included as part of the model (as a
Rescaling
layer), and thustf.keras.applications.efficientnet.preprocess_input
is actually a pass-through function. EfficientNet models expect their inputs to be float tensors of pixels with values in the [0-255] range.Args
include_top
- Whether to include the fully-connected 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'. input_tensor
- Optional Keras tensor
(i.e. output of
layers.Input()
) to use as image input for the model. input_shape
- Optional shape tuple, only to be specified
if
include_top
is False. It should have exactly 3 inputs channels. pooling
- Optional pooling mode for feature extraction
when
include_top
isFalse
. Defaults to None. -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 will be applied to the output of the last convolutional layer, and thus the output of the model will be a 2D tensor. -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 noweights
argument is specified. Defaults to 1000 (number of ImageNet classes). classifier_activation
- A
str
or callable. The activation function to use on the "top" layer. Ignored unlessinclude_top=True
. Setclassifier_activation=None
to return the logits of the "top" layer. Defaults to 'softmax'. When loading pretrained weights,classifier_activation
can only beNone
or"softmax"
.
Returns
A
keras.Model
instance.Expand source code
@keras_export('keras.applications.efficientnet.EfficientNetB6', 'keras.applications.EfficientNetB6') def EfficientNetB6(include_top=True, weights='imagenet', input_tensor=None, input_shape=None, pooling=None, classes=1000, classifier_activation='softmax', **kwargs): return EfficientNet( 1.8, 2.6, 528, 0.5, model_name='efficientnetb6', include_top=include_top, weights=weights, input_tensor=input_tensor, input_shape=input_shape, pooling=pooling, classes=classes, classifier_activation=classifier_activation, **kwargs)
def EfficientNetB7(include_top=True, weights='imagenet', input_tensor=None, input_shape=None, pooling=None, classes=1000, classifier_activation='softmax', **kwargs)
-
Instantiates the EfficientNetB7 architecture.
Reference: - EfficientNet: Rethinking Model Scaling for Convolutional Neural Networks (ICML 2019)
This function returns a Keras image classification model, optionally loaded with weights pre-trained on ImageNet.
For image classification use cases, see this page for detailed examples.
For transfer learning use cases, make sure to read the guide to transfer learning & fine-tuning.
Note: each Keras Application expects a specific kind of input preprocessing. For EfficientNet, input preprocessing is included as part of the model (as a
Rescaling
layer), and thustf.keras.applications.efficientnet.preprocess_input
is actually a pass-through function. EfficientNet models expect their inputs to be float tensors of pixels with values in the [0-255] range.Args
include_top
- Whether to include the fully-connected 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'. input_tensor
- Optional Keras tensor
(i.e. output of
layers.Input()
) to use as image input for the model. input_shape
- Optional shape tuple, only to be specified
if
include_top
is False. It should have exactly 3 inputs channels. pooling
- Optional pooling mode for feature extraction
when
include_top
isFalse
. Defaults to None. -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 will be applied to the output of the last convolutional layer, and thus the output of the model will be a 2D tensor. -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 noweights
argument is specified. Defaults to 1000 (number of ImageNet classes). classifier_activation
- A
str
or callable. The activation function to use on the "top" layer. Ignored unlessinclude_top=True
. Setclassifier_activation=None
to return the logits of the "top" layer. Defaults to 'softmax'. When loading pretrained weights,classifier_activation
can only beNone
or"softmax"
.
Returns
A
keras.Model
instance.Expand source code
@keras_export('keras.applications.efficientnet.EfficientNetB7', 'keras.applications.EfficientNetB7') def EfficientNetB7(include_top=True, weights='imagenet', input_tensor=None, input_shape=None, pooling=None, classes=1000, classifier_activation='softmax', **kwargs): return EfficientNet( 2.0, 3.1, 600, 0.5, model_name='efficientnetb7', include_top=include_top, weights=weights, input_tensor=input_tensor, input_shape=input_shape, pooling=pooling, classes=classes, classifier_activation=classifier_activation, **kwargs)
def decode_predictions(preds, top=5)
-
Decodes the prediction of an ImageNet model.
Args
preds
- Numpy array encoding a batch of predictions.
top
- Integer, how many top-guesses to return. Defaults to 5.
Returns
A list of lists of top class prediction tuples
(class_name, class_description, score)
. One list of tuples per sample in batch input.Raises
ValueError
- In case of invalid shape of the
pred
array (must be 2D).
Expand source code
@keras_export('keras.applications.efficientnet.decode_predictions') def decode_predictions(preds, top=5): return imagenet_utils.decode_predictions(preds, top=top)
def preprocess_input(x, data_format=None)
-
A placeholder method for backward compatibility.
The preprocessing logic has been included in the efficientnet model implementation. Users are no longer required to call this method to normalize the input data. This method does nothing and only kept as a placeholder to align the API surface between old and new version of model.
Args
x
- A floating point
numpy.array
or atf.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}
Returns
Unchanged
numpy.array
ortf.Tensor
.Expand source code
@keras_export('keras.applications.efficientnet.preprocess_input') def preprocess_input(x, data_format=None): # pylint: disable=unused-argument """A placeholder method for backward compatibility. The preprocessing logic has been included in the efficientnet model implementation. Users are no longer required to call this method to normalize the input data. This method does nothing and only kept as a placeholder to align the API surface between old and new version of model. 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} Returns: Unchanged `numpy.array` or `tf.Tensor`. """ return x