>- ** 本文为[365天深度学习训练营]中的学习记录博客**
>- ** 原作者:[K同学啊]**

本周任务:
●1.请根据本文 Pytorch 代码,编写出相应的 TensorFlow 代码(建议使用上周的数据测试一下模型是否构建正确)
●2.了解并研究 DenseNet与ResNetV 的区别
●3.改进思路是否可以迁移到其他地方呢(自由探索,虽然不强求但是请认真对待这个哦)

我的环境:

  • 语言环境:Python3.11.7
  • 编译器:jupyter notebook
  • 深度学习框架:TensorFlow2.13.0

       本文完全根据 第J3周:DenseNet算法实战与解析(pytorch版)中的内容转换为TensorFlow,所以前述性的内容不在一一重复,仅就TensorFlow的内容进行叙述。

一、前期工作 

1、设置CPU(也可以是GPU)

import tensorflow as tf
gpus=tf.config.list_physical_devices("GPU")

if gpus:
    tf.config.experimental.set_memory_growth(gpus[0],True)
    tf.config.set_visible_devices([gpus[0]],"GPU")

2、导入数据

import pathlib

data_dir=r'D:\THE MNIST DATABASE\J-series\J1\bird_photos'
data_dir=pathlib.Path(data_dir)

3、查看数据

image_count=len(list(data_dir.glob('*/*')))
print("图片总数为:",image_count)

运行结果:

图片总数为: 565

二、数据预处理

1、加载数据

加载训练集:

train_ds=tf.keras.preprocessing.image_dataset_from_directory(
    data_dir,
    validation_split=0.2,
    subset="training",
    seed=123,
    image_size=(224,224),
    batch_size=8
)

运行结果:

Found 565 files belonging to 4 classes.
Using 452 files for training.
val_ds=tf.keras.preprocessing.image_dataset_from_directory(
    data_dir,
    validation_split=0.2,
    subset="validation",
    seed=123,
    image_size=(224,224),
    batch_size=8
)
val_ds=tf.keras.preprocessing.image_datas

 加载验证集:

val_ds=tf.keras.preprocessing.image_dataset_from_directory(
    data_dir,
    validation_split=0.2,
    subset="validation",
    seed=123,
    image_size=(224,224),
    batch_size=8
)

运行结果:

ound 565 files belonging to 4 classes.
Using 113 files for validation.

 查看分类名称

classNames=train_ds.class_names
print(classNames)

运行结果:

['Bananaquit', 'Black Skimmer', 'Black Throated Bushtiti', 'Cockatoo']

2、可视化数据

import matplotlib.pyplot as plt
plt.rcParams['font.sans-serif']=['SimHei'] #正常显示中文标签
plt.rcParams['axes.unicode_minus']=False #正常显示负号

plt.figure(figsize=(10,5))
plt.suptitle("OreoCC的案例")

for images,labels in train_ds.take(1):
    for i in range(8):
        
        ax=plt.subplot(2,4,i+1)
        
        plt.imshow(images[i].numpy().astype("uint8"))
        plt.title(classNames[labels[i]])
        
        plt.axis("off")

运行结果:


单独查看其中一张图片

plt.imshow(images[1].numpy().astype("uint8"))

 运行结果:

3、再次检查数据

for image_batch,labels_batch in train_ds:
    print(image_batch.shape)
    print(labels_batch.shape)
    break

运行结果:

(8, 224, 224, 3)
(8,)

image_batch是形状的张量(8,224,224,3)。这是一批形状224*224*4的8张图片(最后一维指的是彩色通道RGB)

labels_batch是形状(8,)的张量,这些标签对应8张图片。

4、配置数据集

shuffle() : 打乱数据,关于此函数的详细介绍可以参考:https://zhuanlan.zhihu.com/p/42417456
prefetch() :预取数据,加速运行,其详细介绍可以参考前面文章,里面都有讲解。
cache() :将数据集缓存到内存当中,加速运行

AUTOTUNE=tf.data.AUTOTUNE

train_ds=train_ds.cache().shuffle(1000).prefetch(buffer_size=AUTOTUNE)
val_ds=val_ds.cache().prefetch(buffer_size=AUTOTUNE)

三、构建DenseNet网络模型

1、搭建DenseLayer

from tensorflow import keras
from keras.layers import Input,Activation,BatchNormalization,Flatten
from keras.layers import Dense,Conv2D,MaxPooling2D,ZeroPadding2D,AveragePooling2D
from keras.models import Model

#DenseLayer
def DenseLayer(x,growth_rate):
    f=BatchNormalization()(x)
    f=Activation('relu')(f)
    f=Conv2D(4*growth_rate,kernel_size=1,strides=1,padding='same',use_bias=False)(f)
    
    f=BatchNormalization()(f)
    f=Activation('relu')(f)
    f=Conv2D(growth_rate,kernel_size=3,strides=1,padding='same',use_bias=False)(f)
    
    return layers.Concatenate(axis=3)([x,f])

2、搭建DenseBlock模块

#DenseBlock
def DenseBlock(x,block,growth_rate=32):
    for i in range(block):
        x=DenseLayer(x,growth_rate)
    return x

3、搭建TransitionBlock模块

#Transition
k=keras.backend
def Transition(x,theta):
    f=BatchNormalization()(x)
    f=Activation('relu')(f)
    f=Conv2D(int(k.int_shape(x)[3]*theta),kernel_size=1,strides=1,use_bias=False)(f)
    f=AveragePooling2D(pool_size=(2,2),strides=2,padding='valid')(f)
    return f

4、搭建DenseNet网络模型

#DenseNet
def DenseNet(input_shape,block,num_classes=4):
    #56*56*64
    img_input=Input(shape=input_shape)
    x=Conv2D(64,kernel_size=(7,7),strides=2,padding='same',use_bias=False)(img_input)
    x=BatchNormalization()(x)
    x=MaxPooling2D(pool_size=3,strides=2,padding='same')(x)
    x=DenseBlock(x,block[0])
    x=Transition(x,0.5) #28*28
    x=DenseBlock(x,block[1])
    x=Transition(x,0.5) #14*14
    x=DenseBlock(x,block[2])
    x=Transition(x,0.5) #7*7
    x=DenseBlock(x,block[3])
    x=BatchNormalization()(x)
    x=Activation('relu')(x)
    x=GlobalAveragePooling2D()(x)
    outputs=Dense(num_classes,activation='softmax')(x)
    model=Model(inputs=[img_input],outputs=[outputs])
    return model

5、建立DenseNet-121模型

model_121=DenseNet([224,224,3],[6,12,24,16])  #DenseNet-121
model_169=DenseNet([224,224,3],[6,12,32,32])  #DenseNet-169
model_201=DenseNet([224,224,3],[6,12,48,32])  #DenseNet-201
model_269=DenseNet([224,224,3],[6,12,64,48])  #DenseNet-269
model=model_121
model.summary()

查看模型结构:

Model: "model_4"
__________________________________________________________________________________________________
 Layer (type)                Output Shape                 Param #   Connected to                  
==================================================================================================
 input_12 (InputLayer)       [(None, 224, 224, 3)]        0         []                            
                                                                                                  
 conv2d_1112 (Conv2D)        (None, 112, 112, 64)         9408      ['input_12[0][0]']            
                                                                                                  
 batch_normalization_1118 (  (None, 112, 112, 64)         256       ['conv2d_1112[0][0]']         
 BatchNormalization)                                                                              
                                                                                                  
 max_pooling2d_7 (MaxPoolin  (None, 56, 56, 64)           0         ['batch_normalization_1118[0][
 g2D)                                                               0]']                          
                                                                                                  
 batch_normalization_1119 (  (None, 56, 56, 64)           256       ['max_pooling2d_7[0][0]']     
 BatchNormalization)                                                                              
                                                                                                  
 activation_1112 (Activatio  (None, 56, 56, 64)           0         ['batch_normalization_1119[0][
 n)                                                                 0]']                          
                                                                                                  
 conv2d_1113 (Conv2D)        (None, 56, 56, 128)          8192      ['activation_1112[0][0]']     
                                                                                                  
 batch_normalization_1120 (  (None, 56, 56, 128)          512       ['conv2d_1113[0][0]']         
 BatchNormalization)                                                                              
                                                                                                  
 activation_1113 (Activatio  (None, 56, 56, 128)          0         ['batch_normalization_1120[0][
 n)                                                                 0]']                          
                                                                                                  
 conv2d_1114 (Conv2D)        (None, 56, 56, 32)           36864     ['activation_1113[0][0]']     
                                                                                                  
 concatenate_484 (Concatena  (None, 56, 56, 96)           0         ['max_pooling2d_7[0][0]',     
 te)                                                                 'conv2d_1114[0][0]']         
                                                                                                  
 batch_normalization_1121 (  (None, 56, 56, 96)           384       ['concatenate_484[0][0]']     
 BatchNormalization)                                                                              
                                                                                                  
 activation_1114 (Activatio  (None, 56, 56, 96)           0         ['batch_normalization_1121[0][
 n)                                                                 0]']                          
                                                                                                  
 conv2d_1115 (Conv2D)        (None, 56, 56, 128)          12288     ['activation_1114[0][0]']     
                                                                                                  
 batch_normalization_1122 (  (None, 56, 56, 128)          512       ['conv2d_1115[0][0]']         
 BatchNormalization)                                                                              
                                                                                                  
 activation_1115 (Activatio  (None, 56, 56, 128)          0         ['batch_normalization_1122[0][
 n)                                                                 0]']                          
                                                                                                  
 conv2d_1116 (Conv2D)        (None, 56, 56, 32)           36864     ['activation_1115[0][0]']     
                                                                                                  
 concatenate_485 (Concatena  (None, 56, 56, 128)          0         ['concatenate_484[0][0]',     
 te)                                                                 'conv2d_1116[0][0]']         
                                                                                                  
 batch_normalization_1123 (  (None, 56, 56, 128)          512       ['concatenate_485[0][0]']     
 BatchNormalization)                                                                              
                                                                                                  
 activation_1116 (Activatio  (None, 56, 56, 128)          0         ['batch_normalization_1123[0][
 n)                                                                 0]']                          
                                                                                                  
 conv2d_1117 (Conv2D)        (None, 56, 56, 128)          16384     ['activation_1116[0][0]']     
                                                                                                  
 batch_normalization_1124 (  (None, 56, 56, 128)          512       ['conv2d_1117[0][0]']         
 BatchNormalization)                                                                              
                                                                                                  
 activation_1117 (Activatio  (None, 56, 56, 128)          0         ['batch_normalization_1124[0][
 n)                                                                 0]']                          
                                                                                                  
 conv2d_1118 (Conv2D)        (None, 56, 56, 32)           36864     ['activation_1117[0][0]']     
                                                                                                  
 concatenate_486 (Concatena  (None, 56, 56, 160)          0         ['concatenate_485[0][0]',     
 te)                                                                 'conv2d_1118[0][0]']         
                                                                                                  
 batch_normalization_1125 (  (None, 56, 56, 160)          640       ['concatenate_486[0][0]']     
 BatchNormalization)                                                                              
                                                                                                  
 activation_1118 (Activatio  (None, 56, 56, 160)          0         ['batch_normalization_1125[0][
 n)                                                                 0]']                          
                                                                                                  
 conv2d_1119 (Conv2D)        (None, 56, 56, 128)          20480     ['activation_1118[0][0]']     
                                                                                                  
 batch_normalization_1126 (  (None, 56, 56, 128)          512       ['conv2d_1119[0][0]']         
 BatchNormalization)                                                                              
                                                                                                  
 activation_1119 (Activatio  (None, 56, 56, 128)          0         ['batch_normalization_1126[0][
 n)                                                                 0]']                          
                                                                                                  
 conv2d_1120 (Conv2D)        (None, 56, 56, 32)           36864     ['activation_1119[0][0]']     
                                                                                                  
 concatenate_487 (Concatena  (None, 56, 56, 192)          0         ['concatenate_486[0][0]',     
 te)                                                                 'conv2d_1120[0][0]']         
                                                                                                  
 batch_normalization_1127 (  (None, 56, 56, 192)          768       ['concatenate_487[0][0]']     
 BatchNormalization)                                                                              
                                                                                                  
 activation_1120 (Activatio  (None, 56, 56, 192)          0         ['batch_normalization_1127[0][
 n)                                                                 0]']                          
                                                                                                  
 conv2d_1121 (Conv2D)        (None, 56, 56, 128)          24576     ['activation_1120[0][0]']     
                                                                                                  
 batch_normalization_1128 (  (None, 56, 56, 128)          512       ['conv2d_1121[0][0]']         
 BatchNormalization)                                                                              
                                                                                                  
 activation_1121 (Activatio  (None, 56, 56, 128)          0         ['batch_normalization_1128[0][
 n)                                                                 0]']                          
                                                                                                  
 conv2d_1122 (Conv2D)        (None, 56, 56, 32)           36864     ['activation_1121[0][0]']     
                                                                                                  
 concatenate_488 (Concatena  (None, 56, 56, 224)          0         ['concatenate_487[0][0]',     
 te)                                                                 'conv2d_1122[0][0]']         
                                                                                                  
 batch_normalization_1129 (  (None, 56, 56, 224)          896       ['concatenate_488[0][0]']     
 BatchNormalization)                                                                              
                                                                                                  
 activation_1122 (Activatio  (None, 56, 56, 224)          0         ['batch_normalization_1129[0][
 n)                                                                 0]']                          
                                                                                                  
 conv2d_1123 (Conv2D)        (None, 56, 56, 128)          28672     ['activation_1122[0][0]']     
                                                                                                  
 batch_normalization_1130 (  (None, 56, 56, 128)          512       ['conv2d_1123[0][0]']         
 BatchNormalization)                                                                              
                                                                                                  
 activation_1123 (Activatio  (None, 56, 56, 128)          0         ['batch_normalization_1130[0][
 n)                                                                 0]']                          
                                                                                                  
 conv2d_1124 (Conv2D)        (None, 56, 56, 32)           36864     ['activation_1123[0][0]']     
                                                                                                  
 concatenate_489 (Concatena  (None, 56, 56, 256)          0         ['concatenate_488[0][0]',     
 te)                                                                 'conv2d_1124[0][0]']         
                                                                                                  
 batch_normalization_1131 (  (None, 56, 56, 256)          1024      ['concatenate_489[0][0]']     
 BatchNormalization)                                                                              
                                                                                                  
 activation_1124 (Activatio  (None, 56, 56, 256)          0         ['batch_normalization_1131[0][
 n)                                                                 0]']                          
                                                                                                  
 conv2d_1125 (Conv2D)        (None, 56, 56, 128)          32768     ['activation_1124[0][0]']     
                                                                                                  
 average_pooling2d_21 (Aver  (None, 28, 28, 128)          0         ['conv2d_1125[0][0]']         
 agePooling2D)                                                                                    
                                                                                                  
 batch_normalization_1132 (  (None, 28, 28, 128)          512       ['average_pooling2d_21[0][0]']
 BatchNormalization)                                                                              
                                                                                                  
 activation_1125 (Activatio  (None, 28, 28, 128)          0         ['batch_normalization_1132[0][
 n)                                                                 0]']                          
                                                                                                  
 conv2d_1126 (Conv2D)        (None, 28, 28, 128)          16384     ['activation_1125[0][0]']     
                                                                                                  
 batch_normalization_1133 (  (None, 28, 28, 128)          512       ['conv2d_1126[0][0]']         
 BatchNormalization)                                                                              
                                                                                                  
 activation_1126 (Activatio  (None, 28, 28, 128)          0         ['batch_normalization_1133[0][
 n)                                                                 0]']                          
                                                                                                  
 conv2d_1127 (Conv2D)        (None, 28, 28, 32)           36864     ['activation_1126[0][0]']     
                                                                                                  
 concatenate_490 (Concatena  (None, 28, 28, 160)          0         ['average_pooling2d_21[0][0]',
 te)                                                                 'conv2d_1127[0][0]']         
                                                                                                  
 batch_normalization_1134 (  (None, 28, 28, 160)          640       ['concatenate_490[0][0]']     
 BatchNormalization)                                                                              
                                                                                                  
 activation_1127 (Activatio  (None, 28, 28, 160)          0         ['batch_normalization_1134[0][
 n)                                                                 0]']                          
                                                                                                  
 conv2d_1128 (Conv2D)        (None, 28, 28, 128)          20480     ['activation_1127[0][0]']     
                                                                                                  
 batch_normalization_1135 (  (None, 28, 28, 128)          512       ['conv2d_1128[0][0]']         
 BatchNormalization)                                                                              
                                                                                                  
 activation_1128 (Activatio  (None, 28, 28, 128)          0         ['batch_normalization_1135[0][
 n)                                                                 0]']                          
                                                                                                  
 conv2d_1129 (Conv2D)        (None, 28, 28, 32)           36864     ['activation_1128[0][0]']     
                                                                                                  
 concatenate_491 (Concatena  (None, 28, 28, 192)          0         ['concatenate_490[0][0]',     
 te)                                                                 'conv2d_1129[0][0]']         
                                                                                                  
 batch_normalization_1136 (  (None, 28, 28, 192)          768       ['concatenate_491[0][0]']     
 BatchNormalization)                                                                              
                                                                                                  
 activation_1129 (Activatio  (None, 28, 28, 192)          0         ['batch_normalization_1136[0][
 n)                                                                 0]']                          
                                                                                                  
 conv2d_1130 (Conv2D)        (None, 28, 28, 128)          24576     ['activation_1129[0][0]']     
                                                                                                  
 batch_normalization_1137 (  (None, 28, 28, 128)          512       ['conv2d_1130[0][0]']         
 BatchNormalization)                                                                              
                                                                                                  
 activation_1130 (Activatio  (None, 28, 28, 128)          0         ['batch_normalization_1137[0][
 n)                                                                 0]']                          
                                                                                                  
 conv2d_1131 (Conv2D)        (None, 28, 28, 32)           36864     ['activation_1130[0][0]']     
                                                                                                  
 concatenate_492 (Concatena  (None, 28, 28, 224)          0         ['concatenate_491[0][0]',     
 te)                                                                 'conv2d_1131[0][0]']         
                                                                                                  
 batch_normalization_1138 (  (None, 28, 28, 224)          896       ['concatenate_492[0][0]']     
 BatchNormalization)                                                                              
                                                                                                  
 activation_1131 (Activatio  (None, 28, 28, 224)          0         ['batch_normalization_1138[0][
 n)                                                                 0]']                          
                                                                                                  
 conv2d_1132 (Conv2D)        (None, 28, 28, 128)          28672     ['activation_1131[0][0]']     
                                                                                                  
 batch_normalization_1139 (  (None, 28, 28, 128)          512       ['conv2d_1132[0][0]']         
 BatchNormalization)                                                                              
                                                                                                  
 activation_1132 (Activatio  (None, 28, 28, 128)          0         ['batch_normalization_1139[0][
 n)                                                                 0]']                          
                                                                                                  
 conv2d_1133 (Conv2D)        (None, 28, 28, 32)           36864     ['activation_1132[0][0]']     
                                                                                                  
 concatenate_493 (Concatena  (None, 28, 28, 256)          0         ['concatenate_492[0][0]',     
 te)                                                                 'conv2d_1133[0][0]']         
                                                                                                  
 batch_normalization_1140 (  (None, 28, 28, 256)          1024      ['concatenate_493[0][0]']     
 BatchNormalization)                                                                              
                                                                                                  
 activation_1133 (Activatio  (None, 28, 28, 256)          0         ['batch_normalization_1140[0][
 n)                                                                 0]']                          
                                                                                                  
 conv2d_1134 (Conv2D)        (None, 28, 28, 128)          32768     ['activation_1133[0][0]']     
                                                                                                  
 batch_normalization_1141 (  (None, 28, 28, 128)          512       ['conv2d_1134[0][0]']         
 BatchNormalization)                                                                              
                                                                                                  
 activation_1134 (Activatio  (None, 28, 28, 128)          0         ['batch_normalization_1141[0][
 n)                                                                 0]']                          
                                                                                                  
 conv2d_1135 (Conv2D)        (None, 28, 28, 32)           36864     ['activation_1134[0][0]']     
                                                                                                  
 concatenate_494 (Concatena  (None, 28, 28, 288)          0         ['concatenate_493[0][0]',     
 te)                                                                 'conv2d_1135[0][0]']         
                                                                                                  
 batch_normalization_1142 (  (None, 28, 28, 288)          1152      ['concatenate_494[0][0]']     
 BatchNormalization)                                                                              
                                                                                                  
 activation_1135 (Activatio  (None, 28, 28, 288)          0         ['batch_normalization_1142[0][
 n)                                                                 0]']                          
                                                                                                  
 conv2d_1136 (Conv2D)        (None, 28, 28, 128)          36864     ['activation_1135[0][0]']     
                                                                                                  
 batch_normalization_1143 (  (None, 28, 28, 128)          512       ['conv2d_1136[0][0]']         
 BatchNormalization)                                                                              
                                                                                                  
 activation_1136 (Activatio  (None, 28, 28, 128)          0         ['batch_normalization_1143[0][
 n)                                                                 0]']                          
                                                                                                  
 conv2d_1137 (Conv2D)        (None, 28, 28, 32)           36864     ['activation_1136[0][0]']     
                                                                                                  
 concatenate_495 (Concatena  (None, 28, 28, 320)          0         ['concatenate_494[0][0]',     
 te)                                                                 'conv2d_1137[0][0]']         
                                                                                                  
 batch_normalization_1144 (  (None, 28, 28, 320)          1280      ['concatenate_495[0][0]']     
 BatchNormalization)                                                                              
                                                                                                  
 activation_1137 (Activatio  (None, 28, 28, 320)          0         ['batch_normalization_1144[0][
 n)                                                                 0]']                          
                                                                                                  
 conv2d_1138 (Conv2D)        (None, 28, 28, 128)          40960     ['activation_1137[0][0]']     
                                                                                                  
 batch_normalization_1145 (  (None, 28, 28, 128)          512       ['conv2d_1138[0][0]']         
 BatchNormalization)                                                                              
                                                                                                  
 activation_1138 (Activatio  (None, 28, 28, 128)          0         ['batch_normalization_1145[0][
 n)                                                                 0]']                          
                                                                                                  
 conv2d_1139 (Conv2D)        (None, 28, 28, 32)           36864     ['activation_1138[0][0]']     
                                                                                                  
 concatenate_496 (Concatena  (None, 28, 28, 352)          0         ['concatenate_495[0][0]',     
 te)                                                                 'conv2d_1139[0][0]']         
                                                                                                  
 batch_normalization_1146 (  (None, 28, 28, 352)          1408      ['concatenate_496[0][0]']     
 BatchNormalization)                                                                              
                                                                                                  
 activation_1139 (Activatio  (None, 28, 28, 352)          0         ['batch_normalization_1146[0][
 n)                                                                 0]']                          
                                                                                                  
 conv2d_1140 (Conv2D)        (None, 28, 28, 128)          45056     ['activation_1139[0][0]']     
                                                                                                  
 batch_normalization_1147 (  (None, 28, 28, 128)          512       ['conv2d_1140[0][0]']         
 BatchNormalization)                                                                              
                                                                                                  
 activation_1140 (Activatio  (None, 28, 28, 128)          0         ['batch_normalization_1147[0][
 n)                                                                 0]']                          
                                                                                                  
 conv2d_1141 (Conv2D)        (None, 28, 28, 32)           36864     ['activation_1140[0][0]']     
                                                                                                  
 concatenate_497 (Concatena  (None, 28, 28, 384)          0         ['concatenate_496[0][0]',     
 te)                                                                 'conv2d_1141[0][0]']         
                                                                                                  
 batch_normalization_1148 (  (None, 28, 28, 384)          1536      ['concatenate_497[0][0]']     
 BatchNormalization)                                                                              
                                                                                                  
 activation_1141 (Activatio  (None, 28, 28, 384)          0         ['batch_normalization_1148[0][
 n)                                                                 0]']                          
                                                                                                  
 conv2d_1142 (Conv2D)        (None, 28, 28, 128)          49152     ['activation_1141[0][0]']     
                                                                                                  
 batch_normalization_1149 (  (None, 28, 28, 128)          512       ['conv2d_1142[0][0]']         
 BatchNormalization)                                                                              
                                                                                                  
 activation_1142 (Activatio  (None, 28, 28, 128)          0         ['batch_normalization_1149[0][
 n)                                                                 0]']                          
                                                                                                  
 conv2d_1143 (Conv2D)        (None, 28, 28, 32)           36864     ['activation_1142[0][0]']     
                                                                                                  
 concatenate_498 (Concatena  (None, 28, 28, 416)          0         ['concatenate_497[0][0]',     
 te)                                                                 'conv2d_1143[0][0]']         
                                                                                                  
 batch_normalization_1150 (  (None, 28, 28, 416)          1664      ['concatenate_498[0][0]']     
 BatchNormalization)                                                                              
                                                                                                  
 activation_1143 (Activatio  (None, 28, 28, 416)          0         ['batch_normalization_1150[0][
 n)                                                                 0]']                          
                                                                                                  
 conv2d_1144 (Conv2D)        (None, 28, 28, 128)          53248     ['activation_1143[0][0]']     
                                                                                                  
 batch_normalization_1151 (  (None, 28, 28, 128)          512       ['conv2d_1144[0][0]']         
 BatchNormalization)                                                                              
                                                                                                  
 activation_1144 (Activatio  (None, 28, 28, 128)          0         ['batch_normalization_1151[0][
 n)                                                                 0]']                          
                                                                                                  
 conv2d_1145 (Conv2D)        (None, 28, 28, 32)           36864     ['activation_1144[0][0]']     
                                                                                                  
 concatenate_499 (Concatena  (None, 28, 28, 448)          0         ['concatenate_498[0][0]',     
 te)                                                                 'conv2d_1145[0][0]']         
                                                                                                  
 batch_normalization_1152 (  (None, 28, 28, 448)          1792      ['concatenate_499[0][0]']     
 BatchNormalization)                                                                              
                                                                                                  
 activation_1145 (Activatio  (None, 28, 28, 448)          0         ['batch_normalization_1152[0][
 n)                                                                 0]']                          
                                                                                                  
 conv2d_1146 (Conv2D)        (None, 28, 28, 128)          57344     ['activation_1145[0][0]']     
                                                                                                  
 batch_normalization_1153 (  (None, 28, 28, 128)          512       ['conv2d_1146[0][0]']         
 BatchNormalization)                                                                              
                                                                                                  
 activation_1146 (Activatio  (None, 28, 28, 128)          0         ['batch_normalization_1153[0][
 n)                                                                 0]']                          
                                                                                                  
 conv2d_1147 (Conv2D)        (None, 28, 28, 32)           36864     ['activation_1146[0][0]']     
                                                                                                  
 concatenate_500 (Concatena  (None, 28, 28, 480)          0         ['concatenate_499[0][0]',     
 te)                                                                 'conv2d_1147[0][0]']         
                                                                                                  
 batch_normalization_1154 (  (None, 28, 28, 480)          1920      ['concatenate_500[0][0]']     
 BatchNormalization)                                                                              
                                                                                                  
 activation_1147 (Activatio  (None, 28, 28, 480)          0         ['batch_normalization_1154[0][
 n)                                                                 0]']                          
                                                                                                  
 conv2d_1148 (Conv2D)        (None, 28, 28, 128)          61440     ['activation_1147[0][0]']     
                                                                                                  
 batch_normalization_1155 (  (None, 28, 28, 128)          512       ['conv2d_1148[0][0]']         
 BatchNormalization)                                                                              
                                                                                                  
 activation_1148 (Activatio  (None, 28, 28, 128)          0         ['batch_normalization_1155[0][
 n)                                                                 0]']                          
                                                                                                  
 conv2d_1149 (Conv2D)        (None, 28, 28, 32)           36864     ['activation_1148[0][0]']     
                                                                                                  
 concatenate_501 (Concatena  (None, 28, 28, 512)          0         ['concatenate_500[0][0]',     
 te)                                                                 'conv2d_1149[0][0]']         
                                                                                                  
 batch_normalization_1156 (  (None, 28, 28, 512)          2048      ['concatenate_501[0][0]']     
 BatchNormalization)                                                                              
                                                                                                  
 activation_1149 (Activatio  (None, 28, 28, 512)          0         ['batch_normalization_1156[0][
 n)                                                                 0]']                          
                                                                                                  
 conv2d_1150 (Conv2D)        (None, 28, 28, 256)          131072    ['activation_1149[0][0]']     
                                                                                                  
 average_pooling2d_22 (Aver  (None, 14, 14, 256)          0         ['conv2d_1150[0][0]']         
 agePooling2D)                                                                                    
                                                                                                  
 batch_normalization_1157 (  (None, 14, 14, 256)          1024      ['average_pooling2d_22[0][0]']
 BatchNormalization)                                                                              
                                                                                                  
 activation_1150 (Activatio  (None, 14, 14, 256)          0         ['batch_normalization_1157[0][
 n)                                                                 0]']                          
                                                                                                  
 conv2d_1151 (Conv2D)        (None, 14, 14, 128)          32768     ['activation_1150[0][0]']     
                                                                                                  
 batch_normalization_1158 (  (None, 14, 14, 128)          512       ['conv2d_1151[0][0]']         
 BatchNormalization)                                                                              
                                                                                                  
 activation_1151 (Activatio  (None, 14, 14, 128)          0         ['batch_normalization_1158[0][
 n)                                                                 0]']                          
                                                                                                  
 conv2d_1152 (Conv2D)        (None, 14, 14, 32)           36864     ['activation_1151[0][0]']     
                                                                                                  
 concatenate_502 (Concatena  (None, 14, 14, 288)          0         ['average_pooling2d_22[0][0]',
 te)                                                                 'conv2d_1152[0][0]']         
                                                                                                  
 batch_normalization_1159 (  (None, 14, 14, 288)          1152      ['concatenate_502[0][0]']     
 BatchNormalization)                                                                              
                                                                                                  
 activation_1152 (Activatio  (None, 14, 14, 288)          0         ['batch_normalization_1159[0][
 n)                                                                 0]']                          
                                                                                                  
 conv2d_1153 (Conv2D)        (None, 14, 14, 128)          36864     ['activation_1152[0][0]']     
                                                                                                  
 batch_normalization_1160 (  (None, 14, 14, 128)          512       ['conv2d_1153[0][0]']         
 BatchNormalization)                                                                              
                                                                                                  
 activation_1153 (Activatio  (None, 14, 14, 128)          0         ['batch_normalization_1160[0][
 n)                                                                 0]']                          
                                                                                                  
 conv2d_1154 (Conv2D)        (None, 14, 14, 32)           36864     ['activation_1153[0][0]']     
                                                                                                  
 concatenate_503 (Concatena  (None, 14, 14, 320)          0         ['concatenate_502[0][0]',     
 te)                                                                 'conv2d_1154[0][0]']         
                                                                                                  
 batch_normalization_1161 (  (None, 14, 14, 320)          1280      ['concatenate_503[0][0]']     
 BatchNormalization)                                                                              
                                                                                                  
 activation_1154 (Activatio  (None, 14, 14, 320)          0         ['batch_normalization_1161[0][
 n)                                                                 0]']                          
                                                                                                  
 conv2d_1155 (Conv2D)        (None, 14, 14, 128)          40960     ['activation_1154[0][0]']     
                                                                                                  
 batch_normalization_1162 (  (None, 14, 14, 128)          512       ['conv2d_1155[0][0]']         
 BatchNormalization)                                                                              
                                                                                                  
 activation_1155 (Activatio  (None, 14, 14, 128)          0         ['batch_normalization_1162[0][
 n)                                                                 0]']                          
                                                                                                  
 conv2d_1156 (Conv2D)        (None, 14, 14, 32)           36864     ['activation_1155[0][0]']     
                                                                                                  
 concatenate_504 (Concatena  (None, 14, 14, 352)          0         ['concatenate_503[0][0]',     
 te)                                                                 'conv2d_1156[0][0]']         
                                                                                                  
 batch_normalization_1163 (  (None, 14, 14, 352)          1408      ['concatenate_504[0][0]']     
 BatchNormalization)                                                                              
                                                                                                  
 activation_1156 (Activatio  (None, 14, 14, 352)          0         ['batch_normalization_1163[0][
 n)                                                                 0]']                          
                                                                                                  
 conv2d_1157 (Conv2D)        (None, 14, 14, 128)          45056     ['activation_1156[0][0]']     
                                                                                                  
 batch_normalization_1164 (  (None, 14, 14, 128)          512       ['conv2d_1157[0][0]']         
 BatchNormalization)                                                                              
                                                                                                  
 activation_1157 (Activatio  (None, 14, 14, 128)          0         ['batch_normalization_1164[0][
 n)                                                                 0]']                          
                                                                                                  
 conv2d_1158 (Conv2D)        (None, 14, 14, 32)           36864     ['activation_1157[0][0]']     
                                                                                                  
 concatenate_505 (Concatena  (None, 14, 14, 384)          0         ['concatenate_504[0][0]',     
 te)                                                                 'conv2d_1158[0][0]']         
                                                                                                  
 batch_normalization_1165 (  (None, 14, 14, 384)          1536      ['concatenate_505[0][0]']     
 BatchNormalization)                                                                              
                                                                                                  
 activation_1158 (Activatio  (None, 14, 14, 384)          0         ['batch_normalization_1165[0][
 n)                                                                 0]']                          
                                                                                                  
 conv2d_1159 (Conv2D)        (None, 14, 14, 128)          49152     ['activation_1158[0][0]']     
                                                                                                  
 batch_normalization_1166 (  (None, 14, 14, 128)          512       ['conv2d_1159[0][0]']         
 BatchNormalization)                                                                              
                                                                                                  
 activation_1159 (Activatio  (None, 14, 14, 128)          0         ['batch_normalization_1166[0][
 n)                                                                 0]']                          
                                                                                                  
 conv2d_1160 (Conv2D)        (None, 14, 14, 32)           36864     ['activation_1159[0][0]']     
                                                                                                  
 concatenate_506 (Concatena  (None, 14, 14, 416)          0         ['concatenate_505[0][0]',     
 te)                                                                 'conv2d_1160[0][0]']         
                                                                                                  
 batch_normalization_1167 (  (None, 14, 14, 416)          1664      ['concatenate_506[0][0]']     
 BatchNormalization)                                                                              
                                                                                                  
 activation_1160 (Activatio  (None, 14, 14, 416)          0         ['batch_normalization_1167[0][
 n)                                                                 0]']                          
                                                                                                  
 conv2d_1161 (Conv2D)        (None, 14, 14, 128)          53248     ['activation_1160[0][0]']     
                                                                                                  
 batch_normalization_1168 (  (None, 14, 14, 128)          512       ['conv2d_1161[0][0]']         
 BatchNormalization)                                                                              
                                                                                                  
 activation_1161 (Activatio  (None, 14, 14, 128)          0         ['batch_normalization_1168[0][
 n)                                                                 0]']                          
                                                                                                  
 conv2d_1162 (Conv2D)        (None, 14, 14, 32)           36864     ['activation_1161[0][0]']     
                                                                                                  
 concatenate_507 (Concatena  (None, 14, 14, 448)          0         ['concatenate_506[0][0]',     
 te)                                                                 'conv2d_1162[0][0]']         
                                                                                                  
 batch_normalization_1169 (  (None, 14, 14, 448)          1792      ['concatenate_507[0][0]']     
 BatchNormalization)                                                                              
                                                                                                  
 activation_1162 (Activatio  (None, 14, 14, 448)          0         ['batch_normalization_1169[0][
 n)                                                                 0]']                          
                                                                                                  
 conv2d_1163 (Conv2D)        (None, 14, 14, 128)          57344     ['activation_1162[0][0]']     
                                                                                                  
 batch_normalization_1170 (  (None, 14, 14, 128)          512       ['conv2d_1163[0][0]']         
 BatchNormalization)                                                                              
                                                                                                  
 activation_1163 (Activatio  (None, 14, 14, 128)          0         ['batch_normalization_1170[0][
 n)                                                                 0]']                          
                                                                                                  
 conv2d_1164 (Conv2D)        (None, 14, 14, 32)           36864     ['activation_1163[0][0]']     
                                                                                                  
 concatenate_508 (Concatena  (None, 14, 14, 480)          0         ['concatenate_507[0][0]',     
 te)                                                                 'conv2d_1164[0][0]']         
                                                                                                  
 batch_normalization_1171 (  (None, 14, 14, 480)          1920      ['concatenate_508[0][0]']     
 BatchNormalization)                                                                              
                                                                                                  
 activation_1164 (Activatio  (None, 14, 14, 480)          0         ['batch_normalization_1171[0][
 n)                                                                 0]']                          
                                                                                                  
 conv2d_1165 (Conv2D)        (None, 14, 14, 128)          61440     ['activation_1164[0][0]']     
                                                                                                  
 batch_normalization_1172 (  (None, 14, 14, 128)          512       ['conv2d_1165[0][0]']         
 BatchNormalization)                                                                              
                                                                                                  
 activation_1165 (Activatio  (None, 14, 14, 128)          0         ['batch_normalization_1172[0][
 n)                                                                 0]']                          
                                                                                                  
 conv2d_1166 (Conv2D)        (None, 14, 14, 32)           36864     ['activation_1165[0][0]']     
                                                                                                  
 concatenate_509 (Concatena  (None, 14, 14, 512)          0         ['concatenate_508[0][0]',     
 te)                                                                 'conv2d_1166[0][0]']         
                                                                                                  
 batch_normalization_1173 (  (None, 14, 14, 512)          2048      ['concatenate_509[0][0]']     
 BatchNormalization)                                                                              
                                                                                                  
 activation_1166 (Activatio  (None, 14, 14, 512)          0         ['batch_normalization_1173[0][
 n)                                                                 0]']                          
                                                                                                  
 conv2d_1167 (Conv2D)        (None, 14, 14, 128)          65536     ['activation_1166[0][0]']     
                                                                                                  
 batch_normalization_1174 (  (None, 14, 14, 128)          512       ['conv2d_1167[0][0]']         
 BatchNormalization)                                                                              
                                                                                                  
 activation_1167 (Activatio  (None, 14, 14, 128)          0         ['batch_normalization_1174[0][
 n)                                                                 0]']                          
                                                                                                  
 conv2d_1168 (Conv2D)        (None, 14, 14, 32)           36864     ['activation_1167[0][0]']     
                                                                                                  
 concatenate_510 (Concatena  (None, 14, 14, 544)          0         ['concatenate_509[0][0]',     
 te)                                                                 'conv2d_1168[0][0]']         
                                                                                                  
 batch_normalization_1175 (  (None, 14, 14, 544)          2176      ['concatenate_510[0][0]']     
 BatchNormalization)                                                                              
                                                                                                  
 activation_1168 (Activatio  (None, 14, 14, 544)          0         ['batch_normalization_1175[0][
 n)                                                                 0]']                          
                                                                                                  
 conv2d_1169 (Conv2D)        (None, 14, 14, 128)          69632     ['activation_1168[0][0]']     
                                                                                                  
 batch_normalization_1176 (  (None, 14, 14, 128)          512       ['conv2d_1169[0][0]']         
 BatchNormalization)                                                                              
                                                                                                  
 activation_1169 (Activatio  (None, 14, 14, 128)          0         ['batch_normalization_1176[0][
 n)                                                                 0]']                          
                                                                                                  
 conv2d_1170 (Conv2D)        (None, 14, 14, 32)           36864     ['activation_1169[0][0]']     
                                                                                                  
 concatenate_511 (Concatena  (None, 14, 14, 576)          0         ['concatenate_510[0][0]',     
 te)                                                                 'conv2d_1170[0][0]']         
                                                                                                  
 batch_normalization_1177 (  (None, 14, 14, 576)          2304      ['concatenate_511[0][0]']     
 BatchNormalization)                                                                              
                                                                                                  
 activation_1170 (Activatio  (None, 14, 14, 576)          0         ['batch_normalization_1177[0][
 n)                                                                 0]']                          
                                                                                                  
 conv2d_1171 (Conv2D)        (None, 14, 14, 128)          73728     ['activation_1170[0][0]']     
                                                                                                  
 batch_normalization_1178 (  (None, 14, 14, 128)          512       ['conv2d_1171[0][0]']         
 BatchNormalization)                                                                              
                                                                                                  
 activation_1171 (Activatio  (None, 14, 14, 128)          0         ['batch_normalization_1178[0][
 n)                                                                 0]']                          
                                                                                                  
 conv2d_1172 (Conv2D)        (None, 14, 14, 32)           36864     ['activation_1171[0][0]']     
                                                                                                  
 concatenate_512 (Concatena  (None, 14, 14, 608)          0         ['concatenate_511[0][0]',     
 te)                                                                 'conv2d_1172[0][0]']         
                                                                                                  
 batch_normalization_1179 (  (None, 14, 14, 608)          2432      ['concatenate_512[0][0]']     
 BatchNormalization)                                                                              
                                                                                                  
 activation_1172 (Activatio  (None, 14, 14, 608)          0         ['batch_normalization_1179[0][
 n)                                                                 0]']                          
                                                                                                  
 conv2d_1173 (Conv2D)        (None, 14, 14, 128)          77824     ['activation_1172[0][0]']     
                                                                                                  
 batch_normalization_1180 (  (None, 14, 14, 128)          512       ['conv2d_1173[0][0]']         
 BatchNormalization)                                                                              
                                                                                                  
 activation_1173 (Activatio  (None, 14, 14, 128)          0         ['batch_normalization_1180[0][
 n)                                                                 0]']                          
                                                                                                  
 conv2d_1174 (Conv2D)        (None, 14, 14, 32)           36864     ['activation_1173[0][0]']     
                                                                                                  
 concatenate_513 (Concatena  (None, 14, 14, 640)          0         ['concatenate_512[0][0]',     
 te)                                                                 'conv2d_1174[0][0]']         
                                                                                                  
 batch_normalization_1181 (  (None, 14, 14, 640)          2560      ['concatenate_513[0][0]']     
 BatchNormalization)                                                                              
                                                                                                  
 activation_1174 (Activatio  (None, 14, 14, 640)          0         ['batch_normalization_1181[0][
 n)                                                                 0]']                          
                                                                                                  
 conv2d_1175 (Conv2D)        (None, 14, 14, 128)          81920     ['activation_1174[0][0]']     
                                                                                                  
 batch_normalization_1182 (  (None, 14, 14, 128)          512       ['conv2d_1175[0][0]']         
 BatchNormalization)                                                                              
                                                                                                  
 activation_1175 (Activatio  (None, 14, 14, 128)          0         ['batch_normalization_1182[0][
 n)                                                                 0]']                          
                                                                                                  
 conv2d_1176 (Conv2D)        (None, 14, 14, 32)           36864     ['activation_1175[0][0]']     
                                                                                                  
 concatenate_514 (Concatena  (None, 14, 14, 672)          0         ['concatenate_513[0][0]',     
 te)                                                                 'conv2d_1176[0][0]']         
                                                                                                  
 batch_normalization_1183 (  (None, 14, 14, 672)          2688      ['concatenate_514[0][0]']     
 BatchNormalization)                                                                              
                                                                                                  
 activation_1176 (Activatio  (None, 14, 14, 672)          0         ['batch_normalization_1183[0][
 n)                                                                 0]']                          
                                                                                                  
 conv2d_1177 (Conv2D)        (None, 14, 14, 128)          86016     ['activation_1176[0][0]']     
                                                                                                  
 batch_normalization_1184 (  (None, 14, 14, 128)          512       ['conv2d_1177[0][0]']         
 BatchNormalization)                                                                              
                                                                                                  
 activation_1177 (Activatio  (None, 14, 14, 128)          0         ['batch_normalization_1184[0][
 n)                                                                 0]']                          
                                                                                                  
 conv2d_1178 (Conv2D)        (None, 14, 14, 32)           36864     ['activation_1177[0][0]']     
                                                                                                  
 concatenate_515 (Concatena  (None, 14, 14, 704)          0         ['concatenate_514[0][0]',     
 te)                                                                 'conv2d_1178[0][0]']         
                                                                                                  
 batch_normalization_1185 (  (None, 14, 14, 704)          2816      ['concatenate_515[0][0]']     
 BatchNormalization)                                                                              
                                                                                                  
 activation_1178 (Activatio  (None, 14, 14, 704)          0         ['batch_normalization_1185[0][
 n)                                                                 0]']                          
                                                                                                  
 conv2d_1179 (Conv2D)        (None, 14, 14, 128)          90112     ['activation_1178[0][0]']     
                                                                                                  
 batch_normalization_1186 (  (None, 14, 14, 128)          512       ['conv2d_1179[0][0]']         
 BatchNormalization)                                                                              
                                                                                                  
 activation_1179 (Activatio  (None, 14, 14, 128)          0         ['batch_normalization_1186[0][
 n)                                                                 0]']                          
                                                                                                  
 conv2d_1180 (Conv2D)        (None, 14, 14, 32)           36864     ['activation_1179[0][0]']     
                                                                                                  
 concatenate_516 (Concatena  (None, 14, 14, 736)          0         ['concatenate_515[0][0]',     
 te)                                                                 'conv2d_1180[0][0]']         
                                                                                                  
 batch_normalization_1187 (  (None, 14, 14, 736)          2944      ['concatenate_516[0][0]']     
 BatchNormalization)                                                                              
                                                                                                  
 activation_1180 (Activatio  (None, 14, 14, 736)          0         ['batch_normalization_1187[0][
 n)                                                                 0]']                          
                                                                                                  
 conv2d_1181 (Conv2D)        (None, 14, 14, 128)          94208     ['activation_1180[0][0]']     
                                                                                                  
 batch_normalization_1188 (  (None, 14, 14, 128)          512       ['conv2d_1181[0][0]']         
 BatchNormalization)                                                                              
                                                                                                  
 activation_1181 (Activatio  (None, 14, 14, 128)          0         ['batch_normalization_1188[0][
 n)                                                                 0]']                          
                                                                                                  
 conv2d_1182 (Conv2D)        (None, 14, 14, 32)           36864     ['activation_1181[0][0]']     
                                                                                                  
 concatenate_517 (Concatena  (None, 14, 14, 768)          0         ['concatenate_516[0][0]',     
 te)                                                                 'conv2d_1182[0][0]']         
                                                                                                  
 batch_normalization_1189 (  (None, 14, 14, 768)          3072      ['concatenate_517[0][0]']     
 BatchNormalization)                                                                              
                                                                                                  
 activation_1182 (Activatio  (None, 14, 14, 768)          0         ['batch_normalization_1189[0][
 n)                                                                 0]']                          
                                                                                                  
 conv2d_1183 (Conv2D)        (None, 14, 14, 128)          98304     ['activation_1182[0][0]']     
                                                                                                  
 batch_normalization_1190 (  (None, 14, 14, 128)          512       ['conv2d_1183[0][0]']         
 BatchNormalization)                                                                              
                                                                                                  
 activation_1183 (Activatio  (None, 14, 14, 128)          0         ['batch_normalization_1190[0][
 n)                                                                 0]']                          
                                                                                                  
 conv2d_1184 (Conv2D)        (None, 14, 14, 32)           36864     ['activation_1183[0][0]']     
                                                                                                  
 concatenate_518 (Concatena  (None, 14, 14, 800)          0         ['concatenate_517[0][0]',     
 te)                                                                 'conv2d_1184[0][0]']         
                                                                                                  
 batch_normalization_1191 (  (None, 14, 14, 800)          3200      ['concatenate_518[0][0]']     
 BatchNormalization)                                                                              
                                                                                                  
 activation_1184 (Activatio  (None, 14, 14, 800)          0         ['batch_normalization_1191[0][
 n)                                                                 0]']                          
                                                                                                  
 conv2d_1185 (Conv2D)        (None, 14, 14, 128)          102400    ['activation_1184[0][0]']     
                                                                                                  
 batch_normalization_1192 (  (None, 14, 14, 128)          512       ['conv2d_1185[0][0]']         
 BatchNormalization)                                                                              
                                                                                                  
 activation_1185 (Activatio  (None, 14, 14, 128)          0         ['batch_normalization_1192[0][
 n)                                                                 0]']                          
                                                                                                  
 conv2d_1186 (Conv2D)        (None, 14, 14, 32)           36864     ['activation_1185[0][0]']     
                                                                                                  
 concatenate_519 (Concatena  (None, 14, 14, 832)          0         ['concatenate_518[0][0]',     
 te)                                                                 'conv2d_1186[0][0]']         
                                                                                                  
 batch_normalization_1193 (  (None, 14, 14, 832)          3328      ['concatenate_519[0][0]']     
 BatchNormalization)                                                                              
                                                                                                  
 activation_1186 (Activatio  (None, 14, 14, 832)          0         ['batch_normalization_1193[0][
 n)                                                                 0]']                          
                                                                                                  
 conv2d_1187 (Conv2D)        (None, 14, 14, 128)          106496    ['activation_1186[0][0]']     
                                                                                                  
 batch_normalization_1194 (  (None, 14, 14, 128)          512       ['conv2d_1187[0][0]']         
 BatchNormalization)                                                                              
                                                                                                  
 activation_1187 (Activatio  (None, 14, 14, 128)          0         ['batch_normalization_1194[0][
 n)                                                                 0]']                          
                                                                                                  
 conv2d_1188 (Conv2D)        (None, 14, 14, 32)           36864     ['activation_1187[0][0]']     
                                                                                                  
 concatenate_520 (Concatena  (None, 14, 14, 864)          0         ['concatenate_519[0][0]',     
 te)                                                                 'conv2d_1188[0][0]']         
                                                                                                  
 batch_normalization_1195 (  (None, 14, 14, 864)          3456      ['concatenate_520[0][0]']     
 BatchNormalization)                                                                              
                                                                                                  
 activation_1188 (Activatio  (None, 14, 14, 864)          0         ['batch_normalization_1195[0][
 n)                                                                 0]']                          
                                                                                                  
 conv2d_1189 (Conv2D)        (None, 14, 14, 128)          110592    ['activation_1188[0][0]']     
                                                                                                  
 batch_normalization_1196 (  (None, 14, 14, 128)          512       ['conv2d_1189[0][0]']         
 BatchNormalization)                                                                              
                                                                                                  
 activation_1189 (Activatio  (None, 14, 14, 128)          0         ['batch_normalization_1196[0][
 n)                                                                 0]']                          
                                                                                                  
 conv2d_1190 (Conv2D)        (None, 14, 14, 32)           36864     ['activation_1189[0][0]']     
                                                                                                  
 concatenate_521 (Concatena  (None, 14, 14, 896)          0         ['concatenate_520[0][0]',     
 te)                                                                 'conv2d_1190[0][0]']         
                                                                                                  
 batch_normalization_1197 (  (None, 14, 14, 896)          3584      ['concatenate_521[0][0]']     
 BatchNormalization)                                                                              
                                                                                                  
 activation_1190 (Activatio  (None, 14, 14, 896)          0         ['batch_normalization_1197[0][
 n)                                                                 0]']                          
                                                                                                  
 conv2d_1191 (Conv2D)        (None, 14, 14, 128)          114688    ['activation_1190[0][0]']     
                                                                                                  
 batch_normalization_1198 (  (None, 14, 14, 128)          512       ['conv2d_1191[0][0]']         
 BatchNormalization)                                                                              
                                                                                                  
 activation_1191 (Activatio  (None, 14, 14, 128)          0         ['batch_normalization_1198[0][
 n)                                                                 0]']                          
                                                                                                  
 conv2d_1192 (Conv2D)        (None, 14, 14, 32)           36864     ['activation_1191[0][0]']     
                                                                                                  
 concatenate_522 (Concatena  (None, 14, 14, 928)          0         ['concatenate_521[0][0]',     
 te)                                                                 'conv2d_1192[0][0]']         
                                                                                                  
 batch_normalization_1199 (  (None, 14, 14, 928)          3712      ['concatenate_522[0][0]']     
 BatchNormalization)                                                                              
                                                                                                  
 activation_1192 (Activatio  (None, 14, 14, 928)          0         ['batch_normalization_1199[0][
 n)                                                                 0]']                          
                                                                                                  
 conv2d_1193 (Conv2D)        (None, 14, 14, 128)          118784    ['activation_1192[0][0]']     
                                                                                                  
 batch_normalization_1200 (  (None, 14, 14, 128)          512       ['conv2d_1193[0][0]']         
 BatchNormalization)                                                                              
                                                                                                  
 activation_1193 (Activatio  (None, 14, 14, 128)          0         ['batch_normalization_1200[0][
 n)                                                                 0]']                          
                                                                                                  
 conv2d_1194 (Conv2D)        (None, 14, 14, 32)           36864     ['activation_1193[0][0]']     
                                                                                                  
 concatenate_523 (Concatena  (None, 14, 14, 960)          0         ['concatenate_522[0][0]',     
 te)                                                                 'conv2d_1194[0][0]']         
                                                                                                  
 batch_normalization_1201 (  (None, 14, 14, 960)          3840      ['concatenate_523[0][0]']     
 BatchNormalization)                                                                              
                                                                                                  
 activation_1194 (Activatio  (None, 14, 14, 960)          0         ['batch_normalization_1201[0][
 n)                                                                 0]']                          
                                                                                                  
 conv2d_1195 (Conv2D)        (None, 14, 14, 128)          122880    ['activation_1194[0][0]']     
                                                                                                  
 batch_normalization_1202 (  (None, 14, 14, 128)          512       ['conv2d_1195[0][0]']         
 BatchNormalization)                                                                              
                                                                                                  
 activation_1195 (Activatio  (None, 14, 14, 128)          0         ['batch_normalization_1202[0][
 n)                                                                 0]']                          
                                                                                                  
 conv2d_1196 (Conv2D)        (None, 14, 14, 32)           36864     ['activation_1195[0][0]']     
                                                                                                  
 concatenate_524 (Concatena  (None, 14, 14, 992)          0         ['concatenate_523[0][0]',     
 te)                                                                 'conv2d_1196[0][0]']         
                                                                                                  
 batch_normalization_1203 (  (None, 14, 14, 992)          3968      ['concatenate_524[0][0]']     
 BatchNormalization)                                                                              
                                                                                                  
 activation_1196 (Activatio  (None, 14, 14, 992)          0         ['batch_normalization_1203[0][
 n)                                                                 0]']                          
                                                                                                  
 conv2d_1197 (Conv2D)        (None, 14, 14, 128)          126976    ['activation_1196[0][0]']     
                                                                                                  
 batch_normalization_1204 (  (None, 14, 14, 128)          512       ['conv2d_1197[0][0]']         
 BatchNormalization)                                                                              
                                                                                                  
 activation_1197 (Activatio  (None, 14, 14, 128)          0         ['batch_normalization_1204[0][
 n)                                                                 0]']                          
                                                                                                  
 conv2d_1198 (Conv2D)        (None, 14, 14, 32)           36864     ['activation_1197[0][0]']     
                                                                                                  
 concatenate_525 (Concatena  (None, 14, 14, 1024)         0         ['concatenate_524[0][0]',     
 te)                                                                 'conv2d_1198[0][0]']         
                                                                                                  
 batch_normalization_1205 (  (None, 14, 14, 1024)         4096      ['concatenate_525[0][0]']     
 BatchNormalization)                                                                              
                                                                                                  
 activation_1198 (Activatio  (None, 14, 14, 1024)         0         ['batch_normalization_1205[0][
 n)                                                                 0]']                          
                                                                                                  
 conv2d_1199 (Conv2D)        (None, 14, 14, 512)          524288    ['activation_1198[0][0]']     
                                                                                                  
 average_pooling2d_23 (Aver  (None, 7, 7, 512)            0         ['conv2d_1199[0][0]']         
 agePooling2D)                                                                                    
                                                                                                  
 batch_normalization_1206 (  (None, 7, 7, 512)            2048      ['average_pooling2d_23[0][0]']
 BatchNormalization)                                                                              
                                                                                                  
 activation_1199 (Activatio  (None, 7, 7, 512)            0         ['batch_normalization_1206[0][
 n)                                                                 0]']                          
                                                                                                  
 conv2d_1200 (Conv2D)        (None, 7, 7, 128)            65536     ['activation_1199[0][0]']     
                                                                                                  
 batch_normalization_1207 (  (None, 7, 7, 128)            512       ['conv2d_1200[0][0]']         
 BatchNormalization)                                                                              
                                                                                                  
 activation_1200 (Activatio  (None, 7, 7, 128)            0         ['batch_normalization_1207[0][
 n)                                                                 0]']                          
                                                                                                  
 conv2d_1201 (Conv2D)        (None, 7, 7, 32)             36864     ['activation_1200[0][0]']     
                                                                                                  
 concatenate_526 (Concatena  (None, 7, 7, 544)            0         ['average_pooling2d_23[0][0]',
 te)                                                                 'conv2d_1201[0][0]']         
                                                                                                  
 batch_normalization_1208 (  (None, 7, 7, 544)            2176      ['concatenate_526[0][0]']     
 BatchNormalization)                                                                              
                                                                                                  
 activation_1201 (Activatio  (None, 7, 7, 544)            0         ['batch_normalization_1208[0][
 n)                                                                 0]']                          
                                                                                                  
 conv2d_1202 (Conv2D)        (None, 7, 7, 128)            69632     ['activation_1201[0][0]']     
                                                                                                  
 batch_normalization_1209 (  (None, 7, 7, 128)            512       ['conv2d_1202[0][0]']         
 BatchNormalization)                                                                              
                                                                                                  
 activation_1202 (Activatio  (None, 7, 7, 128)            0         ['batch_normalization_1209[0][
 n)                                                                 0]']                          
                                                                                                  
 conv2d_1203 (Conv2D)        (None, 7, 7, 32)             36864     ['activation_1202[0][0]']     
                                                                                                  
 concatenate_527 (Concatena  (None, 7, 7, 576)            0         ['concatenate_526[0][0]',     
 te)                                                                 'conv2d_1203[0][0]']         
                                                                                                  
 batch_normalization_1210 (  (None, 7, 7, 576)            2304      ['concatenate_527[0][0]']     
 BatchNormalization)                                                                              
                                                                                                  
 activation_1203 (Activatio  (None, 7, 7, 576)            0         ['batch_normalization_1210[0][
 n)                                                                 0]']                          
                                                                                                  
 conv2d_1204 (Conv2D)        (None, 7, 7, 128)            73728     ['activation_1203[0][0]']     
                                                                                                  
 batch_normalization_1211 (  (None, 7, 7, 128)            512       ['conv2d_1204[0][0]']         
 BatchNormalization)                                                                              
                                                                                                  
 activation_1204 (Activatio  (None, 7, 7, 128)            0         ['batch_normalization_1211[0][
 n)                                                                 0]']                          
                                                                                                  
 conv2d_1205 (Conv2D)        (None, 7, 7, 32)             36864     ['activation_1204[0][0]']     
                                                                                                  
 concatenate_528 (Concatena  (None, 7, 7, 608)            0         ['concatenate_527[0][0]',     
 te)                                                                 'conv2d_1205[0][0]']         
                                                                                                  
 batch_normalization_1212 (  (None, 7, 7, 608)            2432      ['concatenate_528[0][0]']     
 BatchNormalization)                                                                              
                                                                                                  
 activation_1205 (Activatio  (None, 7, 7, 608)            0         ['batch_normalization_1212[0][
 n)                                                                 0]']                          
                                                                                                  
 conv2d_1206 (Conv2D)        (None, 7, 7, 128)            77824     ['activation_1205[0][0]']     
                                                                                                  
 batch_normalization_1213 (  (None, 7, 7, 128)            512       ['conv2d_1206[0][0]']         
 BatchNormalization)                                                                              
                                                                                                  
 activation_1206 (Activatio  (None, 7, 7, 128)            0         ['batch_normalization_1213[0][
 n)                                                                 0]']                          
                                                                                                  
 conv2d_1207 (Conv2D)        (None, 7, 7, 32)             36864     ['activation_1206[0][0]']     
                                                                                                  
 concatenate_529 (Concatena  (None, 7, 7, 640)            0         ['concatenate_528[0][0]',     
 te)                                                                 'conv2d_1207[0][0]']         
                                                                                                  
 batch_normalization_1214 (  (None, 7, 7, 640)            2560      ['concatenate_529[0][0]']     
 BatchNormalization)                                                                              
                                                                                                  
 activation_1207 (Activatio  (None, 7, 7, 640)            0         ['batch_normalization_1214[0][
 n)                                                                 0]']                          
                                                                                                  
 conv2d_1208 (Conv2D)        (None, 7, 7, 128)            81920     ['activation_1207[0][0]']     
                                                                                                  
 batch_normalization_1215 (  (None, 7, 7, 128)            512       ['conv2d_1208[0][0]']         
 BatchNormalization)                                                                              
                                                                                                  
 activation_1208 (Activatio  (None, 7, 7, 128)            0         ['batch_normalization_1215[0][
 n)                                                                 0]']                          
                                                                                                  
 conv2d_1209 (Conv2D)        (None, 7, 7, 32)             36864     ['activation_1208[0][0]']     
                                                                                                  
 concatenate_530 (Concatena  (None, 7, 7, 672)            0         ['concatenate_529[0][0]',     
 te)                                                                 'conv2d_1209[0][0]']         
                                                                                                  
 batch_normalization_1216 (  (None, 7, 7, 672)            2688      ['concatenate_530[0][0]']     
 BatchNormalization)                                                                              
                                                                                                  
 activation_1209 (Activatio  (None, 7, 7, 672)            0         ['batch_normalization_1216[0][
 n)                                                                 0]']                          
                                                                                                  
 conv2d_1210 (Conv2D)        (None, 7, 7, 128)            86016     ['activation_1209[0][0]']     
                                                                                                  
 batch_normalization_1217 (  (None, 7, 7, 128)            512       ['conv2d_1210[0][0]']         
 BatchNormalization)                                                                              
                                                                                                  
 activation_1210 (Activatio  (None, 7, 7, 128)            0         ['batch_normalization_1217[0][
 n)                                                                 0]']                          
                                                                                                  
 conv2d_1211 (Conv2D)        (None, 7, 7, 32)             36864     ['activation_1210[0][0]']     
                                                                                                  
 concatenate_531 (Concatena  (None, 7, 7, 704)            0         ['concatenate_530[0][0]',     
 te)                                                                 'conv2d_1211[0][0]']         
                                                                                                  
 batch_normalization_1218 (  (None, 7, 7, 704)            2816      ['concatenate_531[0][0]']     
 BatchNormalization)                                                                              
                                                                                                  
 activation_1211 (Activatio  (None, 7, 7, 704)            0         ['batch_normalization_1218[0][
 n)                                                                 0]']                          
                                                                                                  
 conv2d_1212 (Conv2D)        (None, 7, 7, 128)            90112     ['activation_1211[0][0]']     
                                                                                                  
 batch_normalization_1219 (  (None, 7, 7, 128)            512       ['conv2d_1212[0][0]']         
 BatchNormalization)                                                                              
                                                                                                  
 activation_1212 (Activatio  (None, 7, 7, 128)            0         ['batch_normalization_1219[0][
 n)                                                                 0]']                          
                                                                                                  
 conv2d_1213 (Conv2D)        (None, 7, 7, 32)             36864     ['activation_1212[0][0]']     
                                                                                                  
 concatenate_532 (Concatena  (None, 7, 7, 736)            0         ['concatenate_531[0][0]',     
 te)                                                                 'conv2d_1213[0][0]']         
                                                                                                  
 batch_normalization_1220 (  (None, 7, 7, 736)            2944      ['concatenate_532[0][0]']     
 BatchNormalization)                                                                              
                                                                                                  
 activation_1213 (Activatio  (None, 7, 7, 736)            0         ['batch_normalization_1220[0][
 n)                                                                 0]']                          
                                                                                                  
 conv2d_1214 (Conv2D)        (None, 7, 7, 128)            94208     ['activation_1213[0][0]']     
                                                                                                  
 batch_normalization_1221 (  (None, 7, 7, 128)            512       ['conv2d_1214[0][0]']         
 BatchNormalization)                                                                              
                                                                                                  
 activation_1214 (Activatio  (None, 7, 7, 128)            0         ['batch_normalization_1221[0][
 n)                                                                 0]']                          
                                                                                                  
 conv2d_1215 (Conv2D)        (None, 7, 7, 32)             36864     ['activation_1214[0][0]']     
                                                                                                  
 concatenate_533 (Concatena  (None, 7, 7, 768)            0         ['concatenate_532[0][0]',     
 te)                                                                 'conv2d_1215[0][0]']         
                                                                                                  
 batch_normalization_1222 (  (None, 7, 7, 768)            3072      ['concatenate_533[0][0]']     
 BatchNormalization)                                                                              
                                                                                                  
 activation_1215 (Activatio  (None, 7, 7, 768)            0         ['batch_normalization_1222[0][
 n)                                                                 0]']                          
                                                                                                  
 conv2d_1216 (Conv2D)        (None, 7, 7, 128)            98304     ['activation_1215[0][0]']     
                                                                                                  
 batch_normalization_1223 (  (None, 7, 7, 128)            512       ['conv2d_1216[0][0]']         
 BatchNormalization)                                                                              
                                                                                                  
 activation_1216 (Activatio  (None, 7, 7, 128)            0         ['batch_normalization_1223[0][
 n)                                                                 0]']                          
                                                                                                  
 conv2d_1217 (Conv2D)        (None, 7, 7, 32)             36864     ['activation_1216[0][0]']     
                                                                                                  
 concatenate_534 (Concatena  (None, 7, 7, 800)            0         ['concatenate_533[0][0]',     
 te)                                                                 'conv2d_1217[0][0]']         
                                                                                                  
 batch_normalization_1224 (  (None, 7, 7, 800)            3200      ['concatenate_534[0][0]']     
 BatchNormalization)                                                                              
                                                                                                  
 activation_1217 (Activatio  (None, 7, 7, 800)            0         ['batch_normalization_1224[0][
 n)                                                                 0]']                          
                                                                                                  
 conv2d_1218 (Conv2D)        (None, 7, 7, 128)            102400    ['activation_1217[0][0]']     
                                                                                                  
 batch_normalization_1225 (  (None, 7, 7, 128)            512       ['conv2d_1218[0][0]']         
 BatchNormalization)                                                                              
                                                                                                  
 activation_1218 (Activatio  (None, 7, 7, 128)            0         ['batch_normalization_1225[0][
 n)                                                                 0]']                          
                                                                                                  
 conv2d_1219 (Conv2D)        (None, 7, 7, 32)             36864     ['activation_1218[0][0]']     
                                                                                                  
 concatenate_535 (Concatena  (None, 7, 7, 832)            0         ['concatenate_534[0][0]',     
 te)                                                                 'conv2d_1219[0][0]']         
                                                                                                  
 batch_normalization_1226 (  (None, 7, 7, 832)            3328      ['concatenate_535[0][0]']     
 BatchNormalization)                                                                              
                                                                                                  
 activation_1219 (Activatio  (None, 7, 7, 832)            0         ['batch_normalization_1226[0][
 n)                                                                 0]']                          
                                                                                                  
 conv2d_1220 (Conv2D)        (None, 7, 7, 128)            106496    ['activation_1219[0][0]']     
                                                                                                  
 batch_normalization_1227 (  (None, 7, 7, 128)            512       ['conv2d_1220[0][0]']         
 BatchNormalization)                                                                              
                                                                                                  
 activation_1220 (Activatio  (None, 7, 7, 128)            0         ['batch_normalization_1227[0][
 n)                                                                 0]']                          
                                                                                                  
 conv2d_1221 (Conv2D)        (None, 7, 7, 32)             36864     ['activation_1220[0][0]']     
                                                                                                  
 concatenate_536 (Concatena  (None, 7, 7, 864)            0         ['concatenate_535[0][0]',     
 te)                                                                 'conv2d_1221[0][0]']         
                                                                                                  
 batch_normalization_1228 (  (None, 7, 7, 864)            3456      ['concatenate_536[0][0]']     
 BatchNormalization)                                                                              
                                                                                                  
 activation_1221 (Activatio  (None, 7, 7, 864)            0         ['batch_normalization_1228[0][
 n)                                                                 0]']                          
                                                                                                  
 conv2d_1222 (Conv2D)        (None, 7, 7, 128)            110592    ['activation_1221[0][0]']     
                                                                                                  
 batch_normalization_1229 (  (None, 7, 7, 128)            512       ['conv2d_1222[0][0]']         
 BatchNormalization)                                                                              
                                                                                                  
 activation_1222 (Activatio  (None, 7, 7, 128)            0         ['batch_normalization_1229[0][
 n)                                                                 0]']                          
                                                                                                  
 conv2d_1223 (Conv2D)        (None, 7, 7, 32)             36864     ['activation_1222[0][0]']     
                                                                                                  
 concatenate_537 (Concatena  (None, 7, 7, 896)            0         ['concatenate_536[0][0]',     
 te)                                                                 'conv2d_1223[0][0]']         
                                                                                                  
 batch_normalization_1230 (  (None, 7, 7, 896)            3584      ['concatenate_537[0][0]']     
 BatchNormalization)                                                                              
                                                                                                  
 activation_1223 (Activatio  (None, 7, 7, 896)            0         ['batch_normalization_1230[0][
 n)                                                                 0]']                          
                                                                                                  
 conv2d_1224 (Conv2D)        (None, 7, 7, 128)            114688    ['activation_1223[0][0]']     
                                                                                                  
 batch_normalization_1231 (  (None, 7, 7, 128)            512       ['conv2d_1224[0][0]']         
 BatchNormalization)                                                                              
                                                                                                  
 activation_1224 (Activatio  (None, 7, 7, 128)            0         ['batch_normalization_1231[0][
 n)                                                                 0]']                          
                                                                                                  
 conv2d_1225 (Conv2D)        (None, 7, 7, 32)             36864     ['activation_1224[0][0]']     
                                                                                                  
 concatenate_538 (Concatena  (None, 7, 7, 928)            0         ['concatenate_537[0][0]',     
 te)                                                                 'conv2d_1225[0][0]']         
                                                                                                  
 batch_normalization_1232 (  (None, 7, 7, 928)            3712      ['concatenate_538[0][0]']     
 BatchNormalization)                                                                              
                                                                                                  
 activation_1225 (Activatio  (None, 7, 7, 928)            0         ['batch_normalization_1232[0][
 n)                                                                 0]']                          
                                                                                                  
 conv2d_1226 (Conv2D)        (None, 7, 7, 128)            118784    ['activation_1225[0][0]']     
                                                                                                  
 batch_normalization_1233 (  (None, 7, 7, 128)            512       ['conv2d_1226[0][0]']         
 BatchNormalization)                                                                              
                                                                                                  
 activation_1226 (Activatio  (None, 7, 7, 128)            0         ['batch_normalization_1233[0][
 n)                                                                 0]']                          
                                                                                                  
 conv2d_1227 (Conv2D)        (None, 7, 7, 32)             36864     ['activation_1226[0][0]']     
                                                                                                  
 concatenate_539 (Concatena  (None, 7, 7, 960)            0         ['concatenate_538[0][0]',     
 te)                                                                 'conv2d_1227[0][0]']         
                                                                                                  
 batch_normalization_1234 (  (None, 7, 7, 960)            3840      ['concatenate_539[0][0]']     
 BatchNormalization)                                                                              
                                                                                                  
 activation_1227 (Activatio  (None, 7, 7, 960)            0         ['batch_normalization_1234[0][
 n)                                                                 0]']                          
                                                                                                  
 conv2d_1228 (Conv2D)        (None, 7, 7, 128)            122880    ['activation_1227[0][0]']     
                                                                                                  
 batch_normalization_1235 (  (None, 7, 7, 128)            512       ['conv2d_1228[0][0]']         
 BatchNormalization)                                                                              
                                                                                                  
 activation_1228 (Activatio  (None, 7, 7, 128)            0         ['batch_normalization_1235[0][
 n)                                                                 0]']                          
                                                                                                  
 conv2d_1229 (Conv2D)        (None, 7, 7, 32)             36864     ['activation_1228[0][0]']     
                                                                                                  
 concatenate_540 (Concatena  (None, 7, 7, 992)            0         ['concatenate_539[0][0]',     
 te)                                                                 'conv2d_1229[0][0]']         
                                                                                                  
 batch_normalization_1236 (  (None, 7, 7, 992)            3968      ['concatenate_540[0][0]']     
 BatchNormalization)                                                                              
                                                                                                  
 activation_1229 (Activatio  (None, 7, 7, 992)            0         ['batch_normalization_1236[0][
 n)                                                                 0]']                          
                                                                                                  
 conv2d_1230 (Conv2D)        (None, 7, 7, 128)            126976    ['activation_1229[0][0]']     
                                                                                                  
 batch_normalization_1237 (  (None, 7, 7, 128)            512       ['conv2d_1230[0][0]']         
 BatchNormalization)                                                                              
                                                                                                  
 activation_1230 (Activatio  (None, 7, 7, 128)            0         ['batch_normalization_1237[0][
 n)                                                                 0]']                          
                                                                                                  
 conv2d_1231 (Conv2D)        (None, 7, 7, 32)             36864     ['activation_1230[0][0]']     
                                                                                                  
 concatenate_541 (Concatena  (None, 7, 7, 1024)           0         ['concatenate_540[0][0]',     
 te)                                                                 'conv2d_1231[0][0]']         
                                                                                                  
 batch_normalization_1238 (  (None, 7, 7, 1024)           4096      ['concatenate_541[0][0]']     
 BatchNormalization)                                                                              
                                                                                                  
 activation_1231 (Activatio  (None, 7, 7, 1024)           0         ['batch_normalization_1238[0][
 n)                                                                 0]']                          
                                                                                                  
 global_average_pooling2d_7  (None, 1024)                 0         ['activation_1231[0][0]']     
  (GlobalAveragePooling2D)                                                                        
                                                                                                  
 dense_7 (Dense)             (None, 4)                    4100      ['global_average_pooling2d_7[0
                                                                    ][0]']                        
                                                                                                  
==================================================================================================
Total params: 7041604 (26.86 MB)
Trainable params: 6957956 (26.54 MB)
Non-trainable params: 83648 (326.75 KB)
__________________________________________________________________________________________________

四、编译

在准备对模型进行训练之前,还需要再对其进行一些设置。以下内容是在模型的编译步骤中添加的:

损失函数(loss):用于衡量模型在训练期间的准确率。
优化器(optimizer):决定模型如何根据其看到的数据和自身的损失函数进行更新。
指标(metrics):用于监控训练和测试步骤。以下示例使用了准确率,即被正确分类的图像的比率。

#设置优化器
opt=tf.keras.optimizers.Adam(learning_rate=1e-3)
 
model.compile(optimizer=opt,
              loss=tf.keras.losses.SparseCategoricalCrossentropy(),
              metrics=['accuracy'])

五、训练模型

epochs=10
 
history=model.fit(
    train_ds,
    validation_data=val_ds,
    epochs=epochs
)

运行结果:

Epoch 1/10
57/57 [==============================] - 176s 3s/step - loss: 1.1100 - accuracy: 0.6018 - val_loss: 65.5068 - val_accuracy: 0.3186
Epoch 2/10
57/57 [==============================] - 144s 3s/step - loss: 0.8184 - accuracy: 0.7102 - val_loss: 12.4867 - val_accuracy: 0.2743
Epoch 3/10
57/57 [==============================] - 145s 3s/step - loss: 0.7348 - accuracy: 0.7345 - val_loss: 13.2388 - val_accuracy: 0.3274
Epoch 4/10
57/57 [==============================] - 145s 3s/step - loss: 0.7246 - accuracy: 0.7500 - val_loss: 0.9510 - val_accuracy: 0.7257
Epoch 5/10
57/57 [==============================] - 146s 3s/step - loss: 0.6159 - accuracy: 0.7588 - val_loss: 0.6772 - val_accuracy: 0.7965
Epoch 6/10
57/57 [==============================] - 146s 3s/step - loss: 0.4837 - accuracy: 0.8363 - val_loss: 1.9455 - val_accuracy: 0.5221
Epoch 7/10
57/57 [==============================] - 146s 3s/step - loss: 0.5053 - accuracy: 0.8252 - val_loss: 1.6885 - val_accuracy: 0.4159
Epoch 8/10
57/57 [==============================] - 146s 3s/step - loss: 0.4130 - accuracy: 0.8518 - val_loss: 1.9283 - val_accuracy: 0.6726
Epoch 9/10
57/57 [==============================] - 146s 3s/step - loss: 0.4273 - accuracy: 0.8429 - val_loss: 2.2898 - val_accuracy: 0.4867
Epoch 10/10
57/57 [==============================] - 152s 3s/step - loss: 0.3546 - accuracy: 0.8695 - val_loss: 0.9306 - val_accuracy: 0.7345

六、模型评估

acc=history.history['accuracy']
val_acc=history.history['val_accuracy']
 
loss=history.history['loss']
val_loss=history.history['val_loss']
 
epochs_range=range(epochs)
 
plt.figure(figsize=(12,4))
plt.suptitle("OreoCC")
 
plt.subplot(1,2,1)
plt.plot(epochs_range,acc,label='Training Accuracy')
plt.plot(epochs_range,val_acc,label='Validation Accuracy')
plt.legend(loc='lower right')
plt.title('Training and Validation Accuracy')
 
plt.subplot(1,2,2)
plt.plot(epochs_range,loss,label='Training Loss')
plt.plot(epochs_range,val_loss,label='Validation Loss')
plt.legend(loc='upper right')
plt.title('Training and Validation Loss')
plt.show()

运行结果:

七、预测

import numpy as np
#采用加载的模型(new_model)来看预测结果
plt.figure(figsize=(10,5))
plt.suptitle("OreoCC")
 
for images,labels in val_ds.take(1):
    for i in range(8):
        ax=plt.subplot(2,4,i+1)
        
        #显示图片
        plt.imshow(images[i].numpy().astype("uint8"))
        
        #需要给图片增加一个维度
        img_array=tf.expand_dims(images[i],0)
        
        #使用模型预测图片中的人物
        predictions=model.predict(img_array)
        plt.title(classNames[np.argmax(predictions)])
        
        plt.axis("off")

 运行结果:

八、心得体会 

本次项目中,体会了再TensorFlow环境下建立DenseNet模型的过程。深入了解了模型密集连接模式。这种设计促进了特征的重用,并鼓励梯度流动,有助于缓解深度学习中的梯度消失问题。

下面是DenseNet结构的关键组成部分:

初始卷积层:网络通常以一个标准的卷积层开始,用于初步提取输入图像的特征,并可能伴随有池化层来缩小输入尺寸。

Dense Blocks(密集块):DenseNet的主要构建模块。每个密集块内,每新增一个层,都会将其输出特征图与之前所有层的输出特征图进行拼接(concatenation),作为下一个层的输入。这保证了信息流的高效传递和特征的复用。为了控制模型复杂度,每个层通过较小的增长率(growth rate)来增加特征图的数量,即每个层产生的新特征图数量。

Bottleneck Layers(瓶颈层):为了减少计算成本,实际应用中的DenseNet常采用Bottleneck层设计。这些层首先使用1x1卷积来减少输入特征图的数量,然后是BN(Batch Normalization)和ReLU激活函数,接着是3x3卷积来提取特征。这样的设计保持了模型的效率,同时维持了特征的丰富性。

Transition Layers(过渡层):位于Dense Blocks之间,用于过渡并控制模型的复杂度。过渡层通常包含1x1的卷积用于压缩特征图的通道数(使用压缩因子θ),以及可选的平均池化(Average Pooling)来进一步减小空间尺寸,帮助减少计算负担和过拟合风险。

分类层:网络的尾部通常包括全局平均池化(Global Average Pooling)层,用于将每个特征图的 spatial 维度压缩为一个值,随后连接一个或多个全连接层用于最终的分类或回归任务。

但模型的预测结果波动较大,初始loss也过于大,我想可能是由于模型层数较多,而数据集较少的原因造成的,故更换了大约有2000多张图片的数据集重新利用模型进行预测,结果如下:

可以看出,模型的准确率有所上升,但依然有些许波动,而loss也依然有所波动,考虑今后采用更大型数据集对模型进行验证。 

点赞(0) 打赏

评论列表 共有 0 条评论

暂无评论

微信公众账号

微信扫一扫加关注

发表
评论
返回
顶部