CFResNet鸟类识别:原网络基础上改进算法

news2025/4/6 20:29:37

​本文为为🔗365天深度学习训练营内部文章

原作者:K同学啊​

先放一张ResNet50模型的鸟类识别结果图 

 

一 ResNet+SE-Net+BN 

import matplotlib.pyplot as plt
import tensorflow as tf
import warnings as w
w.filterwarnings('ignore')
# 支持中文
plt.rcParams['font.sans-serif'] = ['SimHei']  # 用来正常显示中文标签
plt.rcParams['axes.unicode_minus'] = False  # 用来正常显示负号

import os,PIL,pathlib

#隐藏警告
import warnings
warnings.filterwarnings('ignore')

data_dir = "./bird_photos"
data_dir = pathlib.Path(data_dir)

image_count = len(list(data_dir.glob('*/*')))

print("图片数为:",image_count)

batch_size = 8
img_height = 224
img_width = 224

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

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

class_names = train_ds.class_names
print(class_names)

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

AUTOTUNE = tf.data.AUTOTUNE

def preprocess_image(image,label):
    return (image/255.0,label)

# 归一化处理
train_ds = train_ds.map(preprocess_image, num_parallel_calls=AUTOTUNE)
val_ds   = val_ds.map(preprocess_image, num_parallel_calls=AUTOTUNE)

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

plt.figure(figsize=(15, 10))  # 图形的宽为15高为10

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

 

from keras import layers
from keras.layers import Input, Activation, BatchNormalization, Flatten, Dropout,Reshape
from keras.layers import Dense, Conv2D, MaxPooling2D, ZeroPadding2D, AveragePooling2D, GlobalAveragePooling2D
from keras.models import Model
import tensorflow as tf
from keras.layers import Add, UpSampling2D, Conv2D
from keras.layers import Multiply, Concatenate

def squeeze_excite_block(input_tensor, ratio=16):
    '''
    Squeeze-and-Excitation Block
    :param input_tensor: 输入张量
    :param ratio: 压缩比,控制激励层中间层的维度。通常选择较小的值,如16。
    :return: 加权后的张量
    '''
    channel_axis = -1  # 通道轴通常在最后一维
    channels = input_tensor.shape[channel_axis]  # 获取通道数

    # Squeeze:全局平均池化
    x = GlobalAveragePooling2D()(input_tensor)
    x = Reshape((1, 1, channels))(x)

    # Excite:两个全连接层生成通道权重
    x = Dense(channels // ratio, activation='relu', kernel_initializer='he_normal', use_bias=False)(x)
    x = Dense(channels, activation='sigmoid', kernel_initializer='he_normal', use_bias=False)(x)

    # 将生成的权重与输入张量相乘
    x = Multiply()([input_tensor, x])
    
    return x
def identity_block(input_tensor, kernel_size, filters, stage, block):
    filters1, filters2, filters3 = filters
    name_base = str(stage) + block + '_identity_block_'

    # 第一卷积层
    x = Conv2D(filters1, (1, 1), name=name_base + 'conv1')(input_tensor)
    x = BatchNormalization(name=name_base + 'bn1')(x)
    x = Activation('relu', name=name_base + 'relu1')(x)

    # 第二卷积层
    x = Conv2D(filters2, kernel_size, padding='same', name=name_base + 'conv2')(x)
    x = BatchNormalization(name=name_base + 'bn2')(x)
    x = Activation('relu', name=name_base + 'relu2')(x)

    # 第三卷积层
    x = Conv2D(filters3, (1, 1), name=name_base + 'conv3')(x)
    x = BatchNormalization(name=name_base + 'bn3')(x)

    # SE-Net通道注意力机制
    x = squeeze_excite_block(x)

    # 残差连接
    x = layers.add([x, input_tensor], name=name_base + 'add')
    x = Activation('relu', name=name_base + 'relu4')(x)

    return x


def conv_block(input_tensor, kernel_size, filters, stage, block, strides=(2, 2)):
    filters1, filters2, filters3 = filters
    res_name_base = str(stage) + block + '_conv_block_res_'
    name_base = str(stage) + block + '_conv_block_'

    # 主卷积层
    x = Conv2D(filters1, (1, 1), strides=strides, name=name_base + 'conv1')(input_tensor)
    x = BatchNormalization(name=name_base + 'bn1')(x)
    x = Activation('relu', name=name_base + 'relu1')(x)

    x = Conv2D(filters2, kernel_size, padding='same', name=name_base + 'conv2')(x)
    x = BatchNormalization(name=name_base + 'bn2')(x)
    x = Activation('relu', name=name_base + 'relu2')(x)

    x = Conv2D(filters3, (1, 1), name=name_base + 'conv3')(x)
    x = BatchNormalization(name=name_base + 'bn3')(x)

    # 残差连接的卷积
    shortcut = Conv2D(filters3, (1, 1), strides=strides, name=res_name_base + 'conv')(input_tensor)
    shortcut = BatchNormalization(name=res_name_base + 'bn')(shortcut)

    # SE-Net通道注意力机制
    x = squeeze_excite_block(x)

    # 残差连接加和
    x = layers.add([x, shortcut], name=name_base + 'add')
    x = Activation('relu', name=name_base + 'relu4')(x)

    return x
def ResNet50(input_shape=[224,224,3], classes=4):
    img_input = Input(shape=input_shape)
    x = ZeroPadding2D((3, 3))(img_input)

    x = Conv2D(64, (7, 7), strides=(2, 2), name='conv1')(x)
    x = BatchNormalization(name='bn_conv1')(x)
    x = Activation('relu')(x)
    x = MaxPooling2D((3, 3), strides=(2, 2))(x)

    x = conv_block(x, 3, [64, 64, 256], stage=2, block='a', strides=(1, 1))
    x = identity_block(x, 3, [64, 64, 256], stage=2, block='b')
    x = identity_block(x, 3, [64, 64, 256], stage=2, block='c')

    x = conv_block(x, 3, [128, 128, 512], stage=3, block='a')
    x = identity_block(x, 3, [128, 128, 512], stage=3, block='b')
    x = identity_block(x, 3, [128, 128, 512], stage=3, block='c')
    x = identity_block(x, 3, [128, 128, 512], stage=3, block='d')

    x = conv_block(x, 3, [256, 256, 1024], stage=4, block='a')
    x = identity_block(x, 3, [256, 256, 1024], stage=4, block='b')
    x = identity_block(x, 3, [256, 256, 1024], stage=4, block='c')
    x = identity_block(x, 3, [256, 256, 1024], stage=4, block='d')
    x = identity_block(x, 3, [256, 256, 1024], stage=4, block='e')
    x = identity_block(x, 3, [256, 256, 1024], stage=4, block='f')

    x = conv_block(x, 3, [512, 512, 2048], stage=5, block='a')
    x = identity_block(x, 3, [512, 512, 2048], stage=5, block='b')
    x = identity_block(x, 3, [512, 512, 2048], stage=5, block='c')

    x = AveragePooling2D((7, 7), name='avg_pool')(x)

    x = Flatten()(x)
    x = Dropout(0.5)(x)
    x = Dense(classes, activation='softmax', name='fc2')(x)

    model = Model(img_input, x, name='resnet50')

    return model

model = ResNet50()
model.summary()

 

Model: "resnet50"
__________________________________________________________________________________________________
 Layer (type)                   Output Shape         Param #     Connected to                     
==================================================================================================
 input_1 (InputLayer)           [(None, 224, 224, 3  0           []                               
                                )]                                                                
                                                                                                  
 zero_padding2d (ZeroPadding2D)  (None, 230, 230, 3)  0          ['input_1[0][0]']                
                                                                                                  
 conv1 (Conv2D)                 (None, 112, 112, 64  9472        ['zero_padding2d[0][0]']         
                                )                                                                 
                                                                                                  
 bn_conv1 (BatchNormalization)  (None, 112, 112, 64  256         ['conv1[0][0]']                  
                                )                                                                 
                                                                                                  
 activation (Activation)        (None, 112, 112, 64  0           ['bn_conv1[0][0]']               
                                )                                                                 
                                                                                                  
 max_pooling2d (MaxPooling2D)   (None, 55, 55, 64)   0           ['activation[0][0]']             
                                                                                                  
 2a_conv_block_conv1 (Conv2D)   (None, 55, 55, 64)   4160        ['max_pooling2d[0][0]']          
                                                                                                  
 2a_conv_block_bn1 (BatchNormal  (None, 55, 55, 64)  256         ['2a_conv_block_conv1[0][0]']    
 ization)                                                                                         
                                                                                                  
 2a_conv_block_relu1 (Activatio  (None, 55, 55, 64)  0           ['2a_conv_block_bn1[0][0]']      
 n)                                                                                               
                                                                                                  
 2a_conv_block_conv2 (Conv2D)   (None, 55, 55, 64)   36928       ['2a_conv_block_relu1[0][0]']    
                                                                                                  
 2a_conv_block_bn2 (BatchNormal  (None, 55, 55, 64)  256         ['2a_conv_block_conv2[0][0]']    
 ization)                                                                                         
                                                                                                  
 2a_conv_block_relu2 (Activatio  (None, 55, 55, 64)  0           ['2a_conv_block_bn2[0][0]']      
 n)                                                                                               
                                                                                                  
 2a_conv_block_conv3 (Conv2D)   (None, 55, 55, 256)  16640       ['2a_conv_block_relu2[0][0]']    
                                                                                                  
 2a_conv_block_bn3 (BatchNormal  (None, 55, 55, 256)  1024       ['2a_conv_block_conv3[0][0]']    
 ization)                                                                                         
                                                                                                  
 global_average_pooling2d (Glob  (None, 256)         0           ['2a_conv_block_bn3[0][0]']      
 alAveragePooling2D)                                                                              
                                                                                                  
 reshape (Reshape)              (None, 1, 1, 256)    0           ['global_average_pooling2d[0][0]'
                                                                 ]                                
                                                                                                  
 dense (Dense)                  (None, 1, 1, 16)     4096        ['reshape[0][0]']                
                                                                                                  
 dense_1 (Dense)                (None, 1, 1, 256)    4096        ['dense[0][0]']                  
                                                                                                  
 2a_conv_block_res_conv (Conv2D  (None, 55, 55, 256)  16640      ['max_pooling2d[0][0]']          
 )                                                                                                
                                                                                                  
 multiply (Multiply)            (None, 55, 55, 256)  0           ['2a_conv_block_bn3[0][0]',      
                                                                  'dense_1[0][0]']                
                                                                                                  
 2a_conv_block_res_bn (BatchNor  (None, 55, 55, 256)  1024       ['2a_conv_block_res_conv[0][0]'] 
 malization)                                                                                      
                                                                                                  
 2a_conv_block_add (Add)        (None, 55, 55, 256)  0           ['multiply[0][0]',               
                                                                  '2a_conv_block_res_bn[0][0]']   
                                                                                                  
 2a_conv_block_relu4 (Activatio  (None, 55, 55, 256)  0          ['2a_conv_block_add[0][0]']      
 n)                                                                                               
                                                                                                  
 2b_identity_block_conv1 (Conv2  (None, 55, 55, 64)  16448       ['2a_conv_block_relu4[0][0]']    
 D)                                                                                               
                                                                                                  
 2b_identity_block_bn1 (BatchNo  (None, 55, 55, 64)  256         ['2b_identity_block_conv1[0][0]']
 rmalization)                                                                                     
                                                                                                  
 2b_identity_block_relu1 (Activ  (None, 55, 55, 64)  0           ['2b_identity_block_bn1[0][0]']  
 ation)                                                                                           
                                                                                                  
 2b_identity_block_conv2 (Conv2  (None, 55, 55, 64)  36928       ['2b_identity_block_relu1[0][0]']
 D)                                                                                               
                                                                                                  
 2b_identity_block_bn2 (BatchNo  (None, 55, 55, 64)  256         ['2b_identity_block_conv2[0][0]']
 rmalization)                                                                                     
                                                                                                  
 2b_identity_block_relu2 (Activ  (None, 55, 55, 64)  0           ['2b_identity_block_bn2[0][0]']  
 ation)                                                                                           
                                                                                                  
 2b_identity_block_conv3 (Conv2  (None, 55, 55, 256)  16640      ['2b_identity_block_relu2[0][0]']
 D)                                                                                               
                                                                                                  
 2b_identity_block_bn3 (BatchNo  (None, 55, 55, 256)  1024       ['2b_identity_block_conv3[0][0]']
 rmalization)                                                                                     
                                                                                                  
 global_average_pooling2d_1 (Gl  (None, 256)         0           ['2b_identity_block_bn3[0][0]']  
 obalAveragePooling2D)                                                                            
                                                                                                  
 reshape_1 (Reshape)            (None, 1, 1, 256)    0           ['global_average_pooling2d_1[0][0
                                                                 ]']                              
                                                                                                  
 dense_2 (Dense)                (None, 1, 1, 16)     4096        ['reshape_1[0][0]']              
                                                                                                  
 dense_3 (Dense)                (None, 1, 1, 256)    4096        ['dense_2[0][0]']                
                                                                                                  
 multiply_1 (Multiply)          (None, 55, 55, 256)  0           ['2b_identity_block_bn3[0][0]',  
                                                                  'dense_3[0][0]']                
                                                                                                  
 2b_identity_block_add (Add)    (None, 55, 55, 256)  0           ['multiply_1[0][0]',             
                                                                  '2a_conv_block_relu4[0][0]']    
                                                                                                  
 2b_identity_block_relu4 (Activ  (None, 55, 55, 256)  0          ['2b_identity_block_add[0][0]']  
 ation)                                                                                           
                                                                                                  
 2c_identity_block_conv1 (Conv2  (None, 55, 55, 64)  16448       ['2b_identity_block_relu4[0][0]']
 D)                                                                                               
                                                                                                  
 2c_identity_block_bn1 (BatchNo  (None, 55, 55, 64)  256         ['2c_identity_block_conv1[0][0]']
 rmalization)                                                                                     
                                                                                                  
 2c_identity_block_relu1 (Activ  (None, 55, 55, 64)  0           ['2c_identity_block_bn1[0][0]']  
 ation)                                                                                           
                                                                                                  
 2c_identity_block_conv2 (Conv2  (None, 55, 55, 64)  36928       ['2c_identity_block_relu1[0][0]']
 D)                                                                                               
                                                                                                  
 2c_identity_block_bn2 (BatchNo  (None, 55, 55, 64)  256         ['2c_identity_block_conv2[0][0]']
 rmalization)                                                                                     
                                                                                                  
 2c_identity_block_relu2 (Activ  (None, 55, 55, 64)  0           ['2c_identity_block_bn2[0][0]']  
 ation)                                                                                           
                                                                                                  
 2c_identity_block_conv3 (Conv2  (None, 55, 55, 256)  16640      ['2c_identity_block_relu2[0][0]']
 D)                                                                                               
                                                                                                  
 2c_identity_block_bn3 (BatchNo  (None, 55, 55, 256)  1024       ['2c_identity_block_conv3[0][0]']
 rmalization)                                                                                     
                                                                                                  
 global_average_pooling2d_2 (Gl  (None, 256)         0           ['2c_identity_block_bn3[0][0]']  
 obalAveragePooling2D)                                                                            
                                                                                                  
 reshape_2 (Reshape)            (None, 1, 1, 256)    0           ['global_average_pooling2d_2[0][0
                                                                 ]']                              
                                                                                                  
 dense_4 (Dense)                (None, 1, 1, 16)     4096        ['reshape_2[0][0]']              
                                                                                                  
 dense_5 (Dense)                (None, 1, 1, 256)    4096        ['dense_4[0][0]']                
                                                                                                  
 multiply_2 (Multiply)          (None, 55, 55, 256)  0           ['2c_identity_block_bn3[0][0]',  
                                                                  'dense_5[0][0]']                
                                                                                                  
 2c_identity_block_add (Add)    (None, 55, 55, 256)  0           ['multiply_2[0][0]',             
                                                                  '2b_identity_block_relu4[0][0]']
                                                                                                  
 2c_identity_block_relu4 (Activ  (None, 55, 55, 256)  0          ['2c_identity_block_add[0][0]']  
 ation)                                                                                           
                                                                                                  
 3a_conv_block_conv1 (Conv2D)   (None, 28, 28, 128)  32896       ['2c_identity_block_relu4[0][0]']
                                                                                                  
 3a_conv_block_bn1 (BatchNormal  (None, 28, 28, 128)  512        ['3a_conv_block_conv1[0][0]']    
 ization)                                                                                         
                                                                                                  
 3a_conv_block_relu1 (Activatio  (None, 28, 28, 128)  0          ['3a_conv_block_bn1[0][0]']      
 n)                                                                                               
                                                                                                  
 3a_conv_block_conv2 (Conv2D)   (None, 28, 28, 128)  147584      ['3a_conv_block_relu1[0][0]']    
                                                                                                  
 3a_conv_block_bn2 (BatchNormal  (None, 28, 28, 128)  512        ['3a_conv_block_conv2[0][0]']    
 ization)                                                                                         
                                                                                                  
 3a_conv_block_relu2 (Activatio  (None, 28, 28, 128)  0          ['3a_conv_block_bn2[0][0]']      
 n)                                                                                               
                                                                                                  
 3a_conv_block_conv3 (Conv2D)   (None, 28, 28, 512)  66048       ['3a_conv_block_relu2[0][0]']    
                                                                                                  
 3a_conv_block_bn3 (BatchNormal  (None, 28, 28, 512)  2048       ['3a_conv_block_conv3[0][0]']    
 ization)                                                                                         
                                                                                                  
 global_average_pooling2d_3 (Gl  (None, 512)         0           ['3a_conv_block_bn3[0][0]']      
 obalAveragePooling2D)                                                                            
                                                                                                  
 reshape_3 (Reshape)            (None, 1, 1, 512)    0           ['global_average_pooling2d_3[0][0
                                                                 ]']                              
                                                                                                  
 dense_6 (Dense)                (None, 1, 1, 32)     16384       ['reshape_3[0][0]']              
                                                                                                  
 dense_7 (Dense)                (None, 1, 1, 512)    16384       ['dense_6[0][0]']                
                                                                                                  
 3a_conv_block_res_conv (Conv2D  (None, 28, 28, 512)  131584     ['2c_identity_block_relu4[0][0]']
 )                                                                                                
                                                                                                  
 multiply_3 (Multiply)          (None, 28, 28, 512)  0           ['3a_conv_block_bn3[0][0]',      
                                                                  'dense_7[0][0]']                
                                                                                                  
 3a_conv_block_res_bn (BatchNor  (None, 28, 28, 512)  2048       ['3a_conv_block_res_conv[0][0]'] 
 malization)                                                                                      
                                                                                                  
 3a_conv_block_add (Add)        (None, 28, 28, 512)  0           ['multiply_3[0][0]',             
                                                                  '3a_conv_block_res_bn[0][0]']   
                                                                                                  
 3a_conv_block_relu4 (Activatio  (None, 28, 28, 512)  0          ['3a_conv_block_add[0][0]']      
 n)                                                                                               
                                                                                                  
 3b_identity_block_conv1 (Conv2  (None, 28, 28, 128)  65664      ['3a_conv_block_relu4[0][0]']    
 D)                                                                                               
                                                                                                  
 3b_identity_block_bn1 (BatchNo  (None, 28, 28, 128)  512        ['3b_identity_block_conv1[0][0]']
 rmalization)                                                                                     
                                                                                                  
 3b_identity_block_relu1 (Activ  (None, 28, 28, 128)  0          ['3b_identity_block_bn1[0][0]']  
 ation)                                                                                           
                                                                                                  
 3b_identity_block_conv2 (Conv2  (None, 28, 28, 128)  147584     ['3b_identity_block_relu1[0][0]']
 D)                                                                                               
                                                                                                  
 3b_identity_block_bn2 (BatchNo  (None, 28, 28, 128)  512        ['3b_identity_block_conv2[0][0]']
 rmalization)                                                                                     
                                                                                                  
 3b_identity_block_relu2 (Activ  (None, 28, 28, 128)  0          ['3b_identity_block_bn2[0][0]']  
 ation)                                                                                           
                                                                                                  
 3b_identity_block_conv3 (Conv2  (None, 28, 28, 512)  66048      ['3b_identity_block_relu2[0][0]']
 D)                                                                                               
                                                                                                  
 3b_identity_block_bn3 (BatchNo  (None, 28, 28, 512)  2048       ['3b_identity_block_conv3[0][0]']
 rmalization)                                                                                     
                                                                                                  
 global_average_pooling2d_4 (Gl  (None, 512)         0           ['3b_identity_block_bn3[0][0]']  
 obalAveragePooling2D)                                                                            
                                                                                                  
 reshape_4 (Reshape)            (None, 1, 1, 512)    0           ['global_average_pooling2d_4[0][0
                                                                 ]']                              
                                                                                                  
 dense_8 (Dense)                (None, 1, 1, 32)     16384       ['reshape_4[0][0]']              
                                                                                                  
 dense_9 (Dense)                (None, 1, 1, 512)    16384       ['dense_8[0][0]']                
                                                                                                  
 multiply_4 (Multiply)          (None, 28, 28, 512)  0           ['3b_identity_block_bn3[0][0]',  
                                                                  'dense_9[0][0]']                
                                                                                                  
 3b_identity_block_add (Add)    (None, 28, 28, 512)  0           ['multiply_4[0][0]',             
                                                                  '3a_conv_block_relu4[0][0]']    
                                                                                                  
 3b_identity_block_relu4 (Activ  (None, 28, 28, 512)  0          ['3b_identity_block_add[0][0]']  
 ation)                                                                                           
                                                                                                  
 3c_identity_block_conv1 (Conv2  (None, 28, 28, 128)  65664      ['3b_identity_block_relu4[0][0]']
 D)                                                                                               
                                                                                                  
 3c_identity_block_bn1 (BatchNo  (None, 28, 28, 128)  512        ['3c_identity_block_conv1[0][0]']
 rmalization)                                                                                     
                                                                                                  
 3c_identity_block_relu1 (Activ  (None, 28, 28, 128)  0          ['3c_identity_block_bn1[0][0]']  
 ation)                                                                                           
                                                                                                  
 3c_identity_block_conv2 (Conv2  (None, 28, 28, 128)  147584     ['3c_identity_block_relu1[0][0]']
 D)                                                                                               
                                                                                                  
 3c_identity_block_bn2 (BatchNo  (None, 28, 28, 128)  512        ['3c_identity_block_conv2[0][0]']
 rmalization)                                                                                     
                                                                                                  
 3c_identity_block_relu2 (Activ  (None, 28, 28, 128)  0          ['3c_identity_block_bn2[0][0]']  
 ation)                                                                                           
                                                                                                  
 3c_identity_block_conv3 (Conv2  (None, 28, 28, 512)  66048      ['3c_identity_block_relu2[0][0]']
 D)                                                                                               
                                                                                                  
 3c_identity_block_bn3 (BatchNo  (None, 28, 28, 512)  2048       ['3c_identity_block_conv3[0][0]']
 rmalization)                                                                                     
                                                                                                  
 global_average_pooling2d_5 (Gl  (None, 512)         0           ['3c_identity_block_bn3[0][0]']  
 obalAveragePooling2D)                                                                            
                                                                                                  
 reshape_5 (Reshape)            (None, 1, 1, 512)    0           ['global_average_pooling2d_5[0][0
                                                                 ]']                              
                                                                                                  
 dense_10 (Dense)               (None, 1, 1, 32)     16384       ['reshape_5[0][0]']              
                                                                                                  
 dense_11 (Dense)               (None, 1, 1, 512)    16384       ['dense_10[0][0]']               
                                                                                                  
 multiply_5 (Multiply)          (None, 28, 28, 512)  0           ['3c_identity_block_bn3[0][0]',  
                                                                  'dense_11[0][0]']               
                                                                                                  
 3c_identity_block_add (Add)    (None, 28, 28, 512)  0           ['multiply_5[0][0]',             
                                                                  '3b_identity_block_relu4[0][0]']
                                                                                                  
 3c_identity_block_relu4 (Activ  (None, 28, 28, 512)  0          ['3c_identity_block_add[0][0]']  
 ation)                                                                                           
                                                                                                  
 3d_identity_block_conv1 (Conv2  (None, 28, 28, 128)  65664      ['3c_identity_block_relu4[0][0]']
 D)                                                                                               
                                                                                                  
 3d_identity_block_bn1 (BatchNo  (None, 28, 28, 128)  512        ['3d_identity_block_conv1[0][0]']
 rmalization)                                                                                     
                                                                                                  
 3d_identity_block_relu1 (Activ  (None, 28, 28, 128)  0          ['3d_identity_block_bn1[0][0]']  
 ation)                                                                                           
                                                                                                  
 3d_identity_block_conv2 (Conv2  (None, 28, 28, 128)  147584     ['3d_identity_block_relu1[0][0]']
 D)                                                                                               
                                                                                                  
 3d_identity_block_bn2 (BatchNo  (None, 28, 28, 128)  512        ['3d_identity_block_conv2[0][0]']
 rmalization)                                                                                     
                                                                                                  
 3d_identity_block_relu2 (Activ  (None, 28, 28, 128)  0          ['3d_identity_block_bn2[0][0]']  
 ation)                                                                                           
                                                                                                  
 3d_identity_block_conv3 (Conv2  (None, 28, 28, 512)  66048      ['3d_identity_block_relu2[0][0]']
 D)                                                                                               
                                                                                                  
 3d_identity_block_bn3 (BatchNo  (None, 28, 28, 512)  2048       ['3d_identity_block_conv3[0][0]']
 rmalization)                                                                                     
                                                                                                  
 global_average_pooling2d_6 (Gl  (None, 512)         0           ['3d_identity_block_bn3[0][0]']  
 obalAveragePooling2D)                                                                            
                                                                                                  
 reshape_6 (Reshape)            (None, 1, 1, 512)    0           ['global_average_pooling2d_6[0][0
                                                                 ]']                              
                                                                                                  
 dense_12 (Dense)               (None, 1, 1, 32)     16384       ['reshape_6[0][0]']              
                                                                                                  
 dense_13 (Dense)               (None, 1, 1, 512)    16384       ['dense_12[0][0]']               
                                                                                                  
 multiply_6 (Multiply)          (None, 28, 28, 512)  0           ['3d_identity_block_bn3[0][0]',  
                                                                  'dense_13[0][0]']               
                                                                                                  
 3d_identity_block_add (Add)    (None, 28, 28, 512)  0           ['multiply_6[0][0]',             
                                                                  '3c_identity_block_relu4[0][0]']
                                                                                                  
 3d_identity_block_relu4 (Activ  (None, 28, 28, 512)  0          ['3d_identity_block_add[0][0]']  
 ation)                                                                                           
                                                                                                  
 4a_conv_block_conv1 (Conv2D)   (None, 14, 14, 256)  131328      ['3d_identity_block_relu4[0][0]']
                                                                                                  
 4a_conv_block_bn1 (BatchNormal  (None, 14, 14, 256)  1024       ['4a_conv_block_conv1[0][0]']    
 ization)                                                                                         
                                                                                                  
 4a_conv_block_relu1 (Activatio  (None, 14, 14, 256)  0          ['4a_conv_block_bn1[0][0]']      
 n)                                                                                               
                                                                                                  
 4a_conv_block_conv2 (Conv2D)   (None, 14, 14, 256)  590080      ['4a_conv_block_relu1[0][0]']    
                                                                                                  
 4a_conv_block_bn2 (BatchNormal  (None, 14, 14, 256)  1024       ['4a_conv_block_conv2[0][0]']    
 ization)                                                                                         
                                                                                                  
 4a_conv_block_relu2 (Activatio  (None, 14, 14, 256)  0          ['4a_conv_block_bn2[0][0]']      
 n)                                                                                               
                                                                                                  
 4a_conv_block_conv3 (Conv2D)   (None, 14, 14, 1024  263168      ['4a_conv_block_relu2[0][0]']    
                                )                                                                 
                                                                                                  
 4a_conv_block_bn3 (BatchNormal  (None, 14, 14, 1024  4096       ['4a_conv_block_conv3[0][0]']    
 ization)                       )                                                                 
                                                                                                  
 global_average_pooling2d_7 (Gl  (None, 1024)        0           ['4a_conv_block_bn3[0][0]']      
 obalAveragePooling2D)                                                                            
                                                                                                  
 reshape_7 (Reshape)            (None, 1, 1, 1024)   0           ['global_average_pooling2d_7[0][0
                                                                 ]']                              
                                                                                                  
 dense_14 (Dense)               (None, 1, 1, 64)     65536       ['reshape_7[0][0]']              
                                                                                                  
 dense_15 (Dense)               (None, 1, 1, 1024)   65536       ['dense_14[0][0]']               
                                                                                                  
 4a_conv_block_res_conv (Conv2D  (None, 14, 14, 1024  525312     ['3d_identity_block_relu4[0][0]']
 )                              )                                                                 
                                                                                                  
 multiply_7 (Multiply)          (None, 14, 14, 1024  0           ['4a_conv_block_bn3[0][0]',      
                                )                                 'dense_15[0][0]']               
                                                                                                  
 4a_conv_block_res_bn (BatchNor  (None, 14, 14, 1024  4096       ['4a_conv_block_res_conv[0][0]'] 
 malization)                    )                                                                 
                                                                                                  
 4a_conv_block_add (Add)        (None, 14, 14, 1024  0           ['multiply_7[0][0]',             
                                )                                 '4a_conv_block_res_bn[0][0]']   
                                                                                                  
 4a_conv_block_relu4 (Activatio  (None, 14, 14, 1024  0          ['4a_conv_block_add[0][0]']      
 n)                             )                                                                 
                                                                                                  
 4b_identity_block_conv1 (Conv2  (None, 14, 14, 256)  262400     ['4a_conv_block_relu4[0][0]']    
 D)                                                                                               
                                                                                                  
 4b_identity_block_bn1 (BatchNo  (None, 14, 14, 256)  1024       ['4b_identity_block_conv1[0][0]']
 rmalization)                                                                                     
                                                                                                  
 4b_identity_block_relu1 (Activ  (None, 14, 14, 256)  0          ['4b_identity_block_bn1[0][0]']  
 ation)                                                                                           
                                                                                                  
 4b_identity_block_conv2 (Conv2  (None, 14, 14, 256)  590080     ['4b_identity_block_relu1[0][0]']
 D)                                                                                               
                                                                                                  
 4b_identity_block_bn2 (BatchNo  (None, 14, 14, 256)  1024       ['4b_identity_block_conv2[0][0]']
 rmalization)                                                                                     
                                                                                                  
 4b_identity_block_relu2 (Activ  (None, 14, 14, 256)  0          ['4b_identity_block_bn2[0][0]']  
 ation)                                                                                           
                                                                                                  
 4b_identity_block_conv3 (Conv2  (None, 14, 14, 1024  263168     ['4b_identity_block_relu2[0][0]']
 D)                             )                                                                 
                                                                                                  
 4b_identity_block_bn3 (BatchNo  (None, 14, 14, 1024  4096       ['4b_identity_block_conv3[0][0]']
 rmalization)                   )                                                                 
                                                                                                  
 global_average_pooling2d_8 (Gl  (None, 1024)        0           ['4b_identity_block_bn3[0][0]']  
 obalAveragePooling2D)                                                                            
                                                                                                  
 reshape_8 (Reshape)            (None, 1, 1, 1024)   0           ['global_average_pooling2d_8[0][0
                                                                 ]']                              
                                                                                                  
 dense_16 (Dense)               (None, 1, 1, 64)     65536       ['reshape_8[0][0]']              
                                                                                                  
 dense_17 (Dense)               (None, 1, 1, 1024)   65536       ['dense_16[0][0]']               
                                                                                                  
 multiply_8 (Multiply)          (None, 14, 14, 1024  0           ['4b_identity_block_bn3[0][0]',  
                                )                                 'dense_17[0][0]']               
                                                                                                  
 4b_identity_block_add (Add)    (None, 14, 14, 1024  0           ['multiply_8[0][0]',             
                                )                                 '4a_conv_block_relu4[0][0]']    
                                                                                                  
 4b_identity_block_relu4 (Activ  (None, 14, 14, 1024  0          ['4b_identity_block_add[0][0]']  
 ation)                         )                                                                 
                                                                                                  
 4c_identity_block_conv1 (Conv2  (None, 14, 14, 256)  262400     ['4b_identity_block_relu4[0][0]']
 D)                                                                                               
                                                                                                  
 4c_identity_block_bn1 (BatchNo  (None, 14, 14, 256)  1024       ['4c_identity_block_conv1[0][0]']
 rmalization)                                                                                     
                                                                                                  
 4c_identity_block_relu1 (Activ  (None, 14, 14, 256)  0          ['4c_identity_block_bn1[0][0]']  
 ation)                                                                                           
                                                                                                  
 4c_identity_block_conv2 (Conv2  (None, 14, 14, 256)  590080     ['4c_identity_block_relu1[0][0]']
 D)                                                                                               
                                                                                                  
 4c_identity_block_bn2 (BatchNo  (None, 14, 14, 256)  1024       ['4c_identity_block_conv2[0][0]']
 rmalization)                                                                                     
                                                                                                  
 4c_identity_block_relu2 (Activ  (None, 14, 14, 256)  0          ['4c_identity_block_bn2[0][0]']  
 ation)                                                                                           
                                                                                                  
 4c_identity_block_conv3 (Conv2  (None, 14, 14, 1024  263168     ['4c_identity_block_relu2[0][0]']
 D)                             )                                                                 
                                                                                                  
 4c_identity_block_bn3 (BatchNo  (None, 14, 14, 1024  4096       ['4c_identity_block_conv3[0][0]']
 rmalization)                   )                                                                 
                                                                                                  
 global_average_pooling2d_9 (Gl  (None, 1024)        0           ['4c_identity_block_bn3[0][0]']  
 obalAveragePooling2D)                                                                            
                                                                                                  
 reshape_9 (Reshape)            (None, 1, 1, 1024)   0           ['global_average_pooling2d_9[0][0
                                                                 ]']                              
                                                                                                  
 dense_18 (Dense)               (None, 1, 1, 64)     65536       ['reshape_9[0][0]']              
                                                                                                  
 dense_19 (Dense)               (None, 1, 1, 1024)   65536       ['dense_18[0][0]']               
                                                                                                  
 multiply_9 (Multiply)          (None, 14, 14, 1024  0           ['4c_identity_block_bn3[0][0]',  
                                )                                 'dense_19[0][0]']               
                                                                                                  
 4c_identity_block_add (Add)    (None, 14, 14, 1024  0           ['multiply_9[0][0]',             
                                )                                 '4b_identity_block_relu4[0][0]']
                                                                                                  
 4c_identity_block_relu4 (Activ  (None, 14, 14, 1024  0          ['4c_identity_block_add[0][0]']  
 ation)                         )                                                                 
                                                                                                  
 4d_identity_block_conv1 (Conv2  (None, 14, 14, 256)  262400     ['4c_identity_block_relu4[0][0]']
 D)                                                                                               
                                                                                                  
 4d_identity_block_bn1 (BatchNo  (None, 14, 14, 256)  1024       ['4d_identity_block_conv1[0][0]']
 rmalization)                                                                                     
                                                                                                  
 4d_identity_block_relu1 (Activ  (None, 14, 14, 256)  0          ['4d_identity_block_bn1[0][0]']  
 ation)                                                                                           
                                                                                                  
 4d_identity_block_conv2 (Conv2  (None, 14, 14, 256)  590080     ['4d_identity_block_relu1[0][0]']
 D)                                                                                               
                                                                                                  
 4d_identity_block_bn2 (BatchNo  (None, 14, 14, 256)  1024       ['4d_identity_block_conv2[0][0]']
 rmalization)                                                                                     
                                                                                                  
 4d_identity_block_relu2 (Activ  (None, 14, 14, 256)  0          ['4d_identity_block_bn2[0][0]']  
 ation)                                                                                           
                                                                                                  
 4d_identity_block_conv3 (Conv2  (None, 14, 14, 1024  263168     ['4d_identity_block_relu2[0][0]']
 D)                             )                                                                 
                                                                                                  
 4d_identity_block_bn3 (BatchNo  (None, 14, 14, 1024  4096       ['4d_identity_block_conv3[0][0]']
 rmalization)                   )                                                                 
                                                                                                  
 global_average_pooling2d_10 (G  (None, 1024)        0           ['4d_identity_block_bn3[0][0]']  
 lobalAveragePooling2D)                                                                           
                                                                                                  
 reshape_10 (Reshape)           (None, 1, 1, 1024)   0           ['global_average_pooling2d_10[0][
                                                                 0]']                             
                                                                                                  
 dense_20 (Dense)               (None, 1, 1, 64)     65536       ['reshape_10[0][0]']             
                                                                                                  
 dense_21 (Dense)               (None, 1, 1, 1024)   65536       ['dense_20[0][0]']               
                                                                                                  
 multiply_10 (Multiply)         (None, 14, 14, 1024  0           ['4d_identity_block_bn3[0][0]',  
                                )                                 'dense_21[0][0]']               
                                                                                                  
 4d_identity_block_add (Add)    (None, 14, 14, 1024  0           ['multiply_10[0][0]',            
                                )                                 '4c_identity_block_relu4[0][0]']
                                                                                                  
 4d_identity_block_relu4 (Activ  (None, 14, 14, 1024  0          ['4d_identity_block_add[0][0]']  
 ation)                         )                                                                 
                                                                                                  
 4e_identity_block_conv1 (Conv2  (None, 14, 14, 256)  262400     ['4d_identity_block_relu4[0][0]']
 D)                                                                                               
                                                                                                  
 4e_identity_block_bn1 (BatchNo  (None, 14, 14, 256)  1024       ['4e_identity_block_conv1[0][0]']
 rmalization)                                                                                     
                                                                                                  
 4e_identity_block_relu1 (Activ  (None, 14, 14, 256)  0          ['4e_identity_block_bn1[0][0]']  
 ation)                                                                                           
                                                                                                  
 4e_identity_block_conv2 (Conv2  (None, 14, 14, 256)  590080     ['4e_identity_block_relu1[0][0]']
 D)                                                                                               
                                                                                                  
 4e_identity_block_bn2 (BatchNo  (None, 14, 14, 256)  1024       ['4e_identity_block_conv2[0][0]']
 rmalization)                                                                                     
                                                                                                  
 4e_identity_block_relu2 (Activ  (None, 14, 14, 256)  0          ['4e_identity_block_bn2[0][0]']  
 ation)                                                                                           
                                                                                                  
 4e_identity_block_conv3 (Conv2  (None, 14, 14, 1024  263168     ['4e_identity_block_relu2[0][0]']
 D)                             )                                                                 
                                                                                                  
 4e_identity_block_bn3 (BatchNo  (None, 14, 14, 1024  4096       ['4e_identity_block_conv3[0][0]']
 rmalization)                   )                                                                 
                                                                                                  
 global_average_pooling2d_11 (G  (None, 1024)        0           ['4e_identity_block_bn3[0][0]']  
 lobalAveragePooling2D)                                                                           
                                                                                                  
 reshape_11 (Reshape)           (None, 1, 1, 1024)   0           ['global_average_pooling2d_11[0][
                                                                 0]']                             
                                                                                                  
 dense_22 (Dense)               (None, 1, 1, 64)     65536       ['reshape_11[0][0]']             
                                                                                                  
 dense_23 (Dense)               (None, 1, 1, 1024)   65536       ['dense_22[0][0]']               
                                                                                                  
 multiply_11 (Multiply)         (None, 14, 14, 1024  0           ['4e_identity_block_bn3[0][0]',  
                                )                                 'dense_23[0][0]']               
                                                                                                  
 4e_identity_block_add (Add)    (None, 14, 14, 1024  0           ['multiply_11[0][0]',            
                                )                                 '4d_identity_block_relu4[0][0]']
                                                                                                  
 4e_identity_block_relu4 (Activ  (None, 14, 14, 1024  0          ['4e_identity_block_add[0][0]']  
 ation)                         )                                                                 
                                                                                                  
 4f_identity_block_conv1 (Conv2  (None, 14, 14, 256)  262400     ['4e_identity_block_relu4[0][0]']
 D)                                                                                               
                                                                                                  
 4f_identity_block_bn1 (BatchNo  (None, 14, 14, 256)  1024       ['4f_identity_block_conv1[0][0]']
 rmalization)                                                                                     
                                                                                                  
 4f_identity_block_relu1 (Activ  (None, 14, 14, 256)  0          ['4f_identity_block_bn1[0][0]']  
 ation)                                                                                           
                                                                                                  
 4f_identity_block_conv2 (Conv2  (None, 14, 14, 256)  590080     ['4f_identity_block_relu1[0][0]']
 D)                                                                                               
                                                                                                  
 4f_identity_block_bn2 (BatchNo  (None, 14, 14, 256)  1024       ['4f_identity_block_conv2[0][0]']
 rmalization)                                                                                     
                                                                                                  
 4f_identity_block_relu2 (Activ  (None, 14, 14, 256)  0          ['4f_identity_block_bn2[0][0]']  
 ation)                                                                                           
                                                                                                  
 4f_identity_block_conv3 (Conv2  (None, 14, 14, 1024  263168     ['4f_identity_block_relu2[0][0]']
 D)                             )                                                                 
                                                                                                  
 4f_identity_block_bn3 (BatchNo  (None, 14, 14, 1024  4096       ['4f_identity_block_conv3[0][0]']
 rmalization)                   )                                                                 
                                                                                                  
 global_average_pooling2d_12 (G  (None, 1024)        0           ['4f_identity_block_bn3[0][0]']  
 lobalAveragePooling2D)                                                                           
                                                                                                  
 reshape_12 (Reshape)           (None, 1, 1, 1024)   0           ['global_average_pooling2d_12[0][
                                                                 0]']                             
                                                                                                  
 dense_24 (Dense)               (None, 1, 1, 64)     65536       ['reshape_12[0][0]']             
                                                                                                  
 dense_25 (Dense)               (None, 1, 1, 1024)   65536       ['dense_24[0][0]']               
                                                                                                  
 multiply_12 (Multiply)         (None, 14, 14, 1024  0           ['4f_identity_block_bn3[0][0]',  
                                )                                 'dense_25[0][0]']               
                                                                                                  
 4f_identity_block_add (Add)    (None, 14, 14, 1024  0           ['multiply_12[0][0]',            
                                )                                 '4e_identity_block_relu4[0][0]']
                                                                                                  
 4f_identity_block_relu4 (Activ  (None, 14, 14, 1024  0          ['4f_identity_block_add[0][0]']  
 ation)                         )                                                                 
                                                                                                  
 5a_conv_block_conv1 (Conv2D)   (None, 7, 7, 512)    524800      ['4f_identity_block_relu4[0][0]']
                                                                                                  
 5a_conv_block_bn1 (BatchNormal  (None, 7, 7, 512)   2048        ['5a_conv_block_conv1[0][0]']    
 ization)                                                                                         
                                                                                                  
 5a_conv_block_relu1 (Activatio  (None, 7, 7, 512)   0           ['5a_conv_block_bn1[0][0]']      
 n)                                                                                               
                                                                                                  
 5a_conv_block_conv2 (Conv2D)   (None, 7, 7, 512)    2359808     ['5a_conv_block_relu1[0][0]']    
                                                                                                  
 5a_conv_block_bn2 (BatchNormal  (None, 7, 7, 512)   2048        ['5a_conv_block_conv2[0][0]']    
 ization)                                                                                         
                                                                                                  
 5a_conv_block_relu2 (Activatio  (None, 7, 7, 512)   0           ['5a_conv_block_bn2[0][0]']      
 n)                                                                                               
                                                                                                  
 5a_conv_block_conv3 (Conv2D)   (None, 7, 7, 2048)   1050624     ['5a_conv_block_relu2[0][0]']    
                                                                                                  
 5a_conv_block_bn3 (BatchNormal  (None, 7, 7, 2048)  8192        ['5a_conv_block_conv3[0][0]']    
 ization)                                                                                         
                                                                                                  
 global_average_pooling2d_13 (G  (None, 2048)        0           ['5a_conv_block_bn3[0][0]']      
 lobalAveragePooling2D)                                                                           
                                                                                                  
 reshape_13 (Reshape)           (None, 1, 1, 2048)   0           ['global_average_pooling2d_13[0][
                                                                 0]']                             
                                                                                                  
 dense_26 (Dense)               (None, 1, 1, 128)    262144      ['reshape_13[0][0]']             
                                                                                                  
 dense_27 (Dense)               (None, 1, 1, 2048)   262144      ['dense_26[0][0]']               
                                                                                                  
 5a_conv_block_res_conv (Conv2D  (None, 7, 7, 2048)  2099200     ['4f_identity_block_relu4[0][0]']
 )                                                                                                
                                                                                                  
 multiply_13 (Multiply)         (None, 7, 7, 2048)   0           ['5a_conv_block_bn3[0][0]',      
                                                                  'dense_27[0][0]']               
                                                                                                  
 5a_conv_block_res_bn (BatchNor  (None, 7, 7, 2048)  8192        ['5a_conv_block_res_conv[0][0]'] 
 malization)                                                                                      
                                                                                                  
 5a_conv_block_add (Add)        (None, 7, 7, 2048)   0           ['multiply_13[0][0]',            
                                                                  '5a_conv_block_res_bn[0][0]']   
                                                                                                  
 5a_conv_block_relu4 (Activatio  (None, 7, 7, 2048)  0           ['5a_conv_block_add[0][0]']      
 n)                                                                                               
                                                                                                  
 5b_identity_block_conv1 (Conv2  (None, 7, 7, 512)   1049088     ['5a_conv_block_relu4[0][0]']    
 D)                                                                                               
                                                                                                  
 5b_identity_block_bn1 (BatchNo  (None, 7, 7, 512)   2048        ['5b_identity_block_conv1[0][0]']
 rmalization)                                                                                     
                                                                                                  
 5b_identity_block_relu1 (Activ  (None, 7, 7, 512)   0           ['5b_identity_block_bn1[0][0]']  
 ation)                                                                                           
                                                                                                  
 5b_identity_block_conv2 (Conv2  (None, 7, 7, 512)   2359808     ['5b_identity_block_relu1[0][0]']
 D)                                                                                               
                                                                                                  
 5b_identity_block_bn2 (BatchNo  (None, 7, 7, 512)   2048        ['5b_identity_block_conv2[0][0]']
 rmalization)                                                                                     
                                                                                                  
 5b_identity_block_relu2 (Activ  (None, 7, 7, 512)   0           ['5b_identity_block_bn2[0][0]']  
 ation)                                                                                           
                                                                                                  
 5b_identity_block_conv3 (Conv2  (None, 7, 7, 2048)  1050624     ['5b_identity_block_relu2[0][0]']
 D)                                                                                               
                                                                                                  
 5b_identity_block_bn3 (BatchNo  (None, 7, 7, 2048)  8192        ['5b_identity_block_conv3[0][0]']
 rmalization)                                                                                     
                                                                                                  
 global_average_pooling2d_14 (G  (None, 2048)        0           ['5b_identity_block_bn3[0][0]']  
 lobalAveragePooling2D)                                                                           
                                                                                                  
 reshape_14 (Reshape)           (None, 1, 1, 2048)   0           ['global_average_pooling2d_14[0][
                                                                 0]']                             
                                                                                                  
 dense_28 (Dense)               (None, 1, 1, 128)    262144      ['reshape_14[0][0]']             
                                                                                                  
 dense_29 (Dense)               (None, 1, 1, 2048)   262144      ['dense_28[0][0]']               
                                                                                                  
 multiply_14 (Multiply)         (None, 7, 7, 2048)   0           ['5b_identity_block_bn3[0][0]',  
                                                                  'dense_29[0][0]']               
                                                                                                  
 5b_identity_block_add (Add)    (None, 7, 7, 2048)   0           ['multiply_14[0][0]',            
                                                                  '5a_conv_block_relu4[0][0]']    
                                                                                                  
 5b_identity_block_relu4 (Activ  (None, 7, 7, 2048)  0           ['5b_identity_block_add[0][0]']  
 ation)                                                                                           
                                                                                                  
 5c_identity_block_conv1 (Conv2  (None, 7, 7, 512)   1049088     ['5b_identity_block_relu4[0][0]']
 D)                                                                                               
                                                                                                  
 5c_identity_block_bn1 (BatchNo  (None, 7, 7, 512)   2048        ['5c_identity_block_conv1[0][0]']
 rmalization)                                                                                     
                                                                                                  
 5c_identity_block_relu1 (Activ  (None, 7, 7, 512)   0           ['5c_identity_block_bn1[0][0]']  
 ation)                                                                                           
                                                                                                  
 5c_identity_block_conv2 (Conv2  (None, 7, 7, 512)   2359808     ['5c_identity_block_relu1[0][0]']
 D)                                                                                               
                                                                                                  
 5c_identity_block_bn2 (BatchNo  (None, 7, 7, 512)   2048        ['5c_identity_block_conv2[0][0]']
 rmalization)                                                                                     
                                                                                                  
 5c_identity_block_relu2 (Activ  (None, 7, 7, 512)   0           ['5c_identity_block_bn2[0][0]']  
 ation)                                                                                           
                                                                                                  
 5c_identity_block_conv3 (Conv2  (None, 7, 7, 2048)  1050624     ['5c_identity_block_relu2[0][0]']
 D)                                                                                               
                                                                                                  
 5c_identity_block_bn3 (BatchNo  (None, 7, 7, 2048)  8192        ['5c_identity_block_conv3[0][0]']
 rmalization)                                                                                     
                                                                                                  
 global_average_pooling2d_15 (G  (None, 2048)        0           ['5c_identity_block_bn3[0][0]']  
 lobalAveragePooling2D)                                                                           
                                                                                                  
 reshape_15 (Reshape)           (None, 1, 1, 2048)   0           ['global_average_pooling2d_15[0][
                                                                 0]']                             
                                                                                                  
 dense_30 (Dense)               (None, 1, 1, 128)    262144      ['reshape_15[0][0]']             
                                                                                                  
 dense_31 (Dense)               (None, 1, 1, 2048)   262144      ['dense_30[0][0]']               
                                                                                                  
 multiply_15 (Multiply)         (None, 7, 7, 2048)   0           ['5c_identity_block_bn3[0][0]',  
                                                                  'dense_31[0][0]']               
                                                                                                  
 5c_identity_block_add (Add)    (None, 7, 7, 2048)   0           ['multiply_15[0][0]',            
                                                                  '5b_identity_block_relu4[0][0]']
                                                                                                  
 5c_identity_block_relu4 (Activ  (None, 7, 7, 2048)  0           ['5c_identity_block_add[0][0]']  
 ation)                                                                                           
                                                                                                  
 avg_pool (AveragePooling2D)    (None, 1, 1, 2048)   0           ['5c_identity_block_relu4[0][0]']
                                                                                                  
 flatten (Flatten)              (None, 2048)         0           ['avg_pool[0][0]']               
                                                                                                  
 dropout (Dropout)              (None, 2048)         0           ['flatten[0][0]']                
                                                                                                  
 fc2 (Dense)                    (None, 4)            8196        ['dropout[0][0]']                
                                                                                                  
==================================================================================================
Total params: 26,110,852
Trainable params: 26,057,732
Non-trainable params: 53,120
__________________________________________________________________________________________________
model.compile(optimizer='adam',
              loss='sparse_categorical_crossentropy',
              metrics=['accuracy'])

epochs = 30

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

 

Epoch 1/30
57/57 [==============================] - 120s 2s/step - loss: 1.6071 - accuracy: 0.5022 - val_loss: 1.6805 - val_accuracy: 0.3628
Epoch 2/30
57/57 [==============================] - 101s 2s/step - loss: 1.1572 - accuracy: 0.5973 - val_loss: 2.9043 - val_accuracy: 0.3628
Epoch 3/30
57/57 [==============================] - 103s 2s/step - loss: 1.0106 - accuracy: 0.6438 - val_loss: 3.5882 - val_accuracy: 0.2655
Epoch 4/30
57/57 [==============================] - 104s 2s/step - loss: 0.6960 - accuracy: 0.7345 - val_loss: 3.8824 - val_accuracy: 0.2920
Epoch 5/30
57/57 [==============================] - 103s 2s/step - loss: 0.6722 - accuracy: 0.8009 - val_loss: 1.9140 - val_accuracy: 0.3805
Epoch 6/30
57/57 [==============================] - 102s 2s/step - loss: 0.5720 - accuracy: 0.8009 - val_loss: 1.3526 - val_accuracy: 0.5133
Epoch 7/30
57/57 [==============================] - 103s 2s/step - loss: 0.5234 - accuracy: 0.8252 - val_loss: 1.6950 - val_accuracy: 0.6195
Epoch 8/30
57/57 [==============================] - 103s 2s/step - loss: 0.5409 - accuracy: 0.8186 - val_loss: 1.0905 - val_accuracy: 0.5752
Epoch 9/30
57/57 [==============================] - 102s 2s/step - loss: 0.4960 - accuracy: 0.8230 - val_loss: 1.0269 - val_accuracy: 0.5664
Epoch 10/30
57/57 [==============================] - 106s 2s/step - loss: 0.3521 - accuracy: 0.8761 - val_loss: 0.7942 - val_accuracy: 0.7965
Epoch 11/30
57/57 [==============================] - 103s 2s/step - loss: 0.2162 - accuracy: 0.9204 - val_loss: 0.9084 - val_accuracy: 0.7168
Epoch 12/30
57/57 [==============================] - 103s 2s/step - loss: 0.3159 - accuracy: 0.9093 - val_loss: 1.8489 - val_accuracy: 0.7611
Epoch 13/30
57/57 [==============================] - 102s 2s/step - loss: 0.2727 - accuracy: 0.8960 - val_loss: 2.2825 - val_accuracy: 0.7345
Epoch 14/30
57/57 [==============================] - 104s 2s/step - loss: 0.1902 - accuracy: 0.9381 - val_loss: 1.1050 - val_accuracy: 0.7257
Epoch 15/30
57/57 [==============================] - 105s 2s/step - loss: 0.2085 - accuracy: 0.9292 - val_loss: 0.3290 - val_accuracy: 0.9027
Epoch 16/30
57/57 [==============================] - 105s 2s/step - loss: 0.1697 - accuracy: 0.9358 - val_loss: 1.0470 - val_accuracy: 0.7965
Epoch 17/30
57/57 [==============================] - 106s 2s/step - loss: 0.1955 - accuracy: 0.9381 - val_loss: 9.2690 - val_accuracy: 0.3540
Epoch 18/30
57/57 [==============================] - 103s 2s/step - loss: 0.3337 - accuracy: 0.8960 - val_loss: 1.6920 - val_accuracy: 0.7699
Epoch 19/30
57/57 [==============================] - 103s 2s/step - loss: 0.1869 - accuracy: 0.9292 - val_loss: 9.7153 - val_accuracy: 0.3628
Epoch 20/30
57/57 [==============================] - 103s 2s/step - loss: 0.2506 - accuracy: 0.9049 - val_loss: 0.9142 - val_accuracy: 0.7876
Epoch 21/30
57/57 [==============================] - 107s 2s/step - loss: 0.1941 - accuracy: 0.9358 - val_loss: 0.7740 - val_accuracy: 0.8142
Epoch 22/30
57/57 [==============================] - 103s 2s/step - loss: 0.0971 - accuracy: 0.9690 - val_loss: 0.5248 - val_accuracy: 0.8230
Epoch 23/30
57/57 [==============================] - 104s 2s/step - loss: 0.0549 - accuracy: 0.9845 - val_loss: 2.8425 - val_accuracy: 0.6637
Epoch 24/30
57/57 [==============================] - 107s 2s/step - loss: 0.0251 - accuracy: 0.9934 - val_loss: 0.1835 - val_accuracy: 0.9292
Epoch 25/30
57/57 [==============================] - 110s 2s/step - loss: 0.0131 - accuracy: 1.0000 - val_loss: 0.2147 - val_accuracy: 0.9469
Epoch 26/30
57/57 [==============================] - 103s 2s/step - loss: 0.0043 - accuracy: 1.0000 - val_loss: 0.1484 - val_accuracy: 0.9469
Epoch 27/30
57/57 [==============================] - 106s 2s/step - loss: 0.0029 - accuracy: 1.0000 - val_loss: 0.1338 - val_accuracy: 0.9558
Epoch 28/30
57/57 [==============================] - 107s 2s/step - loss: 0.0013 - accuracy: 1.0000 - val_loss: 0.1428 - val_accuracy: 0.9469
Epoch 29/30
57/57 [==============================] - 108s 2s/step - loss: 6.1017e-04 - accuracy: 1.0000 - val_loss: 0.1412 - val_accuracy: 0.9469
Epoch 30/30
57/57 [==============================] - 111s 2s/step - loss: 5.0776e-04 - accuracy: 1.0000 - val_loss: 0.1457 - val_accuracy: 0.9381
# 获取实际训练轮数
actual_epochs = len(history.history['accuracy'])

acc = history.history['accuracy']
val_acc = history.history['val_accuracy']

loss = history.history['loss']
val_loss = history.history['val_loss']

epochs_range = range(actual_epochs)

plt.figure(figsize=(12, 4))

# 绘制准确率
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()

二 CFResNet算法

是在ResNet基础上加上BN、FPN和SE-Net的组合神经网络

我们下面直接看模型代码和结果 

from keras import layers
from keras.layers import Input, Activation, BatchNormalization, Flatten, Dropout, Reshape
from keras.layers import Dense, Conv2D, MaxPooling2D, ZeroPadding2D, AveragePooling2D, GlobalAveragePooling2D
from keras.models import Model
from keras.layers import Add, UpSampling2D, Multiply, Concatenate

# Squeeze-and-Excitation Block
def squeeze_excite_block(input_tensor, ratio=16):
    channel_axis = -1  # 通道轴通常在最后一维
    channels = input_tensor.shape[channel_axis]  # 获取通道数

    # Squeeze:全局平均池化
    x = GlobalAveragePooling2D()(input_tensor)
    x = Reshape((1, 1, channels))(x)

    # Excite:两个全连接层生成通道权重
    x = Dense(channels // ratio, activation='relu', kernel_initializer='he_normal', use_bias=False)(x)
    x = Dense(channels, activation='sigmoid', kernel_initializer='he_normal', use_bias=False)(x)

    # 将生成的权重与输入张量相乘
    x = Multiply()([input_tensor, x])
    
    return x

# Identity Block
def identity_block(input_tensor, kernel_size, filters, stage, block):
    filters1, filters2, filters3 = filters
    name_base = str(stage) + block + '_identity_block_'

    # 第一卷积层
    x = Conv2D(filters1, (1, 1), name=name_base + 'conv1')(input_tensor)
    x = BatchNormalization(name=name_base + 'bn1')(x)
    x = Activation('relu', name=name_base + 'relu1')(x)

    # 第二卷积层
    x = Conv2D(filters2, kernel_size, padding='same', name=name_base + 'conv2')(x)
    x = BatchNormalization(name=name_base + 'bn2')(x)
    x = Activation('relu', name=name_base + 'relu2')(x)

    # 第三卷积层
    x = Conv2D(filters3, (1, 1), name=name_base + 'conv3')(x)
    x = BatchNormalization(name=name_base + 'bn3')(x)

    # SE-Net通道注意力机制
    x = squeeze_excite_block(x)

    # 残差连接
    x = layers.add([x, input_tensor], name=name_base + 'add')
    x = Activation('relu', name=name_base + 'relu4')(x)

    return x

# Conv Block
def conv_block(input_tensor, kernel_size, filters, stage, block, strides=(2, 2)):
    filters1, filters2, filters3 = filters
    res_name_base = str(stage) + block + '_conv_block_res_'
    name_base = str(stage) + block + '_conv_block_'

    # 主卷积层
    x = Conv2D(filters1, (1, 1), strides=strides, name=name_base + 'conv1')(input_tensor)
    x = BatchNormalization(name=name_base + 'bn1')(x)
    x = Activation('relu', name=name_base + 'relu1')(x)

    x = Conv2D(filters2, kernel_size, padding='same', name=name_base + 'conv2')(x)
    x = BatchNormalization(name=name_base + 'bn2')(x)
    x = Activation('relu', name=name_base + 'relu2')(x)

    x = Conv2D(filters3, (1, 1), name=name_base + 'conv3')(x)
    x = BatchNormalization(name=name_base + 'bn3')(x)

    # 残差连接的卷积
    shortcut = Conv2D(filters3, (1, 1), strides=strides, name=res_name_base + 'conv')(input_tensor)
    shortcut = BatchNormalization(name=res_name_base + 'bn')(shortcut)

    # SE-Net通道注意力机制
    x = squeeze_excite_block(x)

    # 残差连接加和
    x = layers.add([x, shortcut], name=name_base + 'add')
    x = Activation('relu', name=name_base + 'relu4')(x)

    return x

# Feature Pyramid Network (FPN)
def fpn_block(input_tensor, filters, name):
    # 上采样
    x = UpSampling2D(size=(2, 2), name=name + '_upsample')(input_tensor)
    x = Conv2D(filters, (1, 1), padding='same', name=name + '_conv')(x)
    x = BatchNormalization(name=name + '_bn')(x)
    return x

def ResNet50_with_FPN(input_shape=[224,224,3], classes=4):
    img_input = Input(shape=input_shape)
    x = ZeroPadding2D((3, 3))(img_input)

    # ResNet50 Backbone with SE Block
    x = Conv2D(64, (7, 7), strides=(2, 2), name='conv1')(x)
    x = BatchNormalization(name='bn_conv1')(x)
    x = Activation('relu')(x)
    x = MaxPooling2D((3, 3), strides=(2, 2))(x)

    # ResNet50 Backbone with SE Block
    c2 = conv_block(x, 3, [64, 64, 256], stage=2, block='a', strides=(1, 1))
    c2 = identity_block(c2, 3, [64, 64, 256], stage=2, block='b')
    c2 = identity_block(c2, 3, [64, 64, 256], stage=2, block='c')

    c3 = conv_block(c2, 3, [128, 128, 512], stage=3, block='a')
    c3 = identity_block(c3, 3, [128, 128, 512], stage=3, block='b')
    c3 = identity_block(c3, 3, [128, 128, 512], stage=3, block='c')
    c3 = identity_block(c3, 3, [128, 128, 512], stage=3, block='d')

    c4 = conv_block(c3, 3, [256, 256, 1024], stage=4, block='a')
    c4 = identity_block(c4, 3, [256, 256, 1024], stage=4, block='b')
    c4 = identity_block(c4, 3, [256, 256, 1024], stage=4, block='c')
    c4 = identity_block(c4, 3, [256, 256, 1024], stage=4, block='d')
    c4 = identity_block(c4, 3, [256, 256, 1024], stage=4, block='e')
    c4 = identity_block(c4, 3, [256, 256, 1024], stage=4, block='f')

    c5 = conv_block(c4, 3, [512, 512, 2048], stage=5, block='a')
    c5 = identity_block(c5, 3, [512, 512, 2048], stage=5, block='b')
    c5 = identity_block(c5, 3, [512, 512, 2048], stage=5, block='c')

    # FPN Layer: create top-down and lateral connections
    p5 = Conv2D(256, (1, 1), padding='same', name='fpn_p5')(c5)
    p4 = fpn_block(p5, 256, 'fpn_p4')
    p3 = fpn_block(p4, 256, 'fpn_p3')
    p2 = fpn_block(p3, 256, 'fpn_p2')

    # Final classification
    x = AveragePooling2D((7, 7), name='avg_pool')(c5)
    x = Flatten()(x)
    x = Dropout(0.5)(x)
    x = Dense(classes, activation='softmax', name='fc2')(x)

    model = Model(img_input, x, name='resnet50_with_fpn')
    
    return model

# Instantiate the model
model = ResNet50_with_FPN()
model.summary()

 

Epoch 1/30
57/57 [==============================] - 124s 2s/step - loss: 1.7040 - accuracy: 0.5465 - val_loss: 4.1759 - val_accuracy: 0.2655
Epoch 2/30
57/57 [==============================] - 108s 2s/step - loss: 1.0829 - accuracy: 0.6615 - val_loss: 6.2262 - val_accuracy: 0.2655
Epoch 3/30
57/57 [==============================] - 110s 2s/step - loss: 0.8514 - accuracy: 0.7102 - val_loss: 7.9029 - val_accuracy: 0.2655
Epoch 4/30
57/57 [==============================] - 108s 2s/step - loss: 0.6071 - accuracy: 0.7743 - val_loss: 5.6822 - val_accuracy: 0.2655
Epoch 5/30
57/57 [==============================] - 107s 2s/step - loss: 0.6340 - accuracy: 0.7854 - val_loss: 2.8168 - val_accuracy: 0.2832
Epoch 6/30
57/57 [==============================] - 107s 2s/step - loss: 0.3986 - accuracy: 0.8562 - val_loss: 2.2164 - val_accuracy: 0.3894
Epoch 7/30
57/57 [==============================] - 108s 2s/step - loss: 0.4435 - accuracy: 0.8518 - val_loss: 1.9530 - val_accuracy: 0.5841
Epoch 8/30
57/57 [==============================] - 112s 2s/step - loss: 0.3334 - accuracy: 0.8650 - val_loss: 0.8318 - val_accuracy: 0.7522
Epoch 9/30
57/57 [==============================] - 109s 2s/step - loss: 0.2631 - accuracy: 0.9027 - val_loss: 0.3123 - val_accuracy: 0.8938
Epoch 10/30
57/57 [==============================] - 121s 2s/step - loss: 0.1918 - accuracy: 0.9336 - val_loss: 0.3432 - val_accuracy: 0.8584
Epoch 11/30
57/57 [==============================] - 111s 2s/step - loss: 0.2280 - accuracy: 0.9270 - val_loss: 3.3803 - val_accuracy: 0.6018
Epoch 12/30
57/57 [==============================] - 112s 2s/step - loss: 0.2377 - accuracy: 0.9137 - val_loss: 1.7401 - val_accuracy: 0.6283
Epoch 13/30
57/57 [==============================] - 112s 2s/step - loss: 0.2143 - accuracy: 0.9204 - val_loss: 1.9620 - val_accuracy: 0.6460
Epoch 14/30
57/57 [==============================] - 108s 2s/step - loss: 0.1334 - accuracy: 0.9602 - val_loss: 1.1494 - val_accuracy: 0.8142
Epoch 15/30
57/57 [==============================] - 107s 2s/step - loss: 0.2434 - accuracy: 0.9226 - val_loss: 1.5473 - val_accuracy: 0.7699
Epoch 16/30
57/57 [==============================] - 107s 2s/step - loss: 0.1815 - accuracy: 0.9425 - val_loss: 0.6820 - val_accuracy: 0.8230
Epoch 17/30
57/57 [==============================] - 107s 2s/step - loss: 0.1237 - accuracy: 0.9580 - val_loss: 0.5633 - val_accuracy: 0.8938
Epoch 18/30
57/57 [==============================] - 107s 2s/step - loss: 0.0653 - accuracy: 0.9779 - val_loss: 0.7569 - val_accuracy: 0.8496
Epoch 19/30
57/57 [==============================] - 106s 2s/step - loss: 0.1139 - accuracy: 0.9558 - val_loss: 5.6673 - val_accuracy: 0.4956
Epoch 20/30
57/57 [==============================] - 108s 2s/step - loss: 0.1208 - accuracy: 0.9535 - val_loss: 10.7703 - val_accuracy: 0.3628
Epoch 21/30
57/57 [==============================] - 107s 2s/step - loss: 0.1212 - accuracy: 0.9668 - val_loss: 184.4987 - val_accuracy: 0.2743
Epoch 22/30
57/57 [==============================] - 106s 2s/step - loss: 0.3250 - accuracy: 0.8938 - val_loss: 44.9149 - val_accuracy: 0.3451
Epoch 23/30
57/57 [==============================] - 106s 2s/step - loss: 0.1613 - accuracy: 0.9381 - val_loss: 3.1342 - val_accuracy: 0.7522
Epoch 24/30
57/57 [==============================] - 108s 2s/step - loss: 0.1241 - accuracy: 0.9558 - val_loss: 1.4571 - val_accuracy: 0.8142
Epoch 25/30
57/57 [==============================] - 108s 2s/step - loss: 0.1052 - accuracy: 0.9558 - val_loss: 0.5071 - val_accuracy: 0.8673
Epoch 26/30
57/57 [==============================] - 108s 2s/step - loss: 0.1868 - accuracy: 0.9403 - val_loss: 0.5222 - val_accuracy: 0.8584
Epoch 27/30
57/57 [==============================] - 107s 2s/step - loss: 0.0699 - accuracy: 0.9801 - val_loss: 1.3800 - val_accuracy: 0.6991
Epoch 28/30
57/57 [==============================] - 106s 2s/step - loss: 0.0975 - accuracy: 0.9712 - val_loss: 4.8408 - val_accuracy: 0.6372
Epoch 29/30
57/57 [==============================] - 108s 2s/step - loss: 0.0452 - accuracy: 0.9801 - val_loss: 0.3862 - val_accuracy: 0.8761
Epoch 30/30
57/57 [==============================] - 107s 2s/step - loss: 0.0164 - accuracy: 0.9978 - val_loss: 0.2110 - val_accuracy: 0.9292

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/2328288.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

Ubuntu 20.04 出现问号图标且无法联网 修复

在 Ubuntu 中遇到网络连接问题(如出现问号图标且无法联网),可以通过以下命令尝试重启网络服务: 1. 推荐先修改DNS 编辑 -> 虚拟机网络编辑器-> VMnet8 ->NAT 设置 -> DNS 设置 -> 设置DNS 服务器 DNS填什么 取决…

基于Contiue来阅读open-r1中的GRPO训练代码

原创 快乐王子HP 快乐王子AI说 2025年04月03日 23:54 广东 前面安装了vscode[1]同时也安装了Coninue的相关插件[2],现在想用它们来阅读一下open-r1项目的代码[3]。 首先,从启动训练开始(以GRPO为例子) 第一步,使用TRL的vLLM后端…

51c嵌入式~单片机~合集7~※

我自己的原文哦~ https://blog.51cto.com/whaosoft/13692314 一、芯片工作的心脏--晶振 在振荡器中采用一个特殊的元件——石英晶体,它可以产生频率高度稳定的交流信号,这种采用石英晶体的振荡器称为晶体振荡器,简称晶振。 制作方法 …

英菲克(INPHIC)A9无线蓝牙鼠标 链接电脑的方式

英菲克(INPHIC)A9鼠标链接至电脑时,要长按住“模式切换MODE”按钮5秒左右的时间,此时模式指示灯变成蓝色,并且闪烁。 这时使用电脑的蓝牙设置中,“添加设备”,会出现BT4.0 Mouse提示&#xff0…

lua表table和JSON字符串互转

--print("local ssxc{\n"..string.gsub(str,":","").."\n}") Utils {} ---------------------------------------------------------------------------------- -- Lua-Table 与 string 转换 local function value2string(value, isA…

【每日一个知识点】分布式数据湖与实时计算

在现代数据架构中,分布式数据湖(Distributed Data Lake) 结合 实时计算(Real-time Computing) 已成为大数据处理的核心模式。数据湖用于存储海量的结构化和非结构化数据,而实时计算则确保数据能够被迅速处理…

c语言数据结构--------拓扑排序和逆拓扑排序(Kahn算法和DFS算法实现)

#include <stdio.h> #include <string.h> #include <stdbool.h> #include <stdlib.h>//使用卡恩算法(Kahn)和深度优先算法(DFS)实现//拓扑排序和逆拓扑排序//拓扑排序和逆拓扑排序顶点顺序相反//图&#xff0c;邻接矩阵存储 #define MaxVertexNum 100 …

谷粒微服务高级篇学习笔记整理---nginx搭建正反向代理

正向与反向代理 **正向代理:**客户端向代理服务器发请求并指定目标服务器,代理向目标转交请求并将获得的内容转给客户端。 反向代理:用户直接访问反向代理服务器就可以获得目标服务器的资源。反向代理服务器统一了访问入口。 给首页配置反向代理 修改windows的hosts文件配…

2.pycharm保姆级安装教程

一、pycharm安装 1.官网上下载好好软&#xff0c;双击打开 2.下一步 3.修改路径地址 (默认也可以) 4.打勾 5.安装 不用重启电脑 二、添加解释器 1.双击软件&#xff0c;打开 2.projects – new project 3.指定项目名字&#xff0c;项目保存地址&#xff0c;解释器 4.右击 – …

【SQL】取消sql某一列的唯一值key值的方法

在插入数据到sql时&#xff0c;遇到了这个问题&#xff1a; Duplicate entry ‘XXX’ for key 起因是&#xff1a; 我之前设计表的时候&#xff0c;手动给product_title 这个列加了一个key&#xff0c; key 是这个字段的唯一键约束&#xff0c;就不能重复在这一列存入重复的数…

数据库--SQL

SQL&#xff1a;Structured Query Language&#xff0c;结构化查询语言 SQL是用于管理关系型数据库并对其中的数据进行一系列操作&#xff08;包括数据插入、查询、修改删除&#xff09;的一种语言 分类&#xff1a;数据定义语言DDL、数据操纵语言DML、数据控制语言DCL、事务处…

SQL语句(一)—— DDL

目录 一、SQL 基础知识 &#xff08;一&#xff09;SQL 通用语法 &#xff08;二&#xff09;SQL 分类 二、DDL —— 数据库操作 1、查询所有数据库 2、查询当前数据库 3、创建数据库 4、删除数据库 5、切换数据库 三、DDL —— 表操作 &#xff08;一&#xff09;查…

Husky目标跟踪

1.0设备清单 幻影峡谷、适配器 摄像头及数据线、显卡欺骗器 外接屏幕、键盘鼠标 Husky底盘、便携显示屏、键盘鼠标 移动电源 1.1连线 插排——移动电源幻影峡谷——适配器——插排摄像头——幻影峡谷&#xff08;摄像头固定在机械臂前方的底盘上&#xff09;键盘鼠标显示器…

Python----机器学习(线性回归:自求导的方法实现)

一、线性回归方程 目标&#xff1a; 线性回归的目标是找到最佳的系数来使模型与观察到的数据尽可能拟合。 应用&#xff1a; 预测&#xff1a;给定自变量的值&#xff0c;预测因变量的值。 回归分析&#xff1a;确定自变量对因变量的影响程度 线性回归是统计学和机器学习中最简…

Springcache+xxljob实现定时刷新缓存

目录 SpringCache详解 SpringCache概述 核心原理 接口抽象与多态 AOP动态代理 核心注解以及使用 公共属性 cacheNames KeyGenerator&#xff1a;key生成器 key condition&#xff1a;缓存的条件&#xff0c;对入参进行判断 注解 xxl-job详解 SpringcacheRedis实现…

vue2拖拉拽做个模拟公式工具

1. 成图 2. 介绍 就是简单拖拉拽来做个规则运算器&#xff0c;具体运算规则、校验规则自己加。 3. 代码 HTML代码 <template><div class"red-cont"><div class"red-top"><divclass"red-top-left"><div class&quo…

Windows查重工具,强烈推荐大家收藏!

我大家在用电脑的时候&#xff0c;是不是发现用得越久&#xff0c;电脑里的软件和文件就越多&#xff1f; 今天我给大家带来的这两款重复文件查找神器&#xff0c;简直就是电脑里的“清洁小能手”&#xff0c;能帮你把那些重复的文件和文件夹找出来。 Easy DupLicate Finder 重…

使用python完成手写数字识别

入门图像识别的第一个案例,看到好多小伙伴分享,也把自己当初的思路捋捋,写成一篇博客,作为记录和分享,也欢迎各位交流讨论。 实现思路 数据集:MNIST(包含60,000个训练样本和10,000个测试样本) 深度学习框架:Keras(基于TensorFlow) 模型架构:卷积神经网络(CNN) 实…

OpenLayers:如何控制Overlay的层级?

我最近在使用Overlay的时候遇到了一个问题&#xff0c;我向地图中添加了两种不同的Overlay&#xff08;下图中的蓝色标牌和粉色标牌&#xff09;&#xff0c;我希望粉色标牌可以显示在最上层&#xff0c;可偏偏蓝色标牌却将其遮挡住了。于是我对Overlay的层级开始起了兴趣&…

《Golang高性能网络编程:构建低延迟服务器应用》

在本文中&#xff0c;我们将深入探讨Golang高性能网络编程&#xff0c;帮助您构建低延迟服务器应用。我们将介绍Golang的网络编程特性、优化技巧和实际案例&#xff0c;让您更好地理解和应用Golang在网络编程领域的优势。 高性能网络编程简介 什么是Golang高性能网络编程 高性能…