Author: Yixing Fu
Date created: 2020/06/30
Last modified: 2023/07/10
Description: Use EfficientNet with weights pre-trained on imagenet for Stanford Dogs classification.
View in Colab β’ GitHub source
EfficientNet, first introduced in Tan and Le, 2019 is among the most efficient models (i.e. requiring least FLOPS for inference) that reaches State-of-the-Art accuracy on both imagenet and common image classification transfer learning tasks.
The smallest base model is similar to MnasNet, which reached near-SOTA with a significantly smaller model. By introducing a heuristic way to scale the model, EfficientNet provides a family of models (B0 to B7) that represents a good combination of efficiency and accuracy on a variety of scales. Such a scaling heuristics (compound-scaling, details see Tan and Le, 2019) allows the efficiency-oriented base model (B0) to surpass models at every scale, while avoiding extensive grid-search of hyperparameters.
A summary of the latest updates on the model is available at here, where various augmentation schemes and semi-supervised learning approaches are applied to further improve the imagenet performance of the models. These extensions of the model can be used by updating weights without changing model architecture.
(This section provides some details on "compound scaling", and can be skipped if you're only interested in using the models)
Based on the original paper people may have the impression that EfficientNet is a continuous family of models created by arbitrarily choosing scaling factor in as Eq.(3) of the paper. However, choice of resolution, depth and width are also restricted by many factors:
As a result, the depth, width and resolution of each variant of the EfficientNet models are hand-picked and proven to produce good results, though they may be significantly off from the compound scaling formula. Therefore, the keras implementation (detailed below) only provide these 8 models, B0 to B7, instead of allowing arbitray choice of width / depth / resolution parameters.
An implementation of EfficientNet B0 to B7 has been shipped with Keras since v2.3. To use EfficientNetB0 for classifying 1000 classes of images from ImageNet, run:
from tensorflow.keras.applications import EfficientNetB0
model = EfficientNetB0(weights='imagenet')
This model takes input images of shape (224, 224, 3)
, and the input data should be in the
range [0, 255]
. Normalization is included as part of the model.
Because training EfficientNet on ImageNet takes a tremendous amount of resources and several techniques that are not a part of the model architecture itself. Hence the Keras implementation by default loads pre-trained weights obtained via training with AutoAugment.
For B0 to B7 base models, the input shapes are different. Here is a list of input shape expected for each model:
Base model | resolution |
---|---|
EfficientNetB0 | 224 |
EfficientNetB1 | 240 |
EfficientNetB2 | 260 |
EfficientNetB3 | 300 |
EfficientNetB4 | 380 |
EfficientNetB5 | 456 |
EfficientNetB6 | 528 |
EfficientNetB7 | 600 |
When the model is intended for transfer learning, the Keras implementation provides a option to remove the top layers:
model = EfficientNetB0(include_top=False, weights='imagenet')
This option excludes the final Dense
layer that turns 1280 features on the penultimate
layer into prediction of the 1000 ImageNet classes. Replacing the top layer with custom
layers allows using EfficientNet as a feature extractor in a transfer learning workflow.
Another argument in the model constructor worth noticing is drop_connect_rate
which controls
the dropout rate responsible for stochastic depth.
This parameter serves as a toggle for extra regularization in finetuning, but does not
affect loaded weights. For example, when stronger regularization is desired, try:
model = EfficientNetB0(weights='imagenet', drop_connect_rate=0.4)
The default value is 0.2.
EfficientNet is capable of a wide range of image classification tasks. This makes it a good model for transfer learning. As an end-to-end example, we will show using pre-trained EfficientNetB0 on Stanford Dogs dataset.
import numpy as np
import tensorflow_datasets as tfds
import tensorflow as tf # For tf.data
import matplotlib.pyplot as plt
import keras
from keras import layers
from keras.applications import EfficientNetB0
# IMG_SIZE is determined by EfficientNet model choice
IMG_SIZE = 224
BATCH_SIZE = 64
Here we load data from tensorflow_datasets (hereafter TFDS). Stanford Dogs dataset is provided in TFDS as stanford_dogs. It features 20,580 images that belong to 120 classes of dog breeds (12,000 for training and 8,580 for testing).
By simply changing dataset_name
below, you may also try this notebook for
other datasets in TFDS such as
cifar10,
cifar100,
food101,
etc. When the images are much smaller than the size of EfficientNet input,
we can simply upsample the input images. It has been shown in
Tan and Le, 2019 that transfer learning
result is better for increased resolution even if input images remain small.
dataset_name = "stanford_dogs"
(ds_train, ds_test), ds_info = tfds.load(
dataset_name, split=["train", "test"], with_info=True, as_supervised=True
)
NUM_CLASSES = ds_info.features["label"].num_classes
When the dataset include images with various size, we need to resize them into a shared size. The Stanford Dogs dataset includes only images at least 200x200 pixels in size. Here we resize the images to the input size needed for EfficientNet.
size = (IMG_SIZE, IMG_SIZE)
ds_train = ds_train.map(lambda image, label: (tf.image.resize(image, size), label))
ds_test = ds_test.map(lambda image, label: (tf.image.resize(image, size), label))
The following code shows the first 9 images with their labels.
def format_label(label):
string_label = label_info.int2str(label)
return string_label.split("-")[1]
label_info = ds_info.features["label"]
for i, (image, label) in enumerate(ds_train.take(9)):
ax = plt.subplot(3, 3, i + 1)
plt.imshow(image.numpy().astype("uint8"))
plt.title("{}".format(format_label(label)))
plt.axis("off")
We can use the preprocessing layers APIs for image augmentation.
img_augmentation_layers = [
layers.RandomRotation(factor=0.15),
layers.RandomTranslation(height_factor=0.1, width_factor=0.1),
layers.RandomFlip(),
layers.RandomContrast(factor=0.1),
]
def img_augmentation(images):
for layer in img_augmentation_layers:
images = layer(images)
return images
This Sequential
model object can be used both as a part of
the model we later build, and as a function to preprocess
data before feeding into the model. Using them as function makes
it easy to visualize the augmented images. Here we plot 9 examples
of augmentation result of a given figure.
for image, label in ds_train.take(1):
for i in range(9):
ax = plt.subplot(3, 3, i + 1)
aug_img = img_augmentation(np.expand_dims(image.numpy(), axis=0))
aug_img = np.array(aug_img)
plt.imshow(aug_img[0].astype("uint8"))
plt.title("{}".format(format_label(label)))
plt.axis("off")
Once we verify the input data and augmentation are working correctly,
we prepare dataset for training. The input data are resized to uniform
IMG_SIZE
. The labels are put into one-hot
(a.k.a. categorical) encoding. The dataset is batched.
Note: prefetch
and AUTOTUNE
may in some situation improve
performance, but depends on environment and the specific dataset used.
See this guide
for more information on data pipeline performance.
# One-hot / categorical encoding
def input_preprocess_train(image, label):
image = img_augmentation(image)
label = tf.one_hot(label, NUM_CLASSES)
return image, label
def input_preprocess_test(image, label):
label = tf.one_hot(label, NUM_CLASSES)
return image, label
ds_train = ds_train.map(input_preprocess_train, num_parallel_calls=tf.data.AUTOTUNE)
ds_train = ds_train.batch(batch_size=BATCH_SIZE, drop_remainder=True)
ds_train = ds_train.prefetch(tf.data.AUTOTUNE)
ds_test = ds_test.map(input_preprocess_test, num_parallel_calls=tf.data.AUTOTUNE)
ds_test = ds_test.batch(batch_size=BATCH_SIZE, drop_remainder=True)
We build an EfficientNetB0 with 120 output classes, that is initialized from scratch:
Note: the accuracy will increase very slowly and may overfit.
model = EfficientNetB0(
include_top=True,
weights=None,
classes=NUM_CLASSES,
input_shape=(IMG_SIZE, IMG_SIZE, 3),
)
model.compile(optimizer="adam", loss="categorical_crossentropy", metrics=["accuracy"])
model.summary()
epochs = 40 # @param {type: "slider", min:10, max:100}
hist = model.fit(ds_train, epochs=epochs, validation_data=ds_test)
Model: "efficientnetb0"
βββββββββββββββββββββββ³ββββββββββββββββββββ³ββββββββββ³βββββββββββββββββββββββ β Layer (type) β Output Shape β Param # β Connected to β β‘βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ© β input_layer β (None, 224, 224, β 0 β - β β (InputLayer) β 3) β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β rescaling β (None, 224, 224, β 0 β input_layer[0][0] β β (Rescaling) β 3) β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β normalization β (None, 224, 224, β 7 β rescaling[0][0] β β (Normalization) β 3) β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β stem_conv_pad β (None, 225, 225, β 0 β normalization[0][0] β β (ZeroPadding2D) β 3) β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β stem_conv (Conv2D) β (None, 112, 112, β 864 β stem_conv_pad[0][0] β β β 32) β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β stem_bn β (None, 112, 112, β 128 β stem_conv[0][0] β β (BatchNormalizatioβ¦ β 32) β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β stem_activation β (None, 112, 112, β 0 β stem_bn[0][0] β β (Activation) β 32) β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block1a_dwconv β (None, 112, 112, β 288 β stem_activation[0][β¦ β β (DepthwiseConv2D) β 32) β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block1a_bn β (None, 112, 112, β 128 β block1a_dwconv[0][0] β β (BatchNormalizatioβ¦ β 32) β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block1a_activation β (None, 112, 112, β 0 β block1a_bn[0][0] β β (Activation) β 32) β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block1a_se_squeeze β (None, 32) β 0 β block1a_activation[β¦ β β (GlobalAveragePoolβ¦ β β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block1a_se_reshape β (None, 1, 1, 32) β 0 β block1a_se_squeeze[β¦ β β (Reshape) β β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block1a_se_reduce β (None, 1, 1, 8) β 264 β block1a_se_reshape[β¦ β β (Conv2D) β β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block1a_se_expand β (None, 1, 1, 32) β 288 β block1a_se_reduce[0β¦ β β (Conv2D) β β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block1a_se_excite β (None, 112, 112, β 0 β block1a_activation[β¦ β β (Multiply) β 32) β β block1a_se_expand[0β¦ β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block1a_project_coβ¦ β (None, 112, 112, β 512 β block1a_se_excite[0β¦ β β (Conv2D) β 16) β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block1a_project_bn β (None, 112, 112, β 64 β block1a_project_conβ¦ β β (BatchNormalizatioβ¦ β 16) β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block2a_expand_conv β (None, 112, 112, β 1,536 β block1a_project_bn[β¦ β β (Conv2D) β 96) β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block2a_expand_bn β (None, 112, 112, β 384 β block2a_expand_convβ¦ β β (BatchNormalizatioβ¦ β 96) β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block2a_expand_actβ¦ β (None, 112, 112, β 0 β block2a_expand_bn[0β¦ β β (Activation) β 96) β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block2a_dwconv_pad β (None, 113, 113, β 0 β block2a_expand_actiβ¦ β β (ZeroPadding2D) β 96) β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block2a_dwconv β (None, 56, 56, β 864 β block2a_dwconv_pad[β¦ β β (DepthwiseConv2D) β 96) β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block2a_bn β (None, 56, 56, β 384 β block2a_dwconv[0][0] β β (BatchNormalizatioβ¦ β 96) β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block2a_activation β (None, 56, 56, β 0 β block2a_bn[0][0] β β (Activation) β 96) β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block2a_se_squeeze β (None, 96) β 0 β block2a_activation[β¦ β β (GlobalAveragePoolβ¦ β β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block2a_se_reshape β (None, 1, 1, 96) β 0 β block2a_se_squeeze[β¦ β β (Reshape) β β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block2a_se_reduce β (None, 1, 1, 4) β 388 β block2a_se_reshape[β¦ β β (Conv2D) β β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block2a_se_expand β (None, 1, 1, 96) β 480 β block2a_se_reduce[0β¦ β β (Conv2D) β β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block2a_se_excite β (None, 56, 56, β 0 β block2a_activation[β¦ β β (Multiply) β 96) β β block2a_se_expand[0β¦ β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block2a_project_coβ¦ β (None, 56, 56, β 2,304 β block2a_se_excite[0β¦ β β (Conv2D) β 24) β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block2a_project_bn β (None, 56, 56, β 96 β block2a_project_conβ¦ β β (BatchNormalizatioβ¦ β 24) β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block2b_expand_conv β (None, 56, 56, β 3,456 β block2a_project_bn[β¦ β β (Conv2D) β 144) β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block2b_expand_bn β (None, 56, 56, β 576 β block2b_expand_convβ¦ β β (BatchNormalizatioβ¦ β 144) β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block2b_expand_actβ¦ β (None, 56, 56, β 0 β block2b_expand_bn[0β¦ β β (Activation) β 144) β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block2b_dwconv β (None, 56, 56, β 1,296 β block2b_expand_actiβ¦ β β (DepthwiseConv2D) β 144) β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block2b_bn β (None, 56, 56, β 576 β block2b_dwconv[0][0] β β (BatchNormalizatioβ¦ β 144) β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block2b_activation β (None, 56, 56, β 0 β block2b_bn[0][0] β β (Activation) β 144) β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block2b_se_squeeze β (None, 144) β 0 β block2b_activation[β¦ β β (GlobalAveragePoolβ¦ β β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block2b_se_reshape β (None, 1, 1, 144) β 0 β block2b_se_squeeze[β¦ β β (Reshape) β β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block2b_se_reduce β (None, 1, 1, 6) β 870 β block2b_se_reshape[β¦ β β (Conv2D) β β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block2b_se_expand β (None, 1, 1, 144) β 1,008 β block2b_se_reduce[0β¦ β β (Conv2D) β β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block2b_se_excite β (None, 56, 56, β 0 β block2b_activation[β¦ β β (Multiply) β 144) β β block2b_se_expand[0β¦ β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block2b_project_coβ¦ β (None, 56, 56, β 3,456 β block2b_se_excite[0β¦ β β (Conv2D) β 24) β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block2b_project_bn β (None, 56, 56, β 96 β block2b_project_conβ¦ β β (BatchNormalizatioβ¦ β 24) β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block2b_drop β (None, 56, 56, β 0 β block2b_project_bn[β¦ β β (Dropout) β 24) β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block2b_add (Add) β (None, 56, 56, β 0 β block2b_drop[0][0], β β β 24) β β block2a_project_bn[β¦ β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block3a_expand_conv β (None, 56, 56, β 3,456 β block2b_add[0][0] β β (Conv2D) β 144) β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block3a_expand_bn β (None, 56, 56, β 576 β block3a_expand_convβ¦ β β (BatchNormalizatioβ¦ β 144) β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block3a_expand_actβ¦ β (None, 56, 56, β 0 β block3a_expand_bn[0β¦ β β (Activation) β 144) β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block3a_dwconv_pad β (None, 59, 59, β 0 β block3a_expand_actiβ¦ β β (ZeroPadding2D) β 144) β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block3a_dwconv β (None, 28, 28, β 3,600 β block3a_dwconv_pad[β¦ β β (DepthwiseConv2D) β 144) β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block3a_bn β (None, 28, 28, β 576 β block3a_dwconv[0][0] β β (BatchNormalizatioβ¦ β 144) β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block3a_activation β (None, 28, 28, β 0 β block3a_bn[0][0] β β (Activation) β 144) β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block3a_se_squeeze β (None, 144) β 0 β block3a_activation[β¦ β β (GlobalAveragePoolβ¦ β β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block3a_se_reshape β (None, 1, 1, 144) β 0 β block3a_se_squeeze[β¦ β β (Reshape) β β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block3a_se_reduce β (None, 1, 1, 6) β 870 β block3a_se_reshape[β¦ β β (Conv2D) β β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block3a_se_expand β (None, 1, 1, 144) β 1,008 β block3a_se_reduce[0β¦ β β (Conv2D) β β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block3a_se_excite β (None, 28, 28, β 0 β block3a_activation[β¦ β β (Multiply) β 144) β β block3a_se_expand[0β¦ β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block3a_project_coβ¦ β (None, 28, 28, β 5,760 β block3a_se_excite[0β¦ β β (Conv2D) β 40) β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block3a_project_bn β (None, 28, 28, β 160 β block3a_project_conβ¦ β β (BatchNormalizatioβ¦ β 40) β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block3b_expand_conv β (None, 28, 28, β 9,600 β block3a_project_bn[β¦ β β (Conv2D) β 240) β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block3b_expand_bn β (None, 28, 28, β 960 β block3b_expand_convβ¦ β β (BatchNormalizatioβ¦ β 240) β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block3b_expand_actβ¦ β (None, 28, 28, β 0 β block3b_expand_bn[0β¦ β β (Activation) β 240) β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block3b_dwconv β (None, 28, 28, β 6,000 β block3b_expand_actiβ¦ β β (DepthwiseConv2D) β 240) β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block3b_bn β (None, 28, 28, β 960 β block3b_dwconv[0][0] β β (BatchNormalizatioβ¦ β 240) β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block3b_activation β (None, 28, 28, β 0 β block3b_bn[0][0] β β (Activation) β 240) β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block3b_se_squeeze β (None, 240) β 0 β block3b_activation[β¦ β β (GlobalAveragePoolβ¦ β β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block3b_se_reshape β (None, 1, 1, 240) β 0 β block3b_se_squeeze[β¦ β β (Reshape) β β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block3b_se_reduce β (None, 1, 1, 10) β 2,410 β block3b_se_reshape[β¦ β β (Conv2D) β β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block3b_se_expand β (None, 1, 1, 240) β 2,640 β block3b_se_reduce[0β¦ β β (Conv2D) β β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block3b_se_excite β (None, 28, 28, β 0 β block3b_activation[β¦ β β (Multiply) β 240) β β block3b_se_expand[0β¦ β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block3b_project_coβ¦ β (None, 28, 28, β 9,600 β block3b_se_excite[0β¦ β β (Conv2D) β 40) β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block3b_project_bn β (None, 28, 28, β 160 β block3b_project_conβ¦ β β (BatchNormalizatioβ¦ β 40) β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block3b_drop β (None, 28, 28, β 0 β block3b_project_bn[β¦ β β (Dropout) β 40) β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block3b_add (Add) β (None, 28, 28, β 0 β block3b_drop[0][0], β β β 40) β β block3a_project_bn[β¦ β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block4a_expand_conv β (None, 28, 28, β 9,600 β block3b_add[0][0] β β (Conv2D) β 240) β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block4a_expand_bn β (None, 28, 28, β 960 β block4a_expand_convβ¦ β β (BatchNormalizatioβ¦ β 240) β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block4a_expand_actβ¦ β (None, 28, 28, β 0 β block4a_expand_bn[0β¦ β β (Activation) β 240) β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block4a_dwconv_pad β (None, 29, 29, β 0 β block4a_expand_actiβ¦ β β (ZeroPadding2D) β 240) β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block4a_dwconv β (None, 14, 14, β 2,160 β block4a_dwconv_pad[β¦ β β (DepthwiseConv2D) β 240) β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block4a_bn β (None, 14, 14, β 960 β block4a_dwconv[0][0] β β (BatchNormalizatioβ¦ β 240) β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block4a_activation β (None, 14, 14, β 0 β block4a_bn[0][0] β β (Activation) β 240) β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block4a_se_squeeze β (None, 240) β 0 β block4a_activation[β¦ β β (GlobalAveragePoolβ¦ β β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block4a_se_reshape β (None, 1, 1, 240) β 0 β block4a_se_squeeze[β¦ β β (Reshape) β β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block4a_se_reduce β (None, 1, 1, 10) β 2,410 β block4a_se_reshape[β¦ β β (Conv2D) β β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block4a_se_expand β (None, 1, 1, 240) β 2,640 β block4a_se_reduce[0β¦ β β (Conv2D) β β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block4a_se_excite β (None, 14, 14, β 0 β block4a_activation[β¦ β β (Multiply) β 240) β β block4a_se_expand[0β¦ β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block4a_project_coβ¦ β (None, 14, 14, β 19,200 β block4a_se_excite[0β¦ β β (Conv2D) β 80) β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block4a_project_bn β (None, 14, 14, β 320 β block4a_project_conβ¦ β β (BatchNormalizatioβ¦ β 80) β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block4b_expand_conv β (None, 14, 14, β 38,400 β block4a_project_bn[β¦ β β (Conv2D) β 480) β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block4b_expand_bn β (None, 14, 14, β 1,920 β block4b_expand_convβ¦ β β (BatchNormalizatioβ¦ β 480) β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block4b_expand_actβ¦ β (None, 14, 14, β 0 β block4b_expand_bn[0β¦ β β (Activation) β 480) β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block4b_dwconv β (None, 14, 14, β 4,320 β block4b_expand_actiβ¦ β β (DepthwiseConv2D) β 480) β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block4b_bn β (None, 14, 14, β 1,920 β block4b_dwconv[0][0] β β (BatchNormalizatioβ¦ β 480) β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block4b_activation β (None, 14, 14, β 0 β block4b_bn[0][0] β β (Activation) β 480) β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block4b_se_squeeze β (None, 480) β 0 β block4b_activation[β¦ β β (GlobalAveragePoolβ¦ β β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block4b_se_reshape β (None, 1, 1, 480) β 0 β block4b_se_squeeze[β¦ β β (Reshape) β β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block4b_se_reduce β (None, 1, 1, 20) β 9,620 β block4b_se_reshape[β¦ β β (Conv2D) β β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block4b_se_expand β (None, 1, 1, 480) β 10,080 β block4b_se_reduce[0β¦ β β (Conv2D) β β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block4b_se_excite β (None, 14, 14, β 0 β block4b_activation[β¦ β β (Multiply) β 480) β β block4b_se_expand[0β¦ β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block4b_project_coβ¦ β (None, 14, 14, β 38,400 β block4b_se_excite[0β¦ β β (Conv2D) β 80) β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block4b_project_bn β (None, 14, 14, β 320 β block4b_project_conβ¦ β β (BatchNormalizatioβ¦ β 80) β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block4b_drop β (None, 14, 14, β 0 β block4b_project_bn[β¦ β β (Dropout) β 80) β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block4b_add (Add) β (None, 14, 14, β 0 β block4b_drop[0][0], β β β 80) β β block4a_project_bn[β¦ β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block4c_expand_conv β (None, 14, 14, β 38,400 β block4b_add[0][0] β β (Conv2D) β 480) β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block4c_expand_bn β (None, 14, 14, β 1,920 β block4c_expand_convβ¦ β β (BatchNormalizatioβ¦ β 480) β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block4c_expand_actβ¦ β (None, 14, 14, β 0 β block4c_expand_bn[0β¦ β β (Activation) β 480) β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block4c_dwconv β (None, 14, 14, β 4,320 β block4c_expand_actiβ¦ β β (DepthwiseConv2D) β 480) β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block4c_bn β (None, 14, 14, β 1,920 β block4c_dwconv[0][0] β β (BatchNormalizatioβ¦ β 480) β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block4c_activation β (None, 14, 14, β 0 β block4c_bn[0][0] β β (Activation) β 480) β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block4c_se_squeeze β (None, 480) β 0 β block4c_activation[β¦ β β (GlobalAveragePoolβ¦ β β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block4c_se_reshape β (None, 1, 1, 480) β 0 β block4c_se_squeeze[β¦ β β (Reshape) β β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block4c_se_reduce β (None, 1, 1, 20) β 9,620 β block4c_se_reshape[β¦ β β (Conv2D) β β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block4c_se_expand β (None, 1, 1, 480) β 10,080 β block4c_se_reduce[0β¦ β β (Conv2D) β β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block4c_se_excite β (None, 14, 14, β 0 β block4c_activation[β¦ β β (Multiply) β 480) β β block4c_se_expand[0β¦ β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block4c_project_coβ¦ β (None, 14, 14, β 38,400 β block4c_se_excite[0β¦ β β (Conv2D) β 80) β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block4c_project_bn β (None, 14, 14, β 320 β block4c_project_conβ¦ β β (BatchNormalizatioβ¦ β 80) β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block4c_drop β (None, 14, 14, β 0 β block4c_project_bn[β¦ β β (Dropout) β 80) β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block4c_add (Add) β (None, 14, 14, β 0 β block4c_drop[0][0], β β β 80) β β block4b_add[0][0] β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block5a_expand_conv β (None, 14, 14, β 38,400 β block4c_add[0][0] β β (Conv2D) β 480) β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block5a_expand_bn β (None, 14, 14, β 1,920 β block5a_expand_convβ¦ β β (BatchNormalizatioβ¦ β 480) β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block5a_expand_actβ¦ β (None, 14, 14, β 0 β block5a_expand_bn[0β¦ β β (Activation) β 480) β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block5a_dwconv β (None, 14, 14, β 12,000 β block5a_expand_actiβ¦ β β (DepthwiseConv2D) β 480) β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block5a_bn β (None, 14, 14, β 1,920 β block5a_dwconv[0][0] β β (BatchNormalizatioβ¦ β 480) β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block5a_activation β (None, 14, 14, β 0 β block5a_bn[0][0] β β (Activation) β 480) β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block5a_se_squeeze β (None, 480) β 0 β block5a_activation[β¦ β β (GlobalAveragePoolβ¦ β β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block5a_se_reshape β (None, 1, 1, 480) β 0 β block5a_se_squeeze[β¦ β β (Reshape) β β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block5a_se_reduce β (None, 1, 1, 20) β 9,620 β block5a_se_reshape[β¦ β β (Conv2D) β β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block5a_se_expand β (None, 1, 1, 480) β 10,080 β block5a_se_reduce[0β¦ β β (Conv2D) β β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block5a_se_excite β (None, 14, 14, β 0 β block5a_activation[β¦ β β (Multiply) β 480) β β block5a_se_expand[0β¦ β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block5a_project_coβ¦ β (None, 14, 14, β 53,760 β block5a_se_excite[0β¦ β β (Conv2D) β 112) β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block5a_project_bn β (None, 14, 14, β 448 β block5a_project_conβ¦ β β (BatchNormalizatioβ¦ β 112) β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block5b_expand_conv β (None, 14, 14, β 75,264 β block5a_project_bn[β¦ β β (Conv2D) β 672) β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block5b_expand_bn β (None, 14, 14, β 2,688 β block5b_expand_convβ¦ β β (BatchNormalizatioβ¦ β 672) β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block5b_expand_actβ¦ β (None, 14, 14, β 0 β block5b_expand_bn[0β¦ β β (Activation) β 672) β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block5b_dwconv β (None, 14, 14, β 16,800 β block5b_expand_actiβ¦ β β (DepthwiseConv2D) β 672) β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block5b_bn β (None, 14, 14, β 2,688 β block5b_dwconv[0][0] β β (BatchNormalizatioβ¦ β 672) β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block5b_activation β (None, 14, 14, β 0 β block5b_bn[0][0] β β (Activation) β 672) β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block5b_se_squeeze β (None, 672) β 0 β block5b_activation[β¦ β β (GlobalAveragePoolβ¦ β β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block5b_se_reshape β (None, 1, 1, 672) β 0 β block5b_se_squeeze[β¦ β β (Reshape) β β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block5b_se_reduce β (None, 1, 1, 28) β 18,844 β block5b_se_reshape[β¦ β β (Conv2D) β β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block5b_se_expand β (None, 1, 1, 672) β 19,488 β block5b_se_reduce[0β¦ β β (Conv2D) β β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block5b_se_excite β (None, 14, 14, β 0 β block5b_activation[β¦ β β (Multiply) β 672) β β block5b_se_expand[0β¦ β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block5b_project_coβ¦ β (None, 14, 14, β 75,264 β block5b_se_excite[0β¦ β β (Conv2D) β 112) β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block5b_project_bn β (None, 14, 14, β 448 β block5b_project_conβ¦ β β (BatchNormalizatioβ¦ β 112) β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block5b_drop β (None, 14, 14, β 0 β block5b_project_bn[β¦ β β (Dropout) β 112) β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block5b_add (Add) β (None, 14, 14, β 0 β block5b_drop[0][0], β β β 112) β β block5a_project_bn[β¦ β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block5c_expand_conv β (None, 14, 14, β 75,264 β block5b_add[0][0] β β (Conv2D) β 672) β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block5c_expand_bn β (None, 14, 14, β 2,688 β block5c_expand_convβ¦ β β (BatchNormalizatioβ¦ β 672) β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block5c_expand_actβ¦ β (None, 14, 14, β 0 β block5c_expand_bn[0β¦ β β (Activation) β 672) β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block5c_dwconv β (None, 14, 14, β 16,800 β block5c_expand_actiβ¦ β β (DepthwiseConv2D) β 672) β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block5c_bn β (None, 14, 14, β 2,688 β block5c_dwconv[0][0] β β (BatchNormalizatioβ¦ β 672) β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block5c_activation β (None, 14, 14, β 0 β block5c_bn[0][0] β β (Activation) β 672) β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block5c_se_squeeze β (None, 672) β 0 β block5c_activation[β¦ β β (GlobalAveragePoolβ¦ β β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block5c_se_reshape β (None, 1, 1, 672) β 0 β block5c_se_squeeze[β¦ β β (Reshape) β β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block5c_se_reduce β (None, 1, 1, 28) β 18,844 β block5c_se_reshape[β¦ β β (Conv2D) β β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block5c_se_expand β (None, 1, 1, 672) β 19,488 β block5c_se_reduce[0β¦ β β (Conv2D) β β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block5c_se_excite β (None, 14, 14, β 0 β block5c_activation[β¦ β β (Multiply) β 672) β β block5c_se_expand[0β¦ β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block5c_project_coβ¦ β (None, 14, 14, β 75,264 β block5c_se_excite[0β¦ β β (Conv2D) β 112) β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block5c_project_bn β (None, 14, 14, β 448 β block5c_project_conβ¦ β β (BatchNormalizatioβ¦ β 112) β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block5c_drop β (None, 14, 14, β 0 β block5c_project_bn[β¦ β β (Dropout) β 112) β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block5c_add (Add) β (None, 14, 14, β 0 β block5c_drop[0][0], β β β 112) β β block5b_add[0][0] β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block6a_expand_conv β (None, 14, 14, β 75,264 β block5c_add[0][0] β β (Conv2D) β 672) β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block6a_expand_bn β (None, 14, 14, β 2,688 β block6a_expand_convβ¦ β β (BatchNormalizatioβ¦ β 672) β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block6a_expand_actβ¦ β (None, 14, 14, β 0 β block6a_expand_bn[0β¦ β β (Activation) β 672) β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block6a_dwconv_pad β (None, 17, 17, β 0 β block6a_expand_actiβ¦ β β (ZeroPadding2D) β 672) β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block6a_dwconv β (None, 7, 7, 672) β 16,800 β block6a_dwconv_pad[β¦ β β (DepthwiseConv2D) β β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block6a_bn β (None, 7, 7, 672) β 2,688 β block6a_dwconv[0][0] β β (BatchNormalizatioβ¦ β β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block6a_activation β (None, 7, 7, 672) β 0 β block6a_bn[0][0] β β (Activation) β β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block6a_se_squeeze β (None, 672) β 0 β block6a_activation[β¦ β β (GlobalAveragePoolβ¦ β β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block6a_se_reshape β (None, 1, 1, 672) β 0 β block6a_se_squeeze[β¦ β β (Reshape) β β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block6a_se_reduce β (None, 1, 1, 28) β 18,844 β block6a_se_reshape[β¦ β β (Conv2D) β β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block6a_se_expand β (None, 1, 1, 672) β 19,488 β block6a_se_reduce[0β¦ β β (Conv2D) β β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block6a_se_excite β (None, 7, 7, 672) β 0 β block6a_activation[β¦ β β (Multiply) β β β block6a_se_expand[0β¦ β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block6a_project_coβ¦ β (None, 7, 7, 192) β 129,024 β block6a_se_excite[0β¦ β β (Conv2D) β β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block6a_project_bn β (None, 7, 7, 192) β 768 β block6a_project_conβ¦ β β (BatchNormalizatioβ¦ β β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block6b_expand_conv β (None, 7, 7, β 221,184 β block6a_project_bn[β¦ β β (Conv2D) β 1152) β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block6b_expand_bn β (None, 7, 7, β 4,608 β block6b_expand_convβ¦ β β (BatchNormalizatioβ¦ β 1152) β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block6b_expand_actβ¦ β (None, 7, 7, β 0 β block6b_expand_bn[0β¦ β β (Activation) β 1152) β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block6b_dwconv β (None, 7, 7, β 28,800 β block6b_expand_actiβ¦ β β (DepthwiseConv2D) β 1152) β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block6b_bn β (None, 7, 7, β 4,608 β block6b_dwconv[0][0] β β (BatchNormalizatioβ¦ β 1152) β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block6b_activation β (None, 7, 7, β 0 β block6b_bn[0][0] β β (Activation) β 1152) β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block6b_se_squeeze β (None, 1152) β 0 β block6b_activation[β¦ β β (GlobalAveragePoolβ¦ β β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block6b_se_reshape β (None, 1, 1, β 0 β block6b_se_squeeze[β¦ β β (Reshape) β 1152) β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block6b_se_reduce β (None, 1, 1, 48) β 55,344 β block6b_se_reshape[β¦ β β (Conv2D) β β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block6b_se_expand β (None, 1, 1, β 56,448 β block6b_se_reduce[0β¦ β β (Conv2D) β 1152) β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block6b_se_excite β (None, 7, 7, β 0 β block6b_activation[β¦ β β (Multiply) β 1152) β β block6b_se_expand[0β¦ β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block6b_project_coβ¦ β (None, 7, 7, 192) β 221,184 β block6b_se_excite[0β¦ β β (Conv2D) β β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block6b_project_bn β (None, 7, 7, 192) β 768 β block6b_project_conβ¦ β β (BatchNormalizatioβ¦ β β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block6b_drop β (None, 7, 7, 192) β 0 β block6b_project_bn[β¦ β β (Dropout) β β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block6b_add (Add) β (None, 7, 7, 192) β 0 β block6b_drop[0][0], β β β β β block6a_project_bn[β¦ β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block6c_expand_conv β (None, 7, 7, β 221,184 β block6b_add[0][0] β β (Conv2D) β 1152) β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block6c_expand_bn β (None, 7, 7, β 4,608 β block6c_expand_convβ¦ β β (BatchNormalizatioβ¦ β 1152) β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block6c_expand_actβ¦ β (None, 7, 7, β 0 β block6c_expand_bn[0β¦ β β (Activation) β 1152) β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block6c_dwconv β (None, 7, 7, β 28,800 β block6c_expand_actiβ¦ β β (DepthwiseConv2D) β 1152) β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block6c_bn β (None, 7, 7, β 4,608 β block6c_dwconv[0][0] β β (BatchNormalizatioβ¦ β 1152) β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block6c_activation β (None, 7, 7, β 0 β block6c_bn[0][0] β β (Activation) β 1152) β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block6c_se_squeeze β (None, 1152) β 0 β block6c_activation[β¦ β β (GlobalAveragePoolβ¦ β β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block6c_se_reshape β (None, 1, 1, β 0 β block6c_se_squeeze[β¦ β β (Reshape) β 1152) β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block6c_se_reduce β (None, 1, 1, 48) β 55,344 β block6c_se_reshape[β¦ β β (Conv2D) β β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block6c_se_expand β (None, 1, 1, β 56,448 β block6c_se_reduce[0β¦ β β (Conv2D) β 1152) β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block6c_se_excite β (None, 7, 7, β 0 β block6c_activation[β¦ β β (Multiply) β 1152) β β block6c_se_expand[0β¦ β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block6c_project_coβ¦ β (None, 7, 7, 192) β 221,184 β block6c_se_excite[0β¦ β β (Conv2D) β β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block6c_project_bn β (None, 7, 7, 192) β 768 β block6c_project_conβ¦ β β (BatchNormalizatioβ¦ β β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block6c_drop β (None, 7, 7, 192) β 0 β block6c_project_bn[β¦ β β (Dropout) β β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block6c_add (Add) β (None, 7, 7, 192) β 0 β block6c_drop[0][0], β β β β β block6b_add[0][0] β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block6d_expand_conv β (None, 7, 7, β 221,184 β block6c_add[0][0] β β (Conv2D) β 1152) β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block6d_expand_bn β (None, 7, 7, β 4,608 β block6d_expand_convβ¦ β β (BatchNormalizatioβ¦ β 1152) β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block6d_expand_actβ¦ β (None, 7, 7, β 0 β block6d_expand_bn[0β¦ β β (Activation) β 1152) β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block6d_dwconv β (None, 7, 7, β 28,800 β block6d_expand_actiβ¦ β β (DepthwiseConv2D) β 1152) β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block6d_bn β (None, 7, 7, β 4,608 β block6d_dwconv[0][0] β β (BatchNormalizatioβ¦ β 1152) β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block6d_activation β (None, 7, 7, β 0 β block6d_bn[0][0] β β (Activation) β 1152) β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block6d_se_squeeze β (None, 1152) β 0 β block6d_activation[β¦ β β (GlobalAveragePoolβ¦ β β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block6d_se_reshape β (None, 1, 1, β 0 β block6d_se_squeeze[β¦ β β (Reshape) β 1152) β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block6d_se_reduce β (None, 1, 1, 48) β 55,344 β block6d_se_reshape[β¦ β β (Conv2D) β β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block6d_se_expand β (None, 1, 1, β 56,448 β block6d_se_reduce[0β¦ β β (Conv2D) β 1152) β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block6d_se_excite β (None, 7, 7, β 0 β block6d_activation[β¦ β β (Multiply) β 1152) β β block6d_se_expand[0β¦ β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block6d_project_coβ¦ β (None, 7, 7, 192) β 221,184 β block6d_se_excite[0β¦ β β (Conv2D) β β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block6d_project_bn β (None, 7, 7, 192) β 768 β block6d_project_conβ¦ β β (BatchNormalizatioβ¦ β β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block6d_drop β (None, 7, 7, 192) β 0 β block6d_project_bn[β¦ β β (Dropout) β β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block6d_add (Add) β (None, 7, 7, 192) β 0 β block6d_drop[0][0], β β β β β block6c_add[0][0] β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block7a_expand_conv β (None, 7, 7, β 221,184 β block6d_add[0][0] β β (Conv2D) β 1152) β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block7a_expand_bn β (None, 7, 7, β 4,608 β block7a_expand_convβ¦ β β (BatchNormalizatioβ¦ β 1152) β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block7a_expand_actβ¦ β (None, 7, 7, β 0 β block7a_expand_bn[0β¦ β β (Activation) β 1152) β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block7a_dwconv β (None, 7, 7, β 10,368 β block7a_expand_actiβ¦ β β (DepthwiseConv2D) β 1152) β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block7a_bn β (None, 7, 7, β 4,608 β block7a_dwconv[0][0] β β (BatchNormalizatioβ¦ β 1152) β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block7a_activation β (None, 7, 7, β 0 β block7a_bn[0][0] β β (Activation) β 1152) β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block7a_se_squeeze β (None, 1152) β 0 β block7a_activation[β¦ β β (GlobalAveragePoolβ¦ β β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block7a_se_reshape β (None, 1, 1, β 0 β block7a_se_squeeze[β¦ β β (Reshape) β 1152) β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block7a_se_reduce β (None, 1, 1, 48) β 55,344 β block7a_se_reshape[β¦ β β (Conv2D) β β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block7a_se_expand β (None, 1, 1, β 56,448 β block7a_se_reduce[0β¦ β β (Conv2D) β 1152) β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block7a_se_excite β (None, 7, 7, β 0 β block7a_activation[β¦ β β (Multiply) β 1152) β β block7a_se_expand[0β¦ β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block7a_project_coβ¦ β (None, 7, 7, 320) β 368,640 β block7a_se_excite[0β¦ β β (Conv2D) β β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β block7a_project_bn β (None, 7, 7, 320) β 1,280 β block7a_project_conβ¦ β β (BatchNormalizatioβ¦ β β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β top_conv (Conv2D) β (None, 7, 7, β 409,600 β block7a_project_bn[β¦ β β β 1280) β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β top_bn β (None, 7, 7, β 5,120 β top_conv[0][0] β β (BatchNormalizatioβ¦ β 1280) β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β top_activation β (None, 7, 7, β 0 β top_bn[0][0] β β (Activation) β 1280) β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β avg_pool β (None, 1280) β 0 β top_activation[0][0] β β (GlobalAveragePoolβ¦ β β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β top_dropout β (None, 1280) β 0 β avg_pool[0][0] β β (Dropout) β β β β βββββββββββββββββββββββΌββββββββββββββββββββΌββββββββββΌβββββββββββββββββββββββ€ β predictions (Dense) β (None, 120) β 153,720 β top_dropout[0][0] β βββββββββββββββββββββββ΄ββββββββββββββββββββ΄ββββββββββ΄βββββββββββββββββββββββ
Total params: 4,203,291 (16.03 MB)
Trainable params: 4,161,268 (15.87 MB)
Non-trainable params: 42,023 (164.16 KB)
Epoch 1/40
1/187 [37mββββββββββββββββββββ 5:30:13 107s/step - accuracy: 0.0000e+00 - loss: 5.1065
WARNING: All log messages before absl::InitializeLog() is called are written to STDERR
I0000 00:00:1700241724.682725 1549299 device_compiler.h:187] Compiled cluster using XLA! This line is logged at most once for the lifetime of the process.
187/187 ββββββββββββββββββββ 200s 501ms/step - accuracy: 0.0097 - loss: 5.0567 - val_accuracy: 0.0100 - val_loss: 4.9278
Epoch 2/40
187/187 ββββββββββββββββββββ 95s 507ms/step - accuracy: 0.0214 - loss: 4.6918 - val_accuracy: 0.0141 - val_loss: 5.5380
Epoch 3/40
187/187 ββββββββββββββββββββ 89s 474ms/step - accuracy: 0.0298 - loss: 4.4749 - val_accuracy: 0.0375 - val_loss: 4.4576
Epoch 4/40
187/187 ββββββββββββββββββββ 90s 479ms/step - accuracy: 0.0423 - loss: 4.3206 - val_accuracy: 0.0391 - val_loss: 4.9898
Epoch 5/40
187/187 ββββββββββββββββββββ 89s 473ms/step - accuracy: 0.0458 - loss: 4.2312 - val_accuracy: 0.0416 - val_loss: 4.3210
Epoch 6/40
187/187 ββββββββββββββββββββ 141s 470ms/step - accuracy: 0.0579 - loss: 4.1162 - val_accuracy: 0.0540 - val_loss: 4.3371
Epoch 7/40
187/187 ββββββββββββββββββββ 89s 476ms/step - accuracy: 0.0679 - loss: 4.0150 - val_accuracy: 0.0786 - val_loss: 3.9759
Epoch 8/40
187/187 ββββββββββββββββββββ 89s 477ms/step - accuracy: 0.0828 - loss: 3.9147 - val_accuracy: 0.0651 - val_loss: 4.1641
Epoch 9/40
187/187 ββββββββββββββββββββ 142s 475ms/step - accuracy: 0.0932 - loss: 3.8297 - val_accuracy: 0.0928 - val_loss: 3.8985
Epoch 10/40
187/187 ββββββββββββββββββββ 88s 472ms/step - accuracy: 0.1092 - loss: 3.7321 - val_accuracy: 0.0946 - val_loss: 3.8618
Epoch 11/40
187/187 ββββββββββββββββββββ 89s 476ms/step - accuracy: 0.1245 - loss: 3.6451 - val_accuracy: 0.0880 - val_loss: 3.9584
Epoch 12/40
187/187 ββββββββββββββββββββ 92s 493ms/step - accuracy: 0.1457 - loss: 3.5514 - val_accuracy: 0.1096 - val_loss: 3.8184
Epoch 13/40
187/187 ββββββββββββββββββββ 88s 471ms/step - accuracy: 0.1606 - loss: 3.4654 - val_accuracy: 0.1118 - val_loss: 3.8059
Epoch 14/40
187/187 ββββββββββββββββββββ 87s 464ms/step - accuracy: 0.1660 - loss: 3.3826 - val_accuracy: 0.1472 - val_loss: 3.5726
Epoch 15/40
187/187 ββββββββββββββββββββ 146s 485ms/step - accuracy: 0.1815 - loss: 3.2935 - val_accuracy: 0.1154 - val_loss: 3.8134
Epoch 16/40
187/187 ββββββββββββββββββββ 87s 466ms/step - accuracy: 0.1942 - loss: 3.2218 - val_accuracy: 0.1540 - val_loss: 3.5051
Epoch 17/40
187/187 ββββββββββββββββββββ 88s 471ms/step - accuracy: 0.2131 - loss: 3.1427 - val_accuracy: 0.1381 - val_loss: 3.7206
Epoch 18/40
187/187 ββββββββββββββββββββ 87s 467ms/step - accuracy: 0.2264 - loss: 3.0461 - val_accuracy: 0.1707 - val_loss: 3.4122
Epoch 19/40
187/187 ββββββββββββββββββββ 88s 470ms/step - accuracy: 0.2401 - loss: 2.9821 - val_accuracy: 0.1515 - val_loss: 3.6481
Epoch 20/40
187/187 ββββββββββββββββββββ 88s 469ms/step - accuracy: 0.2613 - loss: 2.8815 - val_accuracy: 0.1783 - val_loss: 3.4767
Epoch 21/40
187/187 ββββββββββββββββββββ 91s 485ms/step - accuracy: 0.2741 - loss: 2.8102 - val_accuracy: 0.1927 - val_loss: 3.3183
Epoch 22/40
187/187 ββββββββββββββββββββ 90s 477ms/step - accuracy: 0.2892 - loss: 2.7408 - val_accuracy: 0.1859 - val_loss: 3.4887
Epoch 23/40
187/187 ββββββββββββββββββββ 91s 485ms/step - accuracy: 0.3093 - loss: 2.6526 - val_accuracy: 0.1924 - val_loss: 3.4622
Epoch 24/40
187/187 ββββββββββββββββββββ 92s 491ms/step - accuracy: 0.3201 - loss: 2.5750 - val_accuracy: 0.2253 - val_loss: 3.1873
Epoch 25/40
187/187 ββββββββββββββββββββ 95s 508ms/step - accuracy: 0.3280 - loss: 2.5150 - val_accuracy: 0.2148 - val_loss: 3.3391
Epoch 26/40
187/187 ββββββββββββββββββββ 92s 490ms/step - accuracy: 0.3465 - loss: 2.4402 - val_accuracy: 0.2270 - val_loss: 3.2679
Epoch 27/40
187/187 ββββββββββββββββββββ 93s 494ms/step - accuracy: 0.3735 - loss: 2.3199 - val_accuracy: 0.2080 - val_loss: 3.5687
Epoch 28/40
187/187 ββββββββββββββββββββ 89s 476ms/step - accuracy: 0.3837 - loss: 2.2645 - val_accuracy: 0.2374 - val_loss: 3.3592
Epoch 29/40
187/187 ββββββββββββββββββββ 142s 474ms/step - accuracy: 0.3962 - loss: 2.2110 - val_accuracy: 0.2008 - val_loss: 3.6071
Epoch 30/40
187/187 ββββββββββββββββββββ 87s 466ms/step - accuracy: 0.4175 - loss: 2.1086 - val_accuracy: 0.2302 - val_loss: 3.4161
Epoch 31/40
187/187 ββββββββββββββββββββ 87s 465ms/step - accuracy: 0.4359 - loss: 2.0610 - val_accuracy: 0.2231 - val_loss: 3.5957
Epoch 32/40
187/187 ββββββββββββββββββββ 148s 498ms/step - accuracy: 0.4463 - loss: 1.9866 - val_accuracy: 0.2234 - val_loss: 3.7263
Epoch 33/40
187/187 ββββββββββββββββββββ 92s 489ms/step - accuracy: 0.4613 - loss: 1.8821 - val_accuracy: 0.2239 - val_loss: 3.6929
Epoch 34/40
187/187 ββββββββββββββββββββ 139s 475ms/step - accuracy: 0.4925 - loss: 1.7858 - val_accuracy: 0.2238 - val_loss: 3.8351
Epoch 35/40
187/187 ββββββββββββββββββββ 91s 485ms/step - accuracy: 0.5105 - loss: 1.7074 - val_accuracy: 0.1930 - val_loss: 4.1941
Epoch 36/40
187/187 ββββββββββββββββββββ 140s 474ms/step - accuracy: 0.5334 - loss: 1.6256 - val_accuracy: 0.2098 - val_loss: 4.1464
Epoch 37/40
187/187 ββββββββββββββββββββ 87s 464ms/step - accuracy: 0.5504 - loss: 1.5603 - val_accuracy: 0.2306 - val_loss: 4.0215
Epoch 38/40
187/187 ββββββββββββββββββββ 90s 480ms/step - accuracy: 0.5736 - loss: 1.4419 - val_accuracy: 0.2240 - val_loss: 4.1604
Epoch 39/40
187/187 ββββββββββββββββββββ 91s 486ms/step - accuracy: 0.6025 - loss: 1.3612 - val_accuracy: 0.2344 - val_loss: 4.0505
Epoch 40/40
187/187 ββββββββββββββββββββ 89s 474ms/step - accuracy: 0.6199 - loss: 1.2889 - val_accuracy: 0.2151 - val_loss: 4.3660
Training the model is relatively fast. This might make it sounds easy to simply train EfficientNet on any dataset wanted from scratch. However, training EfficientNet on smaller datasets, especially those with lower resolution like CIFAR-100, faces the significant challenge of overfitting.
Hence training from scratch requires very careful choice of hyperparameters and is difficult to find suitable regularization. It would also be much more demanding in resources. Plotting the training and validation accuracy makes it clear that validation accuracy stagnates at a low value.
import matplotlib.pyplot as plt
def plot_hist(hist):
plt.plot(hist.history["accuracy"])
plt.plot(hist.history["val_accuracy"])
plt.title("model accuracy")
plt.ylabel("accuracy")
plt.xlabel("epoch")
plt.legend(["train", "validation"], loc="upper left")
plt.show()
plot_hist(hist)
Here we initialize the model with pre-trained ImageNet weights, and we fine-tune it on our own dataset.
def build_model(num_classes):
inputs = layers.Input(shape=(IMG_SIZE, IMG_SIZE, 3))
model = EfficientNetB0(include_top=False, input_tensor=inputs, weights="imagenet")
# Freeze the pretrained weights
model.trainable = False
# Rebuild top
x = layers.GlobalAveragePooling2D(name="avg_pool")(model.output)
x = layers.BatchNormalization()(x)
top_dropout_rate = 0.2
x = layers.Dropout(top_dropout_rate, name="top_dropout")(x)
outputs = layers.Dense(num_classes, activation="softmax", name="pred")(x)
# Compile
model = keras.Model(inputs, outputs, name="EfficientNet")
optimizer = keras.optimizers.Adam(learning_rate=1e-2)
model.compile(
optimizer=optimizer, loss="categorical_crossentropy", metrics=["accuracy"]
)
return model
The first step to transfer learning is to freeze all layers and train only the top layers. For this step, a relatively large learning rate (1e-2) can be used. Note that validation accuracy and loss will usually be better than training accuracy and loss. This is because the regularization is strong, which only suppresses training-time metrics.
Note that the convergence may take up to 50 epochs depending on choice of learning rate. If image augmentation layers were not applied, the validation accuracy may only reach ~60%.
model = build_model(num_classes=NUM_CLASSES)
epochs = 25 # @param {type: "slider", min:8, max:80}
hist = model.fit(ds_train, epochs=epochs, validation_data=ds_test)
plot_hist(hist)
Epoch 1/25
187/187 ββββββββββββββββββββ 108s 432ms/step - accuracy: 0.2654 - loss: 4.3710 - val_accuracy: 0.6888 - val_loss: 1.0875
Epoch 2/25
187/187 ββββββββββββββββββββ 119s 412ms/step - accuracy: 0.4863 - loss: 2.0996 - val_accuracy: 0.7282 - val_loss: 0.9072
Epoch 3/25
187/187 ββββββββββββββββββββ 78s 416ms/step - accuracy: 0.5422 - loss: 1.7120 - val_accuracy: 0.7411 - val_loss: 0.8574
Epoch 4/25
187/187 ββββββββββββββββββββ 77s 412ms/step - accuracy: 0.5509 - loss: 1.6472 - val_accuracy: 0.7451 - val_loss: 0.8457
Epoch 5/25
187/187 ββββββββββββββββββββ 81s 431ms/step - accuracy: 0.5744 - loss: 1.5373 - val_accuracy: 0.7424 - val_loss: 0.8649
Epoch 6/25
187/187 ββββββββββββββββββββ 78s 417ms/step - accuracy: 0.5715 - loss: 1.5595 - val_accuracy: 0.7374 - val_loss: 0.8736
Epoch 7/25
187/187 ββββββββββββββββββββ 81s 432ms/step - accuracy: 0.5802 - loss: 1.5045 - val_accuracy: 0.7430 - val_loss: 0.8675
Epoch 8/25
187/187 ββββββββββββββββββββ 77s 411ms/step - accuracy: 0.5839 - loss: 1.4972 - val_accuracy: 0.7392 - val_loss: 0.8647
Epoch 9/25
187/187 ββββββββββββββββββββ 77s 411ms/step - accuracy: 0.5929 - loss: 1.4699 - val_accuracy: 0.7508 - val_loss: 0.8634
Epoch 10/25
187/187 ββββββββββββββββββββ 82s 437ms/step - accuracy: 0.6040 - loss: 1.4442 - val_accuracy: 0.7520 - val_loss: 0.8480
Epoch 11/25
187/187 ββββββββββββββββββββ 78s 416ms/step - accuracy: 0.5972 - loss: 1.4626 - val_accuracy: 0.7379 - val_loss: 0.8879
Epoch 12/25
187/187 ββββββββββββββββββββ 79s 421ms/step - accuracy: 0.5965 - loss: 1.4700 - val_accuracy: 0.7383 - val_loss: 0.9409
Epoch 13/25
187/187 ββββββββββββββββββββ 82s 420ms/step - accuracy: 0.6034 - loss: 1.4533 - val_accuracy: 0.7474 - val_loss: 0.8922
Epoch 14/25
187/187 ββββββββββββββββββββ 81s 435ms/step - accuracy: 0.6053 - loss: 1.4170 - val_accuracy: 0.7416 - val_loss: 0.9119
Epoch 15/25
187/187 ββββββββββββββββββββ 77s 411ms/step - accuracy: 0.6059 - loss: 1.4125 - val_accuracy: 0.7406 - val_loss: 0.9205
Epoch 16/25
187/187 ββββββββββββββββββββ 82s 438ms/step - accuracy: 0.5979 - loss: 1.4554 - val_accuracy: 0.7392 - val_loss: 0.9120
Epoch 17/25
187/187 ββββββββββββββββββββ 77s 411ms/step - accuracy: 0.6081 - loss: 1.4089 - val_accuracy: 0.7423 - val_loss: 0.9305
Epoch 18/25
187/187 ββββββββββββββββββββ 82s 436ms/step - accuracy: 0.6041 - loss: 1.4390 - val_accuracy: 0.7380 - val_loss: 0.9644
Epoch 19/25
187/187 ββββββββββββββββββββ 79s 417ms/step - accuracy: 0.6018 - loss: 1.4324 - val_accuracy: 0.7439 - val_loss: 0.9129
Epoch 20/25
187/187 ββββββββββββββββββββ 81s 430ms/step - accuracy: 0.6057 - loss: 1.4342 - val_accuracy: 0.7305 - val_loss: 0.9463
Epoch 21/25
187/187 ββββββββββββββββββββ 77s 410ms/step - accuracy: 0.6209 - loss: 1.3824 - val_accuracy: 0.7410 - val_loss: 0.9503
Epoch 22/25
187/187 ββββββββββββββββββββ 78s 419ms/step - accuracy: 0.6170 - loss: 1.4246 - val_accuracy: 0.7336 - val_loss: 0.9606
Epoch 23/25
187/187 ββββββββββββββββββββ 85s 455ms/step - accuracy: 0.6153 - loss: 1.4009 - val_accuracy: 0.7334 - val_loss: 0.9520
Epoch 24/25
187/187 ββββββββββββββββββββ 82s 438ms/step - accuracy: 0.6051 - loss: 1.4343 - val_accuracy: 0.7435 - val_loss: 0.9403
Epoch 25/25
187/187 ββββββββββββββββββββ 138s 416ms/step - accuracy: 0.6065 - loss: 1.4131 - val_accuracy: 0.7456 - val_loss: 0.9307
The second step is to unfreeze a number of layers and fit the model using smaller learning rate. In this example we show unfreezing all layers, but depending on specific dataset it may be desireble to only unfreeze a fraction of all layers.
When the feature extraction with pretrained model works good enough, this step would give a very limited gain on validation accuracy. In our case we only see a small improvement, as ImageNet pretraining already exposed the model to a good amount of dogs.
On the other hand, when we use pretrained weights on a dataset that is more different
from ImageNet, this fine-tuning step can be crucial as the feature extractor also
needs to be adjusted by a considerable amount. Such a situation can be demonstrated
if choosing CIFAR-100 dataset instead, where fine-tuning boosts validation accuracy
by about 10% to pass 80% on EfficientNetB0
.
A side note on freezing/unfreezing models: setting trainable
of a Model
will
simultaneously set all layers belonging to the Model
to the same trainable
attribute. Each layer is trainable only if both the layer itself and the model
containing it are trainable. Hence when we need to partially freeze/unfreeze
a model, we need to make sure the trainable
attribute of the model is set
to True
.
def unfreeze_model(model):
# We unfreeze the top 20 layers while leaving BatchNorm layers frozen
for layer in model.layers[-20:]:
if not isinstance(layer, layers.BatchNormalization):
layer.trainable = True
optimizer = keras.optimizers.Adam(learning_rate=1e-5)
model.compile(
optimizer=optimizer, loss="categorical_crossentropy", metrics=["accuracy"]
)
unfreeze_model(model)
epochs = 4 # @param {type: "slider", min:4, max:10}
hist = model.fit(ds_train, epochs=epochs, validation_data=ds_test)
plot_hist(hist)
Epoch 1/4
187/187 ββββββββββββββββββββ 111s 442ms/step - accuracy: 0.6310 - loss: 1.3425 - val_accuracy: 0.7565 - val_loss: 0.8874
Epoch 2/4
187/187 ββββββββββββββββββββ 77s 413ms/step - accuracy: 0.6518 - loss: 1.2755 - val_accuracy: 0.7635 - val_loss: 0.8588
Epoch 3/4
187/187 ββββββββββββββββββββ 82s 437ms/step - accuracy: 0.6491 - loss: 1.2426 - val_accuracy: 0.7663 - val_loss: 0.8419
Epoch 4/4
187/187 ββββββββββββββββββββ 79s 419ms/step - accuracy: 0.6625 - loss: 1.1775 - val_accuracy: 0.7701 - val_loss: 0.8284
On unfreezing layers:
BatchNormalization
layers need to be kept frozen
(more details).
If they are also turned to trainable, the
first epoch after unfreezing will significantly reduce accuracy.Some other tips for utilizing EfficientNet: