Symulowanie-wizualne/sw_lab9-10_1.ipynb

236 KiB

Aleksandra Jonas, Aleksandra Gronowska, Iwona Christop

Zadanie 9-10, zadanie 1 - VGG16 + ResNet on train_test_sw

Przygotowanie danych

from IPython.display import Image, display
import sys
import subprocess
import pkg_resources
import numpy as np

required = { 'scikit-image'}
installed = {pkg.key for pkg in pkg_resources.working_set}
missing = required - installed
# VGG16 requires images to be of dim = (224, 224, 3)
newSize = (224,224)

if missing: 
    python = sys.executable
    subprocess.check_call([python, '-m', 'pip', 'install', *missing], stdout=subprocess.DEVNULL)

def load_train_data(input_dir):
    import numpy as np
    import pandas as pd
    import os
    from skimage.io import imread
    import cv2 as cv
    from pathlib import Path
    import random
    from shutil import copyfile, rmtree
    import json

    import seaborn as sns
    import matplotlib.pyplot as plt

    import matplotlib
    
    image_dir = Path(input_dir)
    categories_name = []
    for file in os.listdir(image_dir):
        d = os.path.join(image_dir, file)
        if os.path.isdir(d):
            categories_name.append(file)

    folders = [directory for directory in image_dir.iterdir() if directory.is_dir()]

    train_img = []
    categories_count=[]
    labels=[]
    for i, direc in enumerate(folders):
        count = 0
        for obj in direc.iterdir():
            if os.path.isfile(obj) and os.path.basename(os.path.normpath(obj)) != 'desktop.ini':
                labels.append(os.path.basename(os.path.normpath(direc)))
                count += 1
                img = imread(obj)#zwraca ndarry postaci xSize x ySize x colorDepth
                img = img[:, :, :3]
                img = cv.resize(img, newSize, interpolation=cv.INTER_AREA)# zwraca ndarray
                img = img / 255 #normalizacja
                train_img.append(img)
        categories_count.append(count)
    X={}
    X["values"] = np.array(train_img)
    X["categories_name"] = categories_name
    X["categories_count"] = categories_count
    X["labels"]=labels
    return X

def load_test_data(input_dir):
    import numpy as np
    import pandas as pd
    import os
    from skimage.io import imread
    import cv2 as cv
    from pathlib import Path
    import random
    from shutil import copyfile, rmtree
    import json

    import seaborn as sns
    import matplotlib.pyplot as plt

    import matplotlib

    image_path = Path(input_dir)

    labels_path = image_path.parents[0] / 'test_labels.json'

    jsonString = labels_path.read_text()
    objects = json.loads(jsonString)

    categories_name = []
    categories_count=[]
    count = 0
    c = objects[0]['value']
    for e in  objects:
        if e['value'] != c:
            categories_count.append(count)
            c = e['value']
            count = 1
        else:
            count += 1
        if not e['value'] in categories_name:
            categories_name.append(e['value'])

    categories_count.append(count)
    
    test_img = []

    labels=[]
    for e in objects:
        p = image_path / e['filename']
        img = imread(p)#zwraca ndarry postaci xSize x ySize x colorDepth
        img = img[:, :, :3]
        img = cv.resize(img, newSize, interpolation=cv.INTER_AREA)# zwraca ndarray
        img = img / 255#normalizacja
        test_img.append(img)
        labels.append(e['value'])

    X={}
    X["values"] = np.array(test_img)
    X["categories_name"] = categories_name
    X["categories_count"] = categories_count
    X["labels"]=labels
    return X
def create_tf_ds(X_train, y_train_enc, X_validate, y_validate_enc, X_test, y_test_enc):
    import tensorflow as tf
    
    train_ds = tf.data.Dataset.from_tensor_slices((X_train, y_train_enc))
    validation_ds = tf.data.Dataset.from_tensor_slices((X_validate, y_validate_enc))
    test_ds = tf.data.Dataset.from_tensor_slices((X_test, y_test_enc))

    train_ds_size = tf.data.experimental.cardinality(train_ds).numpy()
    test_ds_size = tf.data.experimental.cardinality(test_ds).numpy()
    validation_ds_size = tf.data.experimental.cardinality(validation_ds).numpy()

    print("Training data size:", train_ds_size)
    print("Test data size:", test_ds_size)
    print("Validation data size:", validation_ds_size)

    train_ds = (train_ds
                  .shuffle(buffer_size=train_ds_size)
                  .batch(batch_size=32, drop_remainder=True))
    test_ds = (test_ds
                    .shuffle(buffer_size=train_ds_size)
                    .batch(batch_size=32, drop_remainder=True))
    validation_ds = (validation_ds
                    .shuffle(buffer_size=train_ds_size)
                    .batch(batch_size=32, drop_remainder=True))
    
    return train_ds, test_ds, validation_ds
def get_run_logdir(root_logdir):
    import os
    import time

    run_id = time.strftime("run_%Y_%m_%d-%H_%M_%S")
    return os.path.join(root_logdir, run_id)
def diagram_setup(model_name):
    from tensorflow import keras
    import os
    
    root_logdir = os.path.join(os.curdir, f"logs\\\\fit\\\\\{model_name}\\\\")
    
    run_logdir = get_run_logdir(root_logdir)
    tensorboard_cb = keras.callbacks.TensorBoard(run_logdir)
# Data load
data_train = load_train_data("./train_test_sw/train_sw")
values_train = data_train['values']
labels_train = data_train['labels']

data_test = load_test_data("./train_test_sw/test_sw")
X_test = data_test['values']
y_test = data_test['labels']
from sklearn.model_selection import train_test_split
X_train, X_validate, y_train, y_validate = train_test_split(values_train, labels_train, test_size=0.2, random_state=42)
from sklearn.preprocessing import LabelEncoder
class_le = LabelEncoder()
y_train_enc = class_le.fit_transform(y_train)
y_validate_enc = class_le.fit_transform(y_validate)
y_test_enc = class_le.fit_transform(y_test)
train_ds, test_ds, validation_ds = create_tf_ds(X_train, y_train_enc, X_validate, y_validate_enc, X_test, y_test_enc)
Training data size: 821
Test data size: 259
Validation data size: 206

VGG16

diagram_setup('vgg_sw')
import keras,os
from keras.models import Sequential
from keras.layers import Dense, Conv2D, MaxPool2D , Flatten
from keras.preprocessing.image import ImageDataGenerator
import numpy as np
from keras.applications import VGG16
from keras.layers import Input, Lambda, Dense, Flatten
from keras.models import Model
from keras.preprocessing import image
from keras.preprocessing.image import ImageDataGenerator
from keras.models import Sequential
import numpy as np
from glob import glob
import matplotlib.pyplot as plt
import ssl
ssl._create_default_https_context = ssl._create_unverified_context

# model = keras.models.Sequential([
#     keras.layers.Conv2D(filters=64, kernel_size=(3,3), activation='relu', input_shape=(224,224,3), padding="same"),
#     keras.layers.Conv2D(filters=64, kernel_size=(3,3), activation='relu', input_shape=(224,224,3), padding="same"),
#     keras.layers.MaxPool2D(pool_size=(2,2), strides=(2,2)),
#     keras.layers.Conv2D(filters=128, kernel_size=(3,3), padding="same", activation="relu"),
#     keras.layers.Conv2D(filters=128, kernel_size=(3,3), padding="same", activation="relu"),
#     keras.layers.MaxPool2D(pool_size=(2,2), strides=(2,2)),
#     keras.layers.Conv2D(filters=256, kernel_size=(3,3), padding="same", activation="relu"),
#     keras.layers.Conv2D(filters=256, kernel_size=(3,3), padding="same", activation="relu"),
#     keras.layers.Conv2D(filters=256, kernel_size=(3,3), padding="same", activation="relu"),
#     keras.layers.MaxPool2D(pool_size=(2,2), strides=(2,2)),
#     keras.layers.Conv2D(filters=512, kernel_size=(3,3), padding="same", activation="relu"),
#     keras.layers.Conv2D(filters=512, kernel_size=(3,3), padding="same", activation="relu"),
#     keras.layers.Conv2D(filters=512, kernel_size=(3,3), padding="same", activation="relu"),
#     keras.layers.MaxPool2D(pool_size=(2,2), strides=(2,2)),
#     keras.layers.Conv2D(filters=512, kernel_size=(3,3), padding="same", activation="relu"),
#     keras.layers.Conv2D(filters=512, kernel_size=(3,3), padding="same", activation="relu"),
#     keras.layers.Conv2D(filters=512, kernel_size=(3,3), padding="same", activation="relu"),
#     keras.layers.Flatten(),
#     keras.layers.Dense(units = 4096, activation='relu'),
#     keras.layers.Dense(units = 4096, activation='relu'),
#     keras.layers.Dense(units = 5, activation='softmax')
# ])

# re-size all the images to this
IMAGE_SIZE = [224, 224]

# add preprocessing layer to the front of resnet
vgg2 = VGG16(input_shape=IMAGE_SIZE + [3], weights='imagenet', include_top=False)

# don't train existing weights
for layer in vgg2.layers:
  layer.trainable = False
  
  # useful for getting number of classes
classes = 5
  

# our layers - you can add more if you want
x = Flatten()(vgg2.output)
# x = Dense(1000, activation='relu')(x)
prediction = Dense(5, activation='softmax')(x)

# create a model object
model = Model(inputs=vgg2.input, outputs=prediction)

# view the structure of the model
model.summary()
# tell the model what cost and optimization method to use
model.compile(
  loss='sparse_categorical_crossentropy',
  optimizer='adam',
  metrics=['accuracy']
)

#train_ds_vgg_sw, test_ds_vgg_sw, validation_ds_vgg_sw
# fit the model
vggr = model.fit_generator(
  train_ds,
  validation_data=validation_ds,
  epochs=25,
  steps_per_epoch=len(train_ds),
  validation_steps=len(validation_ds)
)
Model: "model_3"
_________________________________________________________________
 Layer (type)                Output Shape              Param #   
=================================================================
 input_4 (InputLayer)        [(None, 224, 224, 3)]     0         
                                                                 
 block1_conv1 (Conv2D)       (None, 224, 224, 64)      1792      
                                                                 
 block1_conv2 (Conv2D)       (None, 224, 224, 64)      36928     
                                                                 
 block1_pool (MaxPooling2D)  (None, 112, 112, 64)      0         
                                                                 
 block2_conv1 (Conv2D)       (None, 112, 112, 128)     73856     
                                                                 
 block2_conv2 (Conv2D)       (None, 112, 112, 128)     147584    
                                                                 
 block2_pool (MaxPooling2D)  (None, 56, 56, 128)       0         
                                                                 
 block3_conv1 (Conv2D)       (None, 56, 56, 256)       295168    
                                                                 
 block3_conv2 (Conv2D)       (None, 56, 56, 256)       590080    
                                                                 
 block3_conv3 (Conv2D)       (None, 56, 56, 256)       590080    
                                                                 
 block3_pool (MaxPooling2D)  (None, 28, 28, 256)       0         
                                                                 
 block4_conv1 (Conv2D)       (None, 28, 28, 512)       1180160   
                                                                 
 block4_conv2 (Conv2D)       (None, 28, 28, 512)       2359808   
                                                                 
 block4_conv3 (Conv2D)       (None, 28, 28, 512)       2359808   
                                                                 
 block4_pool (MaxPooling2D)  (None, 14, 14, 512)       0         
                                                                 
 block5_conv1 (Conv2D)       (None, 14, 14, 512)       2359808   
                                                                 
 block5_conv2 (Conv2D)       (None, 14, 14, 512)       2359808   
                                                                 
 block5_conv3 (Conv2D)       (None, 14, 14, 512)       2359808   
                                                                 
 block5_pool (MaxPooling2D)  (None, 7, 7, 512)         0         
                                                                 
 flatten_3 (Flatten)         (None, 25088)             0         
                                                                 
 dense_3 (Dense)             (None, 5)                 125445    
                                                                 
=================================================================
Total params: 14,840,133
Trainable params: 125,445
Non-trainable params: 14,714,688
_________________________________________________________________
Epoch 1/25
/var/folders/3r/c8tg1h051m18qhsdccdysrt40000gn/T/ipykernel_11345/3456911324.py:75: UserWarning: `Model.fit_generator` is deprecated and will be removed in a future version. Please use `Model.fit`, which supports generators.
  vggr = model.fit_generator(
25/25 [==============================] - 117s 5s/step - loss: 1.4384 - accuracy: 0.4363 - val_loss: 0.8596 - val_accuracy: 0.6719
Epoch 2/25
25/25 [==============================] - 121s 5s/step - loss: 0.6040 - accuracy: 0.7975 - val_loss: 0.6615 - val_accuracy: 0.7552
Epoch 3/25
25/25 [==============================] - 126s 5s/step - loss: 0.3955 - accuracy: 0.9000 - val_loss: 0.5536 - val_accuracy: 0.7969
Epoch 4/25
25/25 [==============================] - 124s 5s/step - loss: 0.3278 - accuracy: 0.9237 - val_loss: 0.5154 - val_accuracy: 0.8438
Epoch 5/25
25/25 [==============================] - 124s 5s/step - loss: 0.2700 - accuracy: 0.9350 - val_loss: 0.5352 - val_accuracy: 0.7969
Epoch 6/25
25/25 [==============================] - 119s 5s/step - loss: 0.2109 - accuracy: 0.9538 - val_loss: 0.3983 - val_accuracy: 0.8854
Epoch 7/25
25/25 [==============================] - 117s 5s/step - loss: 0.1713 - accuracy: 0.9812 - val_loss: 0.3841 - val_accuracy: 0.8802
Epoch 8/25
25/25 [==============================] - 115s 5s/step - loss: 0.1519 - accuracy: 0.9850 - val_loss: 0.3871 - val_accuracy: 0.8854
Epoch 9/25
25/25 [==============================] - 117s 5s/step - loss: 0.1412 - accuracy: 0.9800 - val_loss: 0.4005 - val_accuracy: 0.8958
Epoch 10/25
25/25 [==============================] - 116s 5s/step - loss: 0.1176 - accuracy: 0.9900 - val_loss: 0.3657 - val_accuracy: 0.9062
Epoch 11/25
25/25 [==============================] - 116s 5s/step - loss: 0.1200 - accuracy: 0.9825 - val_loss: 0.3862 - val_accuracy: 0.8646
Epoch 12/25
25/25 [==============================] - 116s 5s/step - loss: 0.0958 - accuracy: 0.9912 - val_loss: 0.3412 - val_accuracy: 0.9010
Epoch 13/25
25/25 [==============================] - 113s 5s/step - loss: 0.0914 - accuracy: 0.9925 - val_loss: 0.3484 - val_accuracy: 0.8854
Epoch 14/25
25/25 [==============================] - 115s 5s/step - loss: 0.0799 - accuracy: 0.9950 - val_loss: 0.3406 - val_accuracy: 0.8906
Epoch 15/25
25/25 [==============================] - 118s 5s/step - loss: 0.0714 - accuracy: 0.9975 - val_loss: 0.3355 - val_accuracy: 0.8958
Epoch 16/25
25/25 [==============================] - 121s 5s/step - loss: 0.0728 - accuracy: 0.9950 - val_loss: 0.3384 - val_accuracy: 0.9062
Epoch 17/25
25/25 [==============================] - 120s 5s/step - loss: 0.0674 - accuracy: 0.9962 - val_loss: 0.3627 - val_accuracy: 0.8958
Epoch 18/25
25/25 [==============================] - 118s 5s/step - loss: 0.0580 - accuracy: 0.9962 - val_loss: 0.3231 - val_accuracy: 0.9115
Epoch 19/25
25/25 [==============================] - 118s 5s/step - loss: 0.0509 - accuracy: 0.9987 - val_loss: 0.3387 - val_accuracy: 0.8958
Epoch 20/25
25/25 [==============================] - 119s 5s/step - loss: 0.0492 - accuracy: 0.9987 - val_loss: 0.3076 - val_accuracy: 0.8906
Epoch 21/25
25/25 [==============================] - 1405s 58s/step - loss: 0.0458 - accuracy: 0.9987 - val_loss: 0.3350 - val_accuracy: 0.8854
Epoch 22/25
25/25 [==============================] - 1635s 68s/step - loss: 0.0458 - accuracy: 0.9975 - val_loss: 0.3148 - val_accuracy: 0.9062
Epoch 23/25
25/25 [==============================] - 103s 4s/step - loss: 0.0384 - accuracy: 1.0000 - val_loss: 0.3446 - val_accuracy: 0.8750
Epoch 24/25
25/25 [==============================] - 106s 4s/step - loss: 0.0387 - accuracy: 0.9987 - val_loss: 0.2885 - val_accuracy: 0.9062
Epoch 25/25
25/25 [==============================] - 109s 4s/step - loss: 0.0335 - accuracy: 1.0000 - val_loss: 0.2845 - val_accuracy: 0.8958
import matplotlib.pyplot as plt
plt.plot(vggr.history["accuracy"])
plt.plot(vggr.history['val_accuracy'])
plt.plot(vggr.history['loss'])
plt.plot(vggr.history['val_loss'])
plt.title("Model accuracy")
plt.ylabel("Value")
plt.xlabel("Epoch")
plt.legend(["Accuracy","Validation Accuracy","Loss","Validation Loss"])
plt.show()
model.evaluate(test_ds)
8/8 [==============================] - 29s 4s/step - loss: 0.3817 - accuracy: 0.8633
[0.38167834281921387, 0.86328125]

ResNet101V2

from keras.layers import Input, Lambda, Dense, Flatten
from keras.models import Model
from keras.preprocessing import image
from keras.preprocessing.image import ImageDataGenerator
from keras.models import Sequential
import numpy as np
from glob import glob
import matplotlib.pyplot as plt
import ssl
ssl._create_default_https_context = ssl._create_unverified_context
from keras.applications import ResNet101V2

# re-size all the images to this
IMAGE_SIZE = [224, 224]

# add preprocessing layer to the front of resnet
resnet = ResNet101V2(input_shape=IMAGE_SIZE + [3], weights='imagenet', include_top=False)

# don't train existing weights
for layer in resnet.layers:
  layer.trainable = False
  
  # useful for getting number of classes
classes = 5
  

# our layers - you can add more if you want
x = Flatten()(resnet.output)
# x = Dense(1000, activation='relu')(x)
prediction = Dense(5, activation='softmax')(x)
# create a model object
model = Model(inputs=resnet.input, outputs=prediction)

# view the structure of the model
model.summary()
Model: "model_4"
__________________________________________________________________________________________________
 Layer (type)                   Output Shape         Param #     Connected to                     
==================================================================================================
 input_5 (InputLayer)           [(None, 224, 224, 3  0           []                               
                                )]                                                                
                                                                                                  
 conv1_pad (ZeroPadding2D)      (None, 230, 230, 3)  0           ['input_5[0][0]']                
                                                                                                  
 conv1_conv (Conv2D)            (None, 112, 112, 64  9472        ['conv1_pad[0][0]']              
                                )                                                                 
                                                                                                  
 pool1_pad (ZeroPadding2D)      (None, 114, 114, 64  0           ['conv1_conv[0][0]']             
                                )                                                                 
                                                                                                  
 pool1_pool (MaxPooling2D)      (None, 56, 56, 64)   0           ['pool1_pad[0][0]']              
                                                                                                  
 conv2_block1_preact_bn (BatchN  (None, 56, 56, 64)  256         ['pool1_pool[0][0]']             
 ormalization)                                                                                    
                                                                                                  
 conv2_block1_preact_relu (Acti  (None, 56, 56, 64)  0           ['conv2_block1_preact_bn[0][0]'] 
 vation)                                                                                          
                                                                                                  
 conv2_block1_1_conv (Conv2D)   (None, 56, 56, 64)   4096        ['conv2_block1_preact_relu[0][0]'
                                                                 ]                                
                                                                                                  
 conv2_block1_1_bn (BatchNormal  (None, 56, 56, 64)  256         ['conv2_block1_1_conv[0][0]']    
 ization)                                                                                         
                                                                                                  
 conv2_block1_1_relu (Activatio  (None, 56, 56, 64)  0           ['conv2_block1_1_bn[0][0]']      
 n)                                                                                               
                                                                                                  
 conv2_block1_2_pad (ZeroPaddin  (None, 58, 58, 64)  0           ['conv2_block1_1_relu[0][0]']    
 g2D)                                                                                             
                                                                                                  
 conv2_block1_2_conv (Conv2D)   (None, 56, 56, 64)   36864       ['conv2_block1_2_pad[0][0]']     
                                                                                                  
 conv2_block1_2_bn (BatchNormal  (None, 56, 56, 64)  256         ['conv2_block1_2_conv[0][0]']    
 ization)                                                                                         
                                                                                                  
 conv2_block1_2_relu (Activatio  (None, 56, 56, 64)  0           ['conv2_block1_2_bn[0][0]']      
 n)                                                                                               
                                                                                                  
 conv2_block1_0_conv (Conv2D)   (None, 56, 56, 256)  16640       ['conv2_block1_preact_relu[0][0]'
                                                                 ]                                
                                                                                                  
 conv2_block1_3_conv (Conv2D)   (None, 56, 56, 256)  16640       ['conv2_block1_2_relu[0][0]']    
                                                                                                  
 conv2_block1_out (Add)         (None, 56, 56, 256)  0           ['conv2_block1_0_conv[0][0]',    
                                                                  'conv2_block1_3_conv[0][0]']    
                                                                                                  
 conv2_block2_preact_bn (BatchN  (None, 56, 56, 256)  1024       ['conv2_block1_out[0][0]']       
 ormalization)                                                                                    
                                                                                                  
 conv2_block2_preact_relu (Acti  (None, 56, 56, 256)  0          ['conv2_block2_preact_bn[0][0]'] 
 vation)                                                                                          
                                                                                                  
 conv2_block2_1_conv (Conv2D)   (None, 56, 56, 64)   16384       ['conv2_block2_preact_relu[0][0]'
                                                                 ]                                
                                                                                                  
 conv2_block2_1_bn (BatchNormal  (None, 56, 56, 64)  256         ['conv2_block2_1_conv[0][0]']    
 ization)                                                                                         
                                                                                                  
 conv2_block2_1_relu (Activatio  (None, 56, 56, 64)  0           ['conv2_block2_1_bn[0][0]']      
 n)                                                                                               
                                                                                                  
 conv2_block2_2_pad (ZeroPaddin  (None, 58, 58, 64)  0           ['conv2_block2_1_relu[0][0]']    
 g2D)                                                                                             
                                                                                                  
 conv2_block2_2_conv (Conv2D)   (None, 56, 56, 64)   36864       ['conv2_block2_2_pad[0][0]']     
                                                                                                  
 conv2_block2_2_bn (BatchNormal  (None, 56, 56, 64)  256         ['conv2_block2_2_conv[0][0]']    
 ization)                                                                                         
                                                                                                  
 conv2_block2_2_relu (Activatio  (None, 56, 56, 64)  0           ['conv2_block2_2_bn[0][0]']      
 n)                                                                                               
                                                                                                  
 conv2_block2_3_conv (Conv2D)   (None, 56, 56, 256)  16640       ['conv2_block2_2_relu[0][0]']    
                                                                                                  
 conv2_block2_out (Add)         (None, 56, 56, 256)  0           ['conv2_block1_out[0][0]',       
                                                                  'conv2_block2_3_conv[0][0]']    
                                                                                                  
 conv2_block3_preact_bn (BatchN  (None, 56, 56, 256)  1024       ['conv2_block2_out[0][0]']       
 ormalization)                                                                                    
                                                                                                  
 conv2_block3_preact_relu (Acti  (None, 56, 56, 256)  0          ['conv2_block3_preact_bn[0][0]'] 
 vation)                                                                                          
                                                                                                  
 conv2_block3_1_conv (Conv2D)   (None, 56, 56, 64)   16384       ['conv2_block3_preact_relu[0][0]'
                                                                 ]                                
                                                                                                  
 conv2_block3_1_bn (BatchNormal  (None, 56, 56, 64)  256         ['conv2_block3_1_conv[0][0]']    
 ization)                                                                                         
                                                                                                  
 conv2_block3_1_relu (Activatio  (None, 56, 56, 64)  0           ['conv2_block3_1_bn[0][0]']      
 n)                                                                                               
                                                                                                  
 conv2_block3_2_pad (ZeroPaddin  (None, 58, 58, 64)  0           ['conv2_block3_1_relu[0][0]']    
 g2D)                                                                                             
                                                                                                  
 conv2_block3_2_conv (Conv2D)   (None, 28, 28, 64)   36864       ['conv2_block3_2_pad[0][0]']     
                                                                                                  
 conv2_block3_2_bn (BatchNormal  (None, 28, 28, 64)  256         ['conv2_block3_2_conv[0][0]']    
 ization)                                                                                         
                                                                                                  
 conv2_block3_2_relu (Activatio  (None, 28, 28, 64)  0           ['conv2_block3_2_bn[0][0]']      
 n)                                                                                               
                                                                                                  
 max_pooling2d_3 (MaxPooling2D)  (None, 28, 28, 256)  0          ['conv2_block2_out[0][0]']       
                                                                                                  
 conv2_block3_3_conv (Conv2D)   (None, 28, 28, 256)  16640       ['conv2_block3_2_relu[0][0]']    
                                                                                                  
 conv2_block3_out (Add)         (None, 28, 28, 256)  0           ['max_pooling2d_3[0][0]',        
                                                                  'conv2_block3_3_conv[0][0]']    
                                                                                                  
 conv3_block1_preact_bn (BatchN  (None, 28, 28, 256)  1024       ['conv2_block3_out[0][0]']       
 ormalization)                                                                                    
                                                                                                  
 conv3_block1_preact_relu (Acti  (None, 28, 28, 256)  0          ['conv3_block1_preact_bn[0][0]'] 
 vation)                                                                                          
                                                                                                  
 conv3_block1_1_conv (Conv2D)   (None, 28, 28, 128)  32768       ['conv3_block1_preact_relu[0][0]'
                                                                 ]                                
                                                                                                  
 conv3_block1_1_bn (BatchNormal  (None, 28, 28, 128)  512        ['conv3_block1_1_conv[0][0]']    
 ization)                                                                                         
                                                                                                  
 conv3_block1_1_relu (Activatio  (None, 28, 28, 128)  0          ['conv3_block1_1_bn[0][0]']      
 n)                                                                                               
                                                                                                  
 conv3_block1_2_pad (ZeroPaddin  (None, 30, 30, 128)  0          ['conv3_block1_1_relu[0][0]']    
 g2D)                                                                                             
                                                                                                  
 conv3_block1_2_conv (Conv2D)   (None, 28, 28, 128)  147456      ['conv3_block1_2_pad[0][0]']     
                                                                                                  
 conv3_block1_2_bn (BatchNormal  (None, 28, 28, 128)  512        ['conv3_block1_2_conv[0][0]']    
 ization)                                                                                         
                                                                                                  
 conv3_block1_2_relu (Activatio  (None, 28, 28, 128)  0          ['conv3_block1_2_bn[0][0]']      
 n)                                                                                               
                                                                                                  
 conv3_block1_0_conv (Conv2D)   (None, 28, 28, 512)  131584      ['conv3_block1_preact_relu[0][0]'
                                                                 ]                                
                                                                                                  
 conv3_block1_3_conv (Conv2D)   (None, 28, 28, 512)  66048       ['conv3_block1_2_relu[0][0]']    
                                                                                                  
 conv3_block1_out (Add)         (None, 28, 28, 512)  0           ['conv3_block1_0_conv[0][0]',    
                                                                  'conv3_block1_3_conv[0][0]']    
                                                                                                  
 conv3_block2_preact_bn (BatchN  (None, 28, 28, 512)  2048       ['conv3_block1_out[0][0]']       
 ormalization)                                                                                    
                                                                                                  
 conv3_block2_preact_relu (Acti  (None, 28, 28, 512)  0          ['conv3_block2_preact_bn[0][0]'] 
 vation)                                                                                          
                                                                                                  
 conv3_block2_1_conv (Conv2D)   (None, 28, 28, 128)  65536       ['conv3_block2_preact_relu[0][0]'
                                                                 ]                                
                                                                                                  
 conv3_block2_1_bn (BatchNormal  (None, 28, 28, 128)  512        ['conv3_block2_1_conv[0][0]']    
 ization)                                                                                         
                                                                                                  
 conv3_block2_1_relu (Activatio  (None, 28, 28, 128)  0          ['conv3_block2_1_bn[0][0]']      
 n)                                                                                               
                                                                                                  
 conv3_block2_2_pad (ZeroPaddin  (None, 30, 30, 128)  0          ['conv3_block2_1_relu[0][0]']    
 g2D)                                                                                             
                                                                                                  
 conv3_block2_2_conv (Conv2D)   (None, 28, 28, 128)  147456      ['conv3_block2_2_pad[0][0]']     
                                                                                                  
 conv3_block2_2_bn (BatchNormal  (None, 28, 28, 128)  512        ['conv3_block2_2_conv[0][0]']    
 ization)                                                                                         
                                                                                                  
 conv3_block2_2_relu (Activatio  (None, 28, 28, 128)  0          ['conv3_block2_2_bn[0][0]']      
 n)                                                                                               
                                                                                                  
 conv3_block2_3_conv (Conv2D)   (None, 28, 28, 512)  66048       ['conv3_block2_2_relu[0][0]']    
                                                                                                  
 conv3_block2_out (Add)         (None, 28, 28, 512)  0           ['conv3_block1_out[0][0]',       
                                                                  'conv3_block2_3_conv[0][0]']    
                                                                                                  
 conv3_block3_preact_bn (BatchN  (None, 28, 28, 512)  2048       ['conv3_block2_out[0][0]']       
 ormalization)                                                                                    
                                                                                                  
 conv3_block3_preact_relu (Acti  (None, 28, 28, 512)  0          ['conv3_block3_preact_bn[0][0]'] 
 vation)                                                                                          
                                                                                                  
 conv3_block3_1_conv (Conv2D)   (None, 28, 28, 128)  65536       ['conv3_block3_preact_relu[0][0]'
                                                                 ]                                
                                                                                                  
 conv3_block3_1_bn (BatchNormal  (None, 28, 28, 128)  512        ['conv3_block3_1_conv[0][0]']    
 ization)                                                                                         
                                                                                                  
 conv3_block3_1_relu (Activatio  (None, 28, 28, 128)  0          ['conv3_block3_1_bn[0][0]']      
 n)                                                                                               
                                                                                                  
 conv3_block3_2_pad (ZeroPaddin  (None, 30, 30, 128)  0          ['conv3_block3_1_relu[0][0]']    
 g2D)                                                                                             
                                                                                                  
 conv3_block3_2_conv (Conv2D)   (None, 28, 28, 128)  147456      ['conv3_block3_2_pad[0][0]']     
                                                                                                  
 conv3_block3_2_bn (BatchNormal  (None, 28, 28, 128)  512        ['conv3_block3_2_conv[0][0]']    
 ization)                                                                                         
                                                                                                  
 conv3_block3_2_relu (Activatio  (None, 28, 28, 128)  0          ['conv3_block3_2_bn[0][0]']      
 n)                                                                                               
                                                                                                  
 conv3_block3_3_conv (Conv2D)   (None, 28, 28, 512)  66048       ['conv3_block3_2_relu[0][0]']    
                                                                                                  
 conv3_block3_out (Add)         (None, 28, 28, 512)  0           ['conv3_block2_out[0][0]',       
                                                                  'conv3_block3_3_conv[0][0]']    
                                                                                                  
 conv3_block4_preact_bn (BatchN  (None, 28, 28, 512)  2048       ['conv3_block3_out[0][0]']       
 ormalization)                                                                                    
                                                                                                  
 conv3_block4_preact_relu (Acti  (None, 28, 28, 512)  0          ['conv3_block4_preact_bn[0][0]'] 
 vation)                                                                                          
                                                                                                  
 conv3_block4_1_conv (Conv2D)   (None, 28, 28, 128)  65536       ['conv3_block4_preact_relu[0][0]'
                                                                 ]                                
                                                                                                  
 conv3_block4_1_bn (BatchNormal  (None, 28, 28, 128)  512        ['conv3_block4_1_conv[0][0]']    
 ization)                                                                                         
                                                                                                  
 conv3_block4_1_relu (Activatio  (None, 28, 28, 128)  0          ['conv3_block4_1_bn[0][0]']      
 n)                                                                                               
                                                                                                  
 conv3_block4_2_pad (ZeroPaddin  (None, 30, 30, 128)  0          ['conv3_block4_1_relu[0][0]']    
 g2D)                                                                                             
                                                                                                  
 conv3_block4_2_conv (Conv2D)   (None, 14, 14, 128)  147456      ['conv3_block4_2_pad[0][0]']     
                                                                                                  
 conv3_block4_2_bn (BatchNormal  (None, 14, 14, 128)  512        ['conv3_block4_2_conv[0][0]']    
 ization)                                                                                         
                                                                                                  
 conv3_block4_2_relu (Activatio  (None, 14, 14, 128)  0          ['conv3_block4_2_bn[0][0]']      
 n)                                                                                               
                                                                                                  
 max_pooling2d_4 (MaxPooling2D)  (None, 14, 14, 512)  0          ['conv3_block3_out[0][0]']       
                                                                                                  
 conv3_block4_3_conv (Conv2D)   (None, 14, 14, 512)  66048       ['conv3_block4_2_relu[0][0]']    
                                                                                                  
 conv3_block4_out (Add)         (None, 14, 14, 512)  0           ['max_pooling2d_4[0][0]',        
                                                                  'conv3_block4_3_conv[0][0]']    
                                                                                                  
 conv4_block1_preact_bn (BatchN  (None, 14, 14, 512)  2048       ['conv3_block4_out[0][0]']       
 ormalization)                                                                                    
                                                                                                  
 conv4_block1_preact_relu (Acti  (None, 14, 14, 512)  0          ['conv4_block1_preact_bn[0][0]'] 
 vation)                                                                                          
                                                                                                  
 conv4_block1_1_conv (Conv2D)   (None, 14, 14, 256)  131072      ['conv4_block1_preact_relu[0][0]'
                                                                 ]                                
                                                                                                  
 conv4_block1_1_bn (BatchNormal  (None, 14, 14, 256)  1024       ['conv4_block1_1_conv[0][0]']    
 ization)                                                                                         
                                                                                                  
 conv4_block1_1_relu (Activatio  (None, 14, 14, 256)  0          ['conv4_block1_1_bn[0][0]']      
 n)                                                                                               
                                                                                                  
 conv4_block1_2_pad (ZeroPaddin  (None, 16, 16, 256)  0          ['conv4_block1_1_relu[0][0]']    
 g2D)                                                                                             
                                                                                                  
 conv4_block1_2_conv (Conv2D)   (None, 14, 14, 256)  589824      ['conv4_block1_2_pad[0][0]']     
                                                                                                  
 conv4_block1_2_bn (BatchNormal  (None, 14, 14, 256)  1024       ['conv4_block1_2_conv[0][0]']    
 ization)                                                                                         
                                                                                                  
 conv4_block1_2_relu (Activatio  (None, 14, 14, 256)  0          ['conv4_block1_2_bn[0][0]']      
 n)                                                                                               
                                                                                                  
 conv4_block1_0_conv (Conv2D)   (None, 14, 14, 1024  525312      ['conv4_block1_preact_relu[0][0]'
                                )                                ]                                
                                                                                                  
 conv4_block1_3_conv (Conv2D)   (None, 14, 14, 1024  263168      ['conv4_block1_2_relu[0][0]']    
                                )                                                                 
                                                                                                  
 conv4_block1_out (Add)         (None, 14, 14, 1024  0           ['conv4_block1_0_conv[0][0]',    
                                )                                 'conv4_block1_3_conv[0][0]']    
                                                                                                  
 conv4_block2_preact_bn (BatchN  (None, 14, 14, 1024  4096       ['conv4_block1_out[0][0]']       
 ormalization)                  )                                                                 
                                                                                                  
 conv4_block2_preact_relu (Acti  (None, 14, 14, 1024  0          ['conv4_block2_preact_bn[0][0]'] 
 vation)                        )                                                                 
                                                                                                  
 conv4_block2_1_conv (Conv2D)   (None, 14, 14, 256)  262144      ['conv4_block2_preact_relu[0][0]'
                                                                 ]                                
                                                                                                  
 conv4_block2_1_bn (BatchNormal  (None, 14, 14, 256)  1024       ['conv4_block2_1_conv[0][0]']    
 ization)                                                                                         
                                                                                                  
 conv4_block2_1_relu (Activatio  (None, 14, 14, 256)  0          ['conv4_block2_1_bn[0][0]']      
 n)                                                                                               
                                                                                                  
 conv4_block2_2_pad (ZeroPaddin  (None, 16, 16, 256)  0          ['conv4_block2_1_relu[0][0]']    
 g2D)                                                                                             
                                                                                                  
 conv4_block2_2_conv (Conv2D)   (None, 14, 14, 256)  589824      ['conv4_block2_2_pad[0][0]']     
                                                                                                  
 conv4_block2_2_bn (BatchNormal  (None, 14, 14, 256)  1024       ['conv4_block2_2_conv[0][0]']    
 ization)                                                                                         
                                                                                                  
 conv4_block2_2_relu (Activatio  (None, 14, 14, 256)  0          ['conv4_block2_2_bn[0][0]']      
 n)                                                                                               
                                                                                                  
 conv4_block2_3_conv (Conv2D)   (None, 14, 14, 1024  263168      ['conv4_block2_2_relu[0][0]']    
                                )                                                                 
                                                                                                  
 conv4_block2_out (Add)         (None, 14, 14, 1024  0           ['conv4_block1_out[0][0]',       
                                )                                 'conv4_block2_3_conv[0][0]']    
                                                                                                  
 conv4_block3_preact_bn (BatchN  (None, 14, 14, 1024  4096       ['conv4_block2_out[0][0]']       
 ormalization)                  )                                                                 
                                                                                                  
 conv4_block3_preact_relu (Acti  (None, 14, 14, 1024  0          ['conv4_block3_preact_bn[0][0]'] 
 vation)                        )                                                                 
                                                                                                  
 conv4_block3_1_conv (Conv2D)   (None, 14, 14, 256)  262144      ['conv4_block3_preact_relu[0][0]'
                                                                 ]                                
                                                                                                  
 conv4_block3_1_bn (BatchNormal  (None, 14, 14, 256)  1024       ['conv4_block3_1_conv[0][0]']    
 ization)                                                                                         
                                                                                                  
 conv4_block3_1_relu (Activatio  (None, 14, 14, 256)  0          ['conv4_block3_1_bn[0][0]']      
 n)                                                                                               
                                                                                                  
 conv4_block3_2_pad (ZeroPaddin  (None, 16, 16, 256)  0          ['conv4_block3_1_relu[0][0]']    
 g2D)                                                                                             
                                                                                                  
 conv4_block3_2_conv (Conv2D)   (None, 14, 14, 256)  589824      ['conv4_block3_2_pad[0][0]']     
                                                                                                  
 conv4_block3_2_bn (BatchNormal  (None, 14, 14, 256)  1024       ['conv4_block3_2_conv[0][0]']    
 ization)                                                                                         
                                                                                                  
 conv4_block3_2_relu (Activatio  (None, 14, 14, 256)  0          ['conv4_block3_2_bn[0][0]']      
 n)                                                                                               
                                                                                                  
 conv4_block3_3_conv (Conv2D)   (None, 14, 14, 1024  263168      ['conv4_block3_2_relu[0][0]']    
                                )                                                                 
                                                                                                  
 conv4_block3_out (Add)         (None, 14, 14, 1024  0           ['conv4_block2_out[0][0]',       
                                )                                 'conv4_block3_3_conv[0][0]']    
                                                                                                  
 conv4_block4_preact_bn (BatchN  (None, 14, 14, 1024  4096       ['conv4_block3_out[0][0]']       
 ormalization)                  )                                                                 
                                                                                                  
 conv4_block4_preact_relu (Acti  (None, 14, 14, 1024  0          ['conv4_block4_preact_bn[0][0]'] 
 vation)                        )                                                                 
                                                                                                  
 conv4_block4_1_conv (Conv2D)   (None, 14, 14, 256)  262144      ['conv4_block4_preact_relu[0][0]'
                                                                 ]                                
                                                                                                  
 conv4_block4_1_bn (BatchNormal  (None, 14, 14, 256)  1024       ['conv4_block4_1_conv[0][0]']    
 ization)                                                                                         
                                                                                                  
 conv4_block4_1_relu (Activatio  (None, 14, 14, 256)  0          ['conv4_block4_1_bn[0][0]']      
 n)                                                                                               
                                                                                                  
 conv4_block4_2_pad (ZeroPaddin  (None, 16, 16, 256)  0          ['conv4_block4_1_relu[0][0]']    
 g2D)                                                                                             
                                                                                                  
 conv4_block4_2_conv (Conv2D)   (None, 14, 14, 256)  589824      ['conv4_block4_2_pad[0][0]']     
                                                                                                  
 conv4_block4_2_bn (BatchNormal  (None, 14, 14, 256)  1024       ['conv4_block4_2_conv[0][0]']    
 ization)                                                                                         
                                                                                                  
 conv4_block4_2_relu (Activatio  (None, 14, 14, 256)  0          ['conv4_block4_2_bn[0][0]']      
 n)                                                                                               
                                                                                                  
 conv4_block4_3_conv (Conv2D)   (None, 14, 14, 1024  263168      ['conv4_block4_2_relu[0][0]']    
                                )                                                                 
                                                                                                  
 conv4_block4_out (Add)         (None, 14, 14, 1024  0           ['conv4_block3_out[0][0]',       
                                )                                 'conv4_block4_3_conv[0][0]']    
                                                                                                  
 conv4_block5_preact_bn (BatchN  (None, 14, 14, 1024  4096       ['conv4_block4_out[0][0]']       
 ormalization)                  )                                                                 
                                                                                                  
 conv4_block5_preact_relu (Acti  (None, 14, 14, 1024  0          ['conv4_block5_preact_bn[0][0]'] 
 vation)                        )                                                                 
                                                                                                  
 conv4_block5_1_conv (Conv2D)   (None, 14, 14, 256)  262144      ['conv4_block5_preact_relu[0][0]'
                                                                 ]                                
                                                                                                  
 conv4_block5_1_bn (BatchNormal  (None, 14, 14, 256)  1024       ['conv4_block5_1_conv[0][0]']    
 ization)                                                                                         
                                                                                                  
 conv4_block5_1_relu (Activatio  (None, 14, 14, 256)  0          ['conv4_block5_1_bn[0][0]']      
 n)                                                                                               
                                                                                                  
 conv4_block5_2_pad (ZeroPaddin  (None, 16, 16, 256)  0          ['conv4_block5_1_relu[0][0]']    
 g2D)                                                                                             
                                                                                                  
 conv4_block5_2_conv (Conv2D)   (None, 14, 14, 256)  589824      ['conv4_block5_2_pad[0][0]']     
                                                                                                  
 conv4_block5_2_bn (BatchNormal  (None, 14, 14, 256)  1024       ['conv4_block5_2_conv[0][0]']    
 ization)                                                                                         
                                                                                                  
 conv4_block5_2_relu (Activatio  (None, 14, 14, 256)  0          ['conv4_block5_2_bn[0][0]']      
 n)                                                                                               
                                                                                                  
 conv4_block5_3_conv (Conv2D)   (None, 14, 14, 1024  263168      ['conv4_block5_2_relu[0][0]']    
                                )                                                                 
                                                                                                  
 conv4_block5_out (Add)         (None, 14, 14, 1024  0           ['conv4_block4_out[0][0]',       
                                )                                 'conv4_block5_3_conv[0][0]']    
                                                                                                  
 conv4_block6_preact_bn (BatchN  (None, 14, 14, 1024  4096       ['conv4_block5_out[0][0]']       
 ormalization)                  )                                                                 
                                                                                                  
 conv4_block6_preact_relu (Acti  (None, 14, 14, 1024  0          ['conv4_block6_preact_bn[0][0]'] 
 vation)                        )                                                                 
                                                                                                  
 conv4_block6_1_conv (Conv2D)   (None, 14, 14, 256)  262144      ['conv4_block6_preact_relu[0][0]'
                                                                 ]                                
                                                                                                  
 conv4_block6_1_bn (BatchNormal  (None, 14, 14, 256)  1024       ['conv4_block6_1_conv[0][0]']    
 ization)                                                                                         
                                                                                                  
 conv4_block6_1_relu (Activatio  (None, 14, 14, 256)  0          ['conv4_block6_1_bn[0][0]']      
 n)                                                                                               
                                                                                                  
 conv4_block6_2_pad (ZeroPaddin  (None, 16, 16, 256)  0          ['conv4_block6_1_relu[0][0]']    
 g2D)                                                                                             
                                                                                                  
 conv4_block6_2_conv (Conv2D)   (None, 14, 14, 256)  589824      ['conv4_block6_2_pad[0][0]']     
                                                                                                  
 conv4_block6_2_bn (BatchNormal  (None, 14, 14, 256)  1024       ['conv4_block6_2_conv[0][0]']    
 ization)                                                                                         
                                                                                                  
 conv4_block6_2_relu (Activatio  (None, 14, 14, 256)  0          ['conv4_block6_2_bn[0][0]']      
 n)                                                                                               
                                                                                                  
 conv4_block6_3_conv (Conv2D)   (None, 14, 14, 1024  263168      ['conv4_block6_2_relu[0][0]']    
                                )                                                                 
                                                                                                  
 conv4_block6_out (Add)         (None, 14, 14, 1024  0           ['conv4_block5_out[0][0]',       
                                )                                 'conv4_block6_3_conv[0][0]']    
                                                                                                  
 conv4_block7_preact_bn (BatchN  (None, 14, 14, 1024  4096       ['conv4_block6_out[0][0]']       
 ormalization)                  )                                                                 
                                                                                                  
 conv4_block7_preact_relu (Acti  (None, 14, 14, 1024  0          ['conv4_block7_preact_bn[0][0]'] 
 vation)                        )                                                                 
                                                                                                  
 conv4_block7_1_conv (Conv2D)   (None, 14, 14, 256)  262144      ['conv4_block7_preact_relu[0][0]'
                                                                 ]                                
                                                                                                  
 conv4_block7_1_bn (BatchNormal  (None, 14, 14, 256)  1024       ['conv4_block7_1_conv[0][0]']    
 ization)                                                                                         
                                                                                                  
 conv4_block7_1_relu (Activatio  (None, 14, 14, 256)  0          ['conv4_block7_1_bn[0][0]']      
 n)                                                                                               
                                                                                                  
 conv4_block7_2_pad (ZeroPaddin  (None, 16, 16, 256)  0          ['conv4_block7_1_relu[0][0]']    
 g2D)                                                                                             
                                                                                                  
 conv4_block7_2_conv (Conv2D)   (None, 14, 14, 256)  589824      ['conv4_block7_2_pad[0][0]']     
                                                                                                  
 conv4_block7_2_bn (BatchNormal  (None, 14, 14, 256)  1024       ['conv4_block7_2_conv[0][0]']    
 ization)                                                                                         
                                                                                                  
 conv4_block7_2_relu (Activatio  (None, 14, 14, 256)  0          ['conv4_block7_2_bn[0][0]']      
 n)                                                                                               
                                                                                                  
 conv4_block7_3_conv (Conv2D)   (None, 14, 14, 1024  263168      ['conv4_block7_2_relu[0][0]']    
                                )                                                                 
                                                                                                  
 conv4_block7_out (Add)         (None, 14, 14, 1024  0           ['conv4_block6_out[0][0]',       
                                )                                 'conv4_block7_3_conv[0][0]']    
                                                                                                  
 conv4_block8_preact_bn (BatchN  (None, 14, 14, 1024  4096       ['conv4_block7_out[0][0]']       
 ormalization)                  )                                                                 
                                                                                                  
 conv4_block8_preact_relu (Acti  (None, 14, 14, 1024  0          ['conv4_block8_preact_bn[0][0]'] 
 vation)                        )                                                                 
                                                                                                  
 conv4_block8_1_conv (Conv2D)   (None, 14, 14, 256)  262144      ['conv4_block8_preact_relu[0][0]'
                                                                 ]                                
                                                                                                  
 conv4_block8_1_bn (BatchNormal  (None, 14, 14, 256)  1024       ['conv4_block8_1_conv[0][0]']    
 ization)                                                                                         
                                                                                                  
 conv4_block8_1_relu (Activatio  (None, 14, 14, 256)  0          ['conv4_block8_1_bn[0][0]']      
 n)                                                                                               
                                                                                                  
 conv4_block8_2_pad (ZeroPaddin  (None, 16, 16, 256)  0          ['conv4_block8_1_relu[0][0]']    
 g2D)                                                                                             
                                                                                                  
 conv4_block8_2_conv (Conv2D)   (None, 14, 14, 256)  589824      ['conv4_block8_2_pad[0][0]']     
                                                                                                  
 conv4_block8_2_bn (BatchNormal  (None, 14, 14, 256)  1024       ['conv4_block8_2_conv[0][0]']    
 ization)                                                                                         
                                                                                                  
 conv4_block8_2_relu (Activatio  (None, 14, 14, 256)  0          ['conv4_block8_2_bn[0][0]']      
 n)                                                                                               
                                                                                                  
 conv4_block8_3_conv (Conv2D)   (None, 14, 14, 1024  263168      ['conv4_block8_2_relu[0][0]']    
                                )                                                                 
                                                                                                  
 conv4_block8_out (Add)         (None, 14, 14, 1024  0           ['conv4_block7_out[0][0]',       
                                )                                 'conv4_block8_3_conv[0][0]']    
                                                                                                  
 conv4_block9_preact_bn (BatchN  (None, 14, 14, 1024  4096       ['conv4_block8_out[0][0]']       
 ormalization)                  )                                                                 
                                                                                                  
 conv4_block9_preact_relu (Acti  (None, 14, 14, 1024  0          ['conv4_block9_preact_bn[0][0]'] 
 vation)                        )                                                                 
                                                                                                  
 conv4_block9_1_conv (Conv2D)   (None, 14, 14, 256)  262144      ['conv4_block9_preact_relu[0][0]'
                                                                 ]                                
                                                                                                  
 conv4_block9_1_bn (BatchNormal  (None, 14, 14, 256)  1024       ['conv4_block9_1_conv[0][0]']    
 ization)                                                                                         
                                                                                                  
 conv4_block9_1_relu (Activatio  (None, 14, 14, 256)  0          ['conv4_block9_1_bn[0][0]']      
 n)                                                                                               
                                                                                                  
 conv4_block9_2_pad (ZeroPaddin  (None, 16, 16, 256)  0          ['conv4_block9_1_relu[0][0]']    
 g2D)                                                                                             
                                                                                                  
 conv4_block9_2_conv (Conv2D)   (None, 14, 14, 256)  589824      ['conv4_block9_2_pad[0][0]']     
                                                                                                  
 conv4_block9_2_bn (BatchNormal  (None, 14, 14, 256)  1024       ['conv4_block9_2_conv[0][0]']    
 ization)                                                                                         
                                                                                                  
 conv4_block9_2_relu (Activatio  (None, 14, 14, 256)  0          ['conv4_block9_2_bn[0][0]']      
 n)                                                                                               
                                                                                                  
 conv4_block9_3_conv (Conv2D)   (None, 14, 14, 1024  263168      ['conv4_block9_2_relu[0][0]']    
                                )                                                                 
                                                                                                  
 conv4_block9_out (Add)         (None, 14, 14, 1024  0           ['conv4_block8_out[0][0]',       
                                )                                 'conv4_block9_3_conv[0][0]']    
                                                                                                  
 conv4_block10_preact_bn (Batch  (None, 14, 14, 1024  4096       ['conv4_block9_out[0][0]']       
 Normalization)                 )                                                                 
                                                                                                  
 conv4_block10_preact_relu (Act  (None, 14, 14, 1024  0          ['conv4_block10_preact_bn[0][0]']
 ivation)                       )                                                                 
                                                                                                  
 conv4_block10_1_conv (Conv2D)  (None, 14, 14, 256)  262144      ['conv4_block10_preact_relu[0][0]
                                                                 ']                               
                                                                                                  
 conv4_block10_1_bn (BatchNorma  (None, 14, 14, 256)  1024       ['conv4_block10_1_conv[0][0]']   
 lization)                                                                                        
                                                                                                  
 conv4_block10_1_relu (Activati  (None, 14, 14, 256)  0          ['conv4_block10_1_bn[0][0]']     
 on)                                                                                              
                                                                                                  
 conv4_block10_2_pad (ZeroPaddi  (None, 16, 16, 256)  0          ['conv4_block10_1_relu[0][0]']   
 ng2D)                                                                                            
                                                                                                  
 conv4_block10_2_conv (Conv2D)  (None, 14, 14, 256)  589824      ['conv4_block10_2_pad[0][0]']    
                                                                                                  
 conv4_block10_2_bn (BatchNorma  (None, 14, 14, 256)  1024       ['conv4_block10_2_conv[0][0]']   
 lization)                                                                                        
                                                                                                  
 conv4_block10_2_relu (Activati  (None, 14, 14, 256)  0          ['conv4_block10_2_bn[0][0]']     
 on)                                                                                              
                                                                                                  
 conv4_block10_3_conv (Conv2D)  (None, 14, 14, 1024  263168      ['conv4_block10_2_relu[0][0]']   
                                )                                                                 
                                                                                                  
 conv4_block10_out (Add)        (None, 14, 14, 1024  0           ['conv4_block9_out[0][0]',       
                                )                                 'conv4_block10_3_conv[0][0]']   
                                                                                                  
 conv4_block11_preact_bn (Batch  (None, 14, 14, 1024  4096       ['conv4_block10_out[0][0]']      
 Normalization)                 )                                                                 
                                                                                                  
 conv4_block11_preact_relu (Act  (None, 14, 14, 1024  0          ['conv4_block11_preact_bn[0][0]']
 ivation)                       )                                                                 
                                                                                                  
 conv4_block11_1_conv (Conv2D)  (None, 14, 14, 256)  262144      ['conv4_block11_preact_relu[0][0]
                                                                 ']                               
                                                                                                  
 conv4_block11_1_bn (BatchNorma  (None, 14, 14, 256)  1024       ['conv4_block11_1_conv[0][0]']   
 lization)                                                                                        
                                                                                                  
 conv4_block11_1_relu (Activati  (None, 14, 14, 256)  0          ['conv4_block11_1_bn[0][0]']     
 on)                                                                                              
                                                                                                  
 conv4_block11_2_pad (ZeroPaddi  (None, 16, 16, 256)  0          ['conv4_block11_1_relu[0][0]']   
 ng2D)                                                                                            
                                                                                                  
 conv4_block11_2_conv (Conv2D)  (None, 14, 14, 256)  589824      ['conv4_block11_2_pad[0][0]']    
                                                                                                  
 conv4_block11_2_bn (BatchNorma  (None, 14, 14, 256)  1024       ['conv4_block11_2_conv[0][0]']   
 lization)                                                                                        
                                                                                                  
 conv4_block11_2_relu (Activati  (None, 14, 14, 256)  0          ['conv4_block11_2_bn[0][0]']     
 on)                                                                                              
                                                                                                  
 conv4_block11_3_conv (Conv2D)  (None, 14, 14, 1024  263168      ['conv4_block11_2_relu[0][0]']   
                                )                                                                 
                                                                                                  
 conv4_block11_out (Add)        (None, 14, 14, 1024  0           ['conv4_block10_out[0][0]',      
                                )                                 'conv4_block11_3_conv[0][0]']   
                                                                                                  
 conv4_block12_preact_bn (Batch  (None, 14, 14, 1024  4096       ['conv4_block11_out[0][0]']      
 Normalization)                 )                                                                 
                                                                                                  
 conv4_block12_preact_relu (Act  (None, 14, 14, 1024  0          ['conv4_block12_preact_bn[0][0]']
 ivation)                       )                                                                 
                                                                                                  
 conv4_block12_1_conv (Conv2D)  (None, 14, 14, 256)  262144      ['conv4_block12_preact_relu[0][0]
                                                                 ']                               
                                                                                                  
 conv4_block12_1_bn (BatchNorma  (None, 14, 14, 256)  1024       ['conv4_block12_1_conv[0][0]']   
 lization)                                                                                        
                                                                                                  
 conv4_block12_1_relu (Activati  (None, 14, 14, 256)  0          ['conv4_block12_1_bn[0][0]']     
 on)                                                                                              
                                                                                                  
 conv4_block12_2_pad (ZeroPaddi  (None, 16, 16, 256)  0          ['conv4_block12_1_relu[0][0]']   
 ng2D)                                                                                            
                                                                                                  
 conv4_block12_2_conv (Conv2D)  (None, 14, 14, 256)  589824      ['conv4_block12_2_pad[0][0]']    
                                                                                                  
 conv4_block12_2_bn (BatchNorma  (None, 14, 14, 256)  1024       ['conv4_block12_2_conv[0][0]']   
 lization)                                                                                        
                                                                                                  
 conv4_block12_2_relu (Activati  (None, 14, 14, 256)  0          ['conv4_block12_2_bn[0][0]']     
 on)                                                                                              
                                                                                                  
 conv4_block12_3_conv (Conv2D)  (None, 14, 14, 1024  263168      ['conv4_block12_2_relu[0][0]']   
                                )                                                                 
                                                                                                  
 conv4_block12_out (Add)        (None, 14, 14, 1024  0           ['conv4_block11_out[0][0]',      
                                )                                 'conv4_block12_3_conv[0][0]']   
                                                                                                  
 conv4_block13_preact_bn (Batch  (None, 14, 14, 1024  4096       ['conv4_block12_out[0][0]']      
 Normalization)                 )                                                                 
                                                                                                  
 conv4_block13_preact_relu (Act  (None, 14, 14, 1024  0          ['conv4_block13_preact_bn[0][0]']
 ivation)                       )                                                                 
                                                                                                  
 conv4_block13_1_conv (Conv2D)  (None, 14, 14, 256)  262144      ['conv4_block13_preact_relu[0][0]
                                                                 ']                               
                                                                                                  
 conv4_block13_1_bn (BatchNorma  (None, 14, 14, 256)  1024       ['conv4_block13_1_conv[0][0]']   
 lization)                                                                                        
                                                                                                  
 conv4_block13_1_relu (Activati  (None, 14, 14, 256)  0          ['conv4_block13_1_bn[0][0]']     
 on)                                                                                              
                                                                                                  
 conv4_block13_2_pad (ZeroPaddi  (None, 16, 16, 256)  0          ['conv4_block13_1_relu[0][0]']   
 ng2D)                                                                                            
                                                                                                  
 conv4_block13_2_conv (Conv2D)  (None, 14, 14, 256)  589824      ['conv4_block13_2_pad[0][0]']    
                                                                                                  
 conv4_block13_2_bn (BatchNorma  (None, 14, 14, 256)  1024       ['conv4_block13_2_conv[0][0]']   
 lization)                                                                                        
                                                                                                  
 conv4_block13_2_relu (Activati  (None, 14, 14, 256)  0          ['conv4_block13_2_bn[0][0]']     
 on)                                                                                              
                                                                                                  
 conv4_block13_3_conv (Conv2D)  (None, 14, 14, 1024  263168      ['conv4_block13_2_relu[0][0]']   
                                )                                                                 
                                                                                                  
 conv4_block13_out (Add)        (None, 14, 14, 1024  0           ['conv4_block12_out[0][0]',      
                                )                                 'conv4_block13_3_conv[0][0]']   
                                                                                                  
 conv4_block14_preact_bn (Batch  (None, 14, 14, 1024  4096       ['conv4_block13_out[0][0]']      
 Normalization)                 )                                                                 
                                                                                                  
 conv4_block14_preact_relu (Act  (None, 14, 14, 1024  0          ['conv4_block14_preact_bn[0][0]']
 ivation)                       )                                                                 
                                                                                                  
 conv4_block14_1_conv (Conv2D)  (None, 14, 14, 256)  262144      ['conv4_block14_preact_relu[0][0]
                                                                 ']                               
                                                                                                  
 conv4_block14_1_bn (BatchNorma  (None, 14, 14, 256)  1024       ['conv4_block14_1_conv[0][0]']   
 lization)                                                                                        
                                                                                                  
 conv4_block14_1_relu (Activati  (None, 14, 14, 256)  0          ['conv4_block14_1_bn[0][0]']     
 on)                                                                                              
                                                                                                  
 conv4_block14_2_pad (ZeroPaddi  (None, 16, 16, 256)  0          ['conv4_block14_1_relu[0][0]']   
 ng2D)                                                                                            
                                                                                                  
 conv4_block14_2_conv (Conv2D)  (None, 14, 14, 256)  589824      ['conv4_block14_2_pad[0][0]']    
                                                                                                  
 conv4_block14_2_bn (BatchNorma  (None, 14, 14, 256)  1024       ['conv4_block14_2_conv[0][0]']   
 lization)                                                                                        
                                                                                                  
 conv4_block14_2_relu (Activati  (None, 14, 14, 256)  0          ['conv4_block14_2_bn[0][0]']     
 on)                                                                                              
                                                                                                  
 conv4_block14_3_conv (Conv2D)  (None, 14, 14, 1024  263168      ['conv4_block14_2_relu[0][0]']   
                                )                                                                 
                                                                                                  
 conv4_block14_out (Add)        (None, 14, 14, 1024  0           ['conv4_block13_out[0][0]',      
                                )                                 'conv4_block14_3_conv[0][0]']   
                                                                                                  
 conv4_block15_preact_bn (Batch  (None, 14, 14, 1024  4096       ['conv4_block14_out[0][0]']      
 Normalization)                 )                                                                 
                                                                                                  
 conv4_block15_preact_relu (Act  (None, 14, 14, 1024  0          ['conv4_block15_preact_bn[0][0]']
 ivation)                       )                                                                 
                                                                                                  
 conv4_block15_1_conv (Conv2D)  (None, 14, 14, 256)  262144      ['conv4_block15_preact_relu[0][0]
                                                                 ']                               
                                                                                                  
 conv4_block15_1_bn (BatchNorma  (None, 14, 14, 256)  1024       ['conv4_block15_1_conv[0][0]']   
 lization)                                                                                        
                                                                                                  
 conv4_block15_1_relu (Activati  (None, 14, 14, 256)  0          ['conv4_block15_1_bn[0][0]']     
 on)                                                                                              
                                                                                                  
 conv4_block15_2_pad (ZeroPaddi  (None, 16, 16, 256)  0          ['conv4_block15_1_relu[0][0]']   
 ng2D)                                                                                            
                                                                                                  
 conv4_block15_2_conv (Conv2D)  (None, 14, 14, 256)  589824      ['conv4_block15_2_pad[0][0]']    
                                                                                                  
 conv4_block15_2_bn (BatchNorma  (None, 14, 14, 256)  1024       ['conv4_block15_2_conv[0][0]']   
 lization)                                                                                        
                                                                                                  
 conv4_block15_2_relu (Activati  (None, 14, 14, 256)  0          ['conv4_block15_2_bn[0][0]']     
 on)                                                                                              
                                                                                                  
 conv4_block15_3_conv (Conv2D)  (None, 14, 14, 1024  263168      ['conv4_block15_2_relu[0][0]']   
                                )                                                                 
                                                                                                  
 conv4_block15_out (Add)        (None, 14, 14, 1024  0           ['conv4_block14_out[0][0]',      
                                )                                 'conv4_block15_3_conv[0][0]']   
                                                                                                  
 conv4_block16_preact_bn (Batch  (None, 14, 14, 1024  4096       ['conv4_block15_out[0][0]']      
 Normalization)                 )                                                                 
                                                                                                  
 conv4_block16_preact_relu (Act  (None, 14, 14, 1024  0          ['conv4_block16_preact_bn[0][0]']
 ivation)                       )                                                                 
                                                                                                  
 conv4_block16_1_conv (Conv2D)  (None, 14, 14, 256)  262144      ['conv4_block16_preact_relu[0][0]
                                                                 ']                               
                                                                                                  
 conv4_block16_1_bn (BatchNorma  (None, 14, 14, 256)  1024       ['conv4_block16_1_conv[0][0]']   
 lization)                                                                                        
                                                                                                  
 conv4_block16_1_relu (Activati  (None, 14, 14, 256)  0          ['conv4_block16_1_bn[0][0]']     
 on)                                                                                              
                                                                                                  
 conv4_block16_2_pad (ZeroPaddi  (None, 16, 16, 256)  0          ['conv4_block16_1_relu[0][0]']   
 ng2D)                                                                                            
                                                                                                  
 conv4_block16_2_conv (Conv2D)  (None, 14, 14, 256)  589824      ['conv4_block16_2_pad[0][0]']    
                                                                                                  
 conv4_block16_2_bn (BatchNorma  (None, 14, 14, 256)  1024       ['conv4_block16_2_conv[0][0]']   
 lization)                                                                                        
                                                                                                  
 conv4_block16_2_relu (Activati  (None, 14, 14, 256)  0          ['conv4_block16_2_bn[0][0]']     
 on)                                                                                              
                                                                                                  
 conv4_block16_3_conv (Conv2D)  (None, 14, 14, 1024  263168      ['conv4_block16_2_relu[0][0]']   
                                )                                                                 
                                                                                                  
 conv4_block16_out (Add)        (None, 14, 14, 1024  0           ['conv4_block15_out[0][0]',      
                                )                                 'conv4_block16_3_conv[0][0]']   
                                                                                                  
 conv4_block17_preact_bn (Batch  (None, 14, 14, 1024  4096       ['conv4_block16_out[0][0]']      
 Normalization)                 )                                                                 
                                                                                                  
 conv4_block17_preact_relu (Act  (None, 14, 14, 1024  0          ['conv4_block17_preact_bn[0][0]']
 ivation)                       )                                                                 
                                                                                                  
 conv4_block17_1_conv (Conv2D)  (None, 14, 14, 256)  262144      ['conv4_block17_preact_relu[0][0]
                                                                 ']                               
                                                                                                  
 conv4_block17_1_bn (BatchNorma  (None, 14, 14, 256)  1024       ['conv4_block17_1_conv[0][0]']   
 lization)                                                                                        
                                                                                                  
 conv4_block17_1_relu (Activati  (None, 14, 14, 256)  0          ['conv4_block17_1_bn[0][0]']     
 on)                                                                                              
                                                                                                  
 conv4_block17_2_pad (ZeroPaddi  (None, 16, 16, 256)  0          ['conv4_block17_1_relu[0][0]']   
 ng2D)                                                                                            
                                                                                                  
 conv4_block17_2_conv (Conv2D)  (None, 14, 14, 256)  589824      ['conv4_block17_2_pad[0][0]']    
                                                                                                  
 conv4_block17_2_bn (BatchNorma  (None, 14, 14, 256)  1024       ['conv4_block17_2_conv[0][0]']   
 lization)                                                                                        
                                                                                                  
 conv4_block17_2_relu (Activati  (None, 14, 14, 256)  0          ['conv4_block17_2_bn[0][0]']     
 on)                                                                                              
                                                                                                  
 conv4_block17_3_conv (Conv2D)  (None, 14, 14, 1024  263168      ['conv4_block17_2_relu[0][0]']   
                                )                                                                 
                                                                                                  
 conv4_block17_out (Add)        (None, 14, 14, 1024  0           ['conv4_block16_out[0][0]',      
                                )                                 'conv4_block17_3_conv[0][0]']   
                                                                                                  
 conv4_block18_preact_bn (Batch  (None, 14, 14, 1024  4096       ['conv4_block17_out[0][0]']      
 Normalization)                 )                                                                 
                                                                                                  
 conv4_block18_preact_relu (Act  (None, 14, 14, 1024  0          ['conv4_block18_preact_bn[0][0]']
 ivation)                       )                                                                 
                                                                                                  
 conv4_block18_1_conv (Conv2D)  (None, 14, 14, 256)  262144      ['conv4_block18_preact_relu[0][0]
                                                                 ']                               
                                                                                                  
 conv4_block18_1_bn (BatchNorma  (None, 14, 14, 256)  1024       ['conv4_block18_1_conv[0][0]']   
 lization)                                                                                        
                                                                                                  
 conv4_block18_1_relu (Activati  (None, 14, 14, 256)  0          ['conv4_block18_1_bn[0][0]']     
 on)                                                                                              
                                                                                                  
 conv4_block18_2_pad (ZeroPaddi  (None, 16, 16, 256)  0          ['conv4_block18_1_relu[0][0]']   
 ng2D)                                                                                            
                                                                                                  
 conv4_block18_2_conv (Conv2D)  (None, 14, 14, 256)  589824      ['conv4_block18_2_pad[0][0]']    
                                                                                                  
 conv4_block18_2_bn (BatchNorma  (None, 14, 14, 256)  1024       ['conv4_block18_2_conv[0][0]']   
 lization)                                                                                        
                                                                                                  
 conv4_block18_2_relu (Activati  (None, 14, 14, 256)  0          ['conv4_block18_2_bn[0][0]']     
 on)                                                                                              
                                                                                                  
 conv4_block18_3_conv (Conv2D)  (None, 14, 14, 1024  263168      ['conv4_block18_2_relu[0][0]']   
                                )                                                                 
                                                                                                  
 conv4_block18_out (Add)        (None, 14, 14, 1024  0           ['conv4_block17_out[0][0]',      
                                )                                 'conv4_block18_3_conv[0][0]']   
                                                                                                  
 conv4_block19_preact_bn (Batch  (None, 14, 14, 1024  4096       ['conv4_block18_out[0][0]']      
 Normalization)                 )                                                                 
                                                                                                  
 conv4_block19_preact_relu (Act  (None, 14, 14, 1024  0          ['conv4_block19_preact_bn[0][0]']
 ivation)                       )                                                                 
                                                                                                  
 conv4_block19_1_conv (Conv2D)  (None, 14, 14, 256)  262144      ['conv4_block19_preact_relu[0][0]
                                                                 ']                               
                                                                                                  
 conv4_block19_1_bn (BatchNorma  (None, 14, 14, 256)  1024       ['conv4_block19_1_conv[0][0]']   
 lization)                                                                                        
                                                                                                  
 conv4_block19_1_relu (Activati  (None, 14, 14, 256)  0          ['conv4_block19_1_bn[0][0]']     
 on)                                                                                              
                                                                                                  
 conv4_block19_2_pad (ZeroPaddi  (None, 16, 16, 256)  0          ['conv4_block19_1_relu[0][0]']   
 ng2D)                                                                                            
                                                                                                  
 conv4_block19_2_conv (Conv2D)  (None, 14, 14, 256)  589824      ['conv4_block19_2_pad[0][0]']    
                                                                                                  
 conv4_block19_2_bn (BatchNorma  (None, 14, 14, 256)  1024       ['conv4_block19_2_conv[0][0]']   
 lization)                                                                                        
                                                                                                  
 conv4_block19_2_relu (Activati  (None, 14, 14, 256)  0          ['conv4_block19_2_bn[0][0]']     
 on)                                                                                              
                                                                                                  
 conv4_block19_3_conv (Conv2D)  (None, 14, 14, 1024  263168      ['conv4_block19_2_relu[0][0]']   
                                )                                                                 
                                                                                                  
 conv4_block19_out (Add)        (None, 14, 14, 1024  0           ['conv4_block18_out[0][0]',      
                                )                                 'conv4_block19_3_conv[0][0]']   
                                                                                                  
 conv4_block20_preact_bn (Batch  (None, 14, 14, 1024  4096       ['conv4_block19_out[0][0]']      
 Normalization)                 )                                                                 
                                                                                                  
 conv4_block20_preact_relu (Act  (None, 14, 14, 1024  0          ['conv4_block20_preact_bn[0][0]']
 ivation)                       )                                                                 
                                                                                                  
 conv4_block20_1_conv (Conv2D)  (None, 14, 14, 256)  262144      ['conv4_block20_preact_relu[0][0]
                                                                 ']                               
                                                                                                  
 conv4_block20_1_bn (BatchNorma  (None, 14, 14, 256)  1024       ['conv4_block20_1_conv[0][0]']   
 lization)                                                                                        
                                                                                                  
 conv4_block20_1_relu (Activati  (None, 14, 14, 256)  0          ['conv4_block20_1_bn[0][0]']     
 on)                                                                                              
                                                                                                  
 conv4_block20_2_pad (ZeroPaddi  (None, 16, 16, 256)  0          ['conv4_block20_1_relu[0][0]']   
 ng2D)                                                                                            
                                                                                                  
 conv4_block20_2_conv (Conv2D)  (None, 14, 14, 256)  589824      ['conv4_block20_2_pad[0][0]']    
                                                                                                  
 conv4_block20_2_bn (BatchNorma  (None, 14, 14, 256)  1024       ['conv4_block20_2_conv[0][0]']   
 lization)                                                                                        
                                                                                                  
 conv4_block20_2_relu (Activati  (None, 14, 14, 256)  0          ['conv4_block20_2_bn[0][0]']     
 on)                                                                                              
                                                                                                  
 conv4_block20_3_conv (Conv2D)  (None, 14, 14, 1024  263168      ['conv4_block20_2_relu[0][0]']   
                                )                                                                 
                                                                                                  
 conv4_block20_out (Add)        (None, 14, 14, 1024  0           ['conv4_block19_out[0][0]',      
                                )                                 'conv4_block20_3_conv[0][0]']   
                                                                                                  
 conv4_block21_preact_bn (Batch  (None, 14, 14, 1024  4096       ['conv4_block20_out[0][0]']      
 Normalization)                 )                                                                 
                                                                                                  
 conv4_block21_preact_relu (Act  (None, 14, 14, 1024  0          ['conv4_block21_preact_bn[0][0]']
 ivation)                       )                                                                 
                                                                                                  
 conv4_block21_1_conv (Conv2D)  (None, 14, 14, 256)  262144      ['conv4_block21_preact_relu[0][0]
                                                                 ']                               
                                                                                                  
 conv4_block21_1_bn (BatchNorma  (None, 14, 14, 256)  1024       ['conv4_block21_1_conv[0][0]']   
 lization)                                                                                        
                                                                                                  
 conv4_block21_1_relu (Activati  (None, 14, 14, 256)  0          ['conv4_block21_1_bn[0][0]']     
 on)                                                                                              
                                                                                                  
 conv4_block21_2_pad (ZeroPaddi  (None, 16, 16, 256)  0          ['conv4_block21_1_relu[0][0]']   
 ng2D)                                                                                            
                                                                                                  
 conv4_block21_2_conv (Conv2D)  (None, 14, 14, 256)  589824      ['conv4_block21_2_pad[0][0]']    
                                                                                                  
 conv4_block21_2_bn (BatchNorma  (None, 14, 14, 256)  1024       ['conv4_block21_2_conv[0][0]']   
 lization)                                                                                        
                                                                                                  
 conv4_block21_2_relu (Activati  (None, 14, 14, 256)  0          ['conv4_block21_2_bn[0][0]']     
 on)                                                                                              
                                                                                                  
 conv4_block21_3_conv (Conv2D)  (None, 14, 14, 1024  263168      ['conv4_block21_2_relu[0][0]']   
                                )                                                                 
                                                                                                  
 conv4_block21_out (Add)        (None, 14, 14, 1024  0           ['conv4_block20_out[0][0]',      
                                )                                 'conv4_block21_3_conv[0][0]']   
                                                                                                  
 conv4_block22_preact_bn (Batch  (None, 14, 14, 1024  4096       ['conv4_block21_out[0][0]']      
 Normalization)                 )                                                                 
                                                                                                  
 conv4_block22_preact_relu (Act  (None, 14, 14, 1024  0          ['conv4_block22_preact_bn[0][0]']
 ivation)                       )                                                                 
                                                                                                  
 conv4_block22_1_conv (Conv2D)  (None, 14, 14, 256)  262144      ['conv4_block22_preact_relu[0][0]
                                                                 ']                               
                                                                                                  
 conv4_block22_1_bn (BatchNorma  (None, 14, 14, 256)  1024       ['conv4_block22_1_conv[0][0]']   
 lization)                                                                                        
                                                                                                  
 conv4_block22_1_relu (Activati  (None, 14, 14, 256)  0          ['conv4_block22_1_bn[0][0]']     
 on)                                                                                              
                                                                                                  
 conv4_block22_2_pad (ZeroPaddi  (None, 16, 16, 256)  0          ['conv4_block22_1_relu[0][0]']   
 ng2D)                                                                                            
                                                                                                  
 conv4_block22_2_conv (Conv2D)  (None, 14, 14, 256)  589824      ['conv4_block22_2_pad[0][0]']    
                                                                                                  
 conv4_block22_2_bn (BatchNorma  (None, 14, 14, 256)  1024       ['conv4_block22_2_conv[0][0]']   
 lization)                                                                                        
                                                                                                  
 conv4_block22_2_relu (Activati  (None, 14, 14, 256)  0          ['conv4_block22_2_bn[0][0]']     
 on)                                                                                              
                                                                                                  
 conv4_block22_3_conv (Conv2D)  (None, 14, 14, 1024  263168      ['conv4_block22_2_relu[0][0]']   
                                )                                                                 
                                                                                                  
 conv4_block22_out (Add)        (None, 14, 14, 1024  0           ['conv4_block21_out[0][0]',      
                                )                                 'conv4_block22_3_conv[0][0]']   
                                                                                                  
 conv4_block23_preact_bn (Batch  (None, 14, 14, 1024  4096       ['conv4_block22_out[0][0]']      
 Normalization)                 )                                                                 
                                                                                                  
 conv4_block23_preact_relu (Act  (None, 14, 14, 1024  0          ['conv4_block23_preact_bn[0][0]']
 ivation)                       )                                                                 
                                                                                                  
 conv4_block23_1_conv (Conv2D)  (None, 14, 14, 256)  262144      ['conv4_block23_preact_relu[0][0]
                                                                 ']                               
                                                                                                  
 conv4_block23_1_bn (BatchNorma  (None, 14, 14, 256)  1024       ['conv4_block23_1_conv[0][0]']   
 lization)                                                                                        
                                                                                                  
 conv4_block23_1_relu (Activati  (None, 14, 14, 256)  0          ['conv4_block23_1_bn[0][0]']     
 on)                                                                                              
                                                                                                  
 conv4_block23_2_pad (ZeroPaddi  (None, 16, 16, 256)  0          ['conv4_block23_1_relu[0][0]']   
 ng2D)                                                                                            
                                                                                                  
 conv4_block23_2_conv (Conv2D)  (None, 7, 7, 256)    589824      ['conv4_block23_2_pad[0][0]']    
                                                                                                  
 conv4_block23_2_bn (BatchNorma  (None, 7, 7, 256)   1024        ['conv4_block23_2_conv[0][0]']   
 lization)                                                                                        
                                                                                                  
 conv4_block23_2_relu (Activati  (None, 7, 7, 256)   0           ['conv4_block23_2_bn[0][0]']     
 on)                                                                                              
                                                                                                  
 max_pooling2d_5 (MaxPooling2D)  (None, 7, 7, 1024)  0           ['conv4_block22_out[0][0]']      
                                                                                                  
 conv4_block23_3_conv (Conv2D)  (None, 7, 7, 1024)   263168      ['conv4_block23_2_relu[0][0]']   
                                                                                                  
 conv4_block23_out (Add)        (None, 7, 7, 1024)   0           ['max_pooling2d_5[0][0]',        
                                                                  'conv4_block23_3_conv[0][0]']   
                                                                                                  
 conv5_block1_preact_bn (BatchN  (None, 7, 7, 1024)  4096        ['conv4_block23_out[0][0]']      
 ormalization)                                                                                    
                                                                                                  
 conv5_block1_preact_relu (Acti  (None, 7, 7, 1024)  0           ['conv5_block1_preact_bn[0][0]'] 
 vation)                                                                                          
                                                                                                  
 conv5_block1_1_conv (Conv2D)   (None, 7, 7, 512)    524288      ['conv5_block1_preact_relu[0][0]'
                                                                 ]                                
                                                                                                  
 conv5_block1_1_bn (BatchNormal  (None, 7, 7, 512)   2048        ['conv5_block1_1_conv[0][0]']    
 ization)                                                                                         
                                                                                                  
 conv5_block1_1_relu (Activatio  (None, 7, 7, 512)   0           ['conv5_block1_1_bn[0][0]']      
 n)                                                                                               
                                                                                                  
 conv5_block1_2_pad (ZeroPaddin  (None, 9, 9, 512)   0           ['conv5_block1_1_relu[0][0]']    
 g2D)                                                                                             
                                                                                                  
 conv5_block1_2_conv (Conv2D)   (None, 7, 7, 512)    2359296     ['conv5_block1_2_pad[0][0]']     
                                                                                                  
 conv5_block1_2_bn (BatchNormal  (None, 7, 7, 512)   2048        ['conv5_block1_2_conv[0][0]']    
 ization)                                                                                         
                                                                                                  
 conv5_block1_2_relu (Activatio  (None, 7, 7, 512)   0           ['conv5_block1_2_bn[0][0]']      
 n)                                                                                               
                                                                                                  
 conv5_block1_0_conv (Conv2D)   (None, 7, 7, 2048)   2099200     ['conv5_block1_preact_relu[0][0]'
                                                                 ]                                
                                                                                                  
 conv5_block1_3_conv (Conv2D)   (None, 7, 7, 2048)   1050624     ['conv5_block1_2_relu[0][0]']    
                                                                                                  
 conv5_block1_out (Add)         (None, 7, 7, 2048)   0           ['conv5_block1_0_conv[0][0]',    
                                                                  'conv5_block1_3_conv[0][0]']    
                                                                                                  
 conv5_block2_preact_bn (BatchN  (None, 7, 7, 2048)  8192        ['conv5_block1_out[0][0]']       
 ormalization)                                                                                    
                                                                                                  
 conv5_block2_preact_relu (Acti  (None, 7, 7, 2048)  0           ['conv5_block2_preact_bn[0][0]'] 
 vation)                                                                                          
                                                                                                  
 conv5_block2_1_conv (Conv2D)   (None, 7, 7, 512)    1048576     ['conv5_block2_preact_relu[0][0]'
                                                                 ]                                
                                                                                                  
 conv5_block2_1_bn (BatchNormal  (None, 7, 7, 512)   2048        ['conv5_block2_1_conv[0][0]']    
 ization)                                                                                         
                                                                                                  
 conv5_block2_1_relu (Activatio  (None, 7, 7, 512)   0           ['conv5_block2_1_bn[0][0]']      
 n)                                                                                               
                                                                                                  
 conv5_block2_2_pad (ZeroPaddin  (None, 9, 9, 512)   0           ['conv5_block2_1_relu[0][0]']    
 g2D)                                                                                             
                                                                                                  
 conv5_block2_2_conv (Conv2D)   (None, 7, 7, 512)    2359296     ['conv5_block2_2_pad[0][0]']     
                                                                                                  
 conv5_block2_2_bn (BatchNormal  (None, 7, 7, 512)   2048        ['conv5_block2_2_conv[0][0]']    
 ization)                                                                                         
                                                                                                  
 conv5_block2_2_relu (Activatio  (None, 7, 7, 512)   0           ['conv5_block2_2_bn[0][0]']      
 n)                                                                                               
                                                                                                  
 conv5_block2_3_conv (Conv2D)   (None, 7, 7, 2048)   1050624     ['conv5_block2_2_relu[0][0]']    
                                                                                                  
 conv5_block2_out (Add)         (None, 7, 7, 2048)   0           ['conv5_block1_out[0][0]',       
                                                                  'conv5_block2_3_conv[0][0]']    
                                                                                                  
 conv5_block3_preact_bn (BatchN  (None, 7, 7, 2048)  8192        ['conv5_block2_out[0][0]']       
 ormalization)                                                                                    
                                                                                                  
 conv5_block3_preact_relu (Acti  (None, 7, 7, 2048)  0           ['conv5_block3_preact_bn[0][0]'] 
 vation)                                                                                          
                                                                                                  
 conv5_block3_1_conv (Conv2D)   (None, 7, 7, 512)    1048576     ['conv5_block3_preact_relu[0][0]'
                                                                 ]                                
                                                                                                  
 conv5_block3_1_bn (BatchNormal  (None, 7, 7, 512)   2048        ['conv5_block3_1_conv[0][0]']    
 ization)                                                                                         
                                                                                                  
 conv5_block3_1_relu (Activatio  (None, 7, 7, 512)   0           ['conv5_block3_1_bn[0][0]']      
 n)                                                                                               
                                                                                                  
 conv5_block3_2_pad (ZeroPaddin  (None, 9, 9, 512)   0           ['conv5_block3_1_relu[0][0]']    
 g2D)                                                                                             
                                                                                                  
 conv5_block3_2_conv (Conv2D)   (None, 7, 7, 512)    2359296     ['conv5_block3_2_pad[0][0]']     
                                                                                                  
 conv5_block3_2_bn (BatchNormal  (None, 7, 7, 512)   2048        ['conv5_block3_2_conv[0][0]']    
 ization)                                                                                         
                                                                                                  
 conv5_block3_2_relu (Activatio  (None, 7, 7, 512)   0           ['conv5_block3_2_bn[0][0]']      
 n)                                                                                               
                                                                                                  
 conv5_block3_3_conv (Conv2D)   (None, 7, 7, 2048)   1050624     ['conv5_block3_2_relu[0][0]']    
                                                                                                  
 conv5_block3_out (Add)         (None, 7, 7, 2048)   0           ['conv5_block2_out[0][0]',       
                                                                  'conv5_block3_3_conv[0][0]']    
                                                                                                  
 post_bn (BatchNormalization)   (None, 7, 7, 2048)   8192        ['conv5_block3_out[0][0]']       
                                                                                                  
 post_relu (Activation)         (None, 7, 7, 2048)   0           ['post_bn[0][0]']                
                                                                                                  
 flatten_4 (Flatten)            (None, 100352)       0           ['post_relu[0][0]']              
                                                                                                  
 dense_4 (Dense)                (None, 5)            501765      ['flatten_4[0][0]']              
                                                                                                  
==================================================================================================
Total params: 43,128,325
Trainable params: 501,765
Non-trainable params: 42,626,560
__________________________________________________________________________________________________
# tell the model what cost and optimization method to use
model.compile(
  loss='sparse_categorical_crossentropy',
  optimizer='adam',
  metrics=['accuracy']
)

#train_ds_vgg_sw, test_ds_vgg_sw, validation_ds_vgg_sw
# fit the model
r = model.fit_generator(
  train_ds,
  validation_data=validation_ds,
  epochs=25,
  steps_per_epoch=len(train_ds),
  validation_steps=len(validation_ds)
)
Epoch 1/25
/var/folders/3r/c8tg1h051m18qhsdccdysrt40000gn/T/ipykernel_11345/3602206220.py:10: UserWarning: `Model.fit_generator` is deprecated and will be removed in a future version. Please use `Model.fit`, which supports generators.
  r = model.fit_generator(
25/25 [==============================] - 59s 2s/step - loss: 3.6952 - accuracy: 0.7675 - val_loss: 1.0397 - val_accuracy: 0.9427
Epoch 2/25
25/25 [==============================] - 55s 2s/step - loss: 0.2606 - accuracy: 0.9688 - val_loss: 0.6033 - val_accuracy: 0.9479
Epoch 3/25
25/25 [==============================] - 55s 2s/step - loss: 0.0624 - accuracy: 0.9887 - val_loss: 0.7021 - val_accuracy: 0.9323
Epoch 4/25
25/25 [==============================] - 55s 2s/step - loss: 0.0150 - accuracy: 0.9987 - val_loss: 0.4405 - val_accuracy: 0.9688
Epoch 5/25
25/25 [==============================] - 56s 2s/step - loss: 0.0123 - accuracy: 0.9975 - val_loss: 0.3344 - val_accuracy: 0.9740
Epoch 6/25
25/25 [==============================] - 56s 2s/step - loss: 1.9117e-07 - accuracy: 1.0000 - val_loss: 0.1343 - val_accuracy: 0.9844
Epoch 7/25
25/25 [==============================] - 56s 2s/step - loss: 4.4405e-08 - accuracy: 1.0000 - val_loss: 0.2787 - val_accuracy: 0.9844
Epoch 8/25
25/25 [==============================] - 56s 2s/step - loss: 3.5911e-08 - accuracy: 1.0000 - val_loss: 0.2785 - val_accuracy: 0.9844
Epoch 9/25
25/25 [==============================] - 57s 2s/step - loss: 2.7716e-08 - accuracy: 1.0000 - val_loss: 0.2785 - val_accuracy: 0.9844
Epoch 10/25
25/25 [==============================] - 57s 2s/step - loss: 2.2948e-08 - accuracy: 1.0000 - val_loss: 0.1292 - val_accuracy: 0.9896
Epoch 11/25
25/25 [==============================] - 57s 2s/step - loss: 2.0563e-08 - accuracy: 1.0000 - val_loss: 0.2785 - val_accuracy: 0.9844
Epoch 12/25
25/25 [==============================] - 57s 2s/step - loss: 1.7583e-08 - accuracy: 1.0000 - val_loss: 0.2785 - val_accuracy: 0.9844
Epoch 13/25
25/25 [==============================] - 60s 2s/step - loss: 1.5646e-08 - accuracy: 1.0000 - val_loss: 0.2775 - val_accuracy: 0.9844
Epoch 14/25
25/25 [==============================] - 57s 2s/step - loss: 1.4305e-08 - accuracy: 1.0000 - val_loss: 0.1950 - val_accuracy: 0.9896
Epoch 15/25
25/25 [==============================] - 57s 2s/step - loss: 1.3560e-08 - accuracy: 1.0000 - val_loss: 0.2785 - val_accuracy: 0.9844
Epoch 16/25
25/25 [==============================] - 57s 2s/step - loss: 1.1921e-08 - accuracy: 1.0000 - val_loss: 0.2785 - val_accuracy: 0.9844
Epoch 17/25
25/25 [==============================] - 57s 2s/step - loss: 1.1176e-08 - accuracy: 1.0000 - val_loss: 0.1318 - val_accuracy: 0.9896
Epoch 18/25
25/25 [==============================] - 59s 2s/step - loss: 1.0431e-08 - accuracy: 1.0000 - val_loss: 0.2776 - val_accuracy: 0.9844
Epoch 19/25
25/25 [==============================] - 58s 2s/step - loss: 9.8347e-09 - accuracy: 1.0000 - val_loss: 0.2785 - val_accuracy: 0.9844
Epoch 20/25
25/25 [==============================] - 58s 2s/step - loss: 9.2387e-09 - accuracy: 1.0000 - val_loss: 0.2775 - val_accuracy: 0.9844
Epoch 21/25
25/25 [==============================] - 60s 2s/step - loss: 8.7917e-09 - accuracy: 1.0000 - val_loss: 0.2785 - val_accuracy: 0.9844
Epoch 22/25
25/25 [==============================] - 58s 2s/step - loss: 8.3446e-09 - accuracy: 1.0000 - val_loss: 0.2785 - val_accuracy: 0.9844
Epoch 23/25
25/25 [==============================] - 57s 2s/step - loss: 5.5134e-09 - accuracy: 1.0000 - val_loss: 0.2785 - val_accuracy: 0.9844
Epoch 24/25
25/25 [==============================] - 56s 2s/step - loss: 7.5996e-09 - accuracy: 1.0000 - val_loss: 0.2785 - val_accuracy: 0.9844
Epoch 25/25
25/25 [==============================] - 57s 2s/step - loss: 7.3016e-09 - accuracy: 1.0000 - val_loss: 0.2785 - val_accuracy: 0.9844
# loss
plt.plot(r.history["accuracy"])
plt.plot(r.history['val_accuracy'])
plt.plot(r.history['loss'])
plt.plot(r.history['val_loss'])
plt.title("Model accuracy")
plt.ylabel("Value")
plt.xlabel("Epoch")
plt.legend(["Accuracy","Validation Accuracy","Loss","Validation Loss"])
plt.show()

model.save('resnet_1.h5')
model.evaluate(test_ds)
8/8 [==============================] - 15s 2s/step - loss: 0.7370 - accuracy: 0.9414
[0.7369823455810547, 0.94140625]