Pretrained image classification
Classify images using the standard ImageNet setup.
Keras · Class
EfficientNetB0 creates the B0 EfficientNet image-classification model, optionally using ImageNet-pretrained weights. Its options support standard classification, custom inputs, and feature extraction without the top classifier.
EfficientNetB0 constructs the B0 EfficientNet image-classification architecture and returns it as a Keras model. By default it includes the classifier and loads ImageNet weights; you can instead omit the top layer for feature extraction, choose a custom input shape, and select pooling for the resulting features.
keras.applications.EfficientNetB0(include_top=True, weights="imagenet", input_tensor=None, input_shape=None, pooling=None, classes=1000, classifier_activation="softmax", name="efficientnetb0")| Name | Type | Description |
|---|---|---|
include_top | boolean | Whether to include the fully-connected layer at the top of the network. Defaults to true. |
weights | string | null | None for random initialization, "imagenet" for pretrained weights, or a weights-file path. Defaults to "imagenet". |
input_tensor | KerasTensor | null | Optional Keras tensor to use as image input. |
input_shape | tuple | null | Optional three-channel shape; only specify it when include_top is false. |
pooling | string | null | Optional pooling mode for the feature output when include_top is false. |
classes | integer | Number of classes for the classifier. Defaults to 1000. |
classifier_activation | string | null | Activation for the classifier. Defaults to "softmax". |
name | string | Model name. Defaults to "efficientnetb0". |
A model instance.
from keras.applications import EfficientNetB0
model = EfficientNetB0(weights="imagenet")
print(model.output_shape)Creates the ImageNet-pretrained classifier using the default 1,000-class output and prints its output shape.
Classify images using the standard ImageNet setup.
Reuse convolutional representations in a downstream model.
Replace the original classifier with a task-specific output layer.
Initialize a model without pretrained parameters.
EfficientNetB0 is instantiated with keras.applications.EfficientNetB0 and returns a Keras image-classification model. Its default configuration includes the top classifier and uses ImageNet-pretrained weights.
Follow-up: How would you adapt it for feature extraction? Set include_top=False, provide a compatible input shape if needed, and choose pooling such as average pooling to obtain feature vectors.
include_top controls whether the fully connected classifier is present. When it is false, input_shape may be specified and must have exactly three channels.
Follow-up: Why remove the top? It lets the backbone produce representations that can feed a task-specific classifier rather than forcing the original ImageNet classifier.
weights can be None, "imagenet", or a path to a weights file. The default is "imagenet", so the model can start from pretrained parameters rather than random initialization.
Follow-up: When would None be appropriate? Use it when training from scratch or when pretrained weights are unsuitable for the target domain.
EfficientNetB1EfficientNetB2EfficientNetB3EfficientNetB4EfficientNetB5EfficientNetB6EfficientNetB7keras.applications.efficientnet.decode_predictions