卷积神经网络(ResNet-50)鸟类识别

文章目录

  • 卷积神经网络(CNN)mnist手写数字分类识别的实现
  • 卷积神经网络(CNN)多种图片分类的实现
  • 卷积神经网络(CNN)衣服图像分类的实现
  • 卷积神经网络(CNN)鲜花的识别
  • 卷积神经网络(CNN)天气识别
  • 卷积神经网络(VGG-16)海贼王人物识别
  • 卷积神经网络(VGG-19)灵笼人物识别
  • 前期工作
    • 1. 设置GPU(如果使用的是CPU可以忽略这步)
      • 我的环境:
    • 2. 导入数据
    • 3. 查看数据
  • 二、数据预处理
    • 1. 加载数据
    • 2. 可视化数据
    • 3. 再次检查数据
    • 4. 配置数据集
  • 三、残差网络(ResNet)介绍
    • 1. 残差网络解决了什么
    • 2. ResNet-50介绍
  • 四、构建ResNet-50网络模型
  • 五、编译
  • 六、训练模型
  • 六、模型评估
  • 八、保存and加载模型
  • 九、预测

卷积神经网络(CNN)mnist手写数字分类识别的实现

卷积神经网络(CNN)多种图片分类的实现

卷积神经网络(CNN)衣服图像分类的实现

卷积神经网络(CNN)鲜花的识别

卷积神经网络(CNN)天气识别

卷积神经网络(VGG-16)海贼王人物识别

卷积神经网络(VGG-19)灵笼人物识别

前期工作

1. 设置GPU(如果使用的是CPU可以忽略这步)

我的环境:

  • 语言环境:Python3.6.5
  • 编译器:jupyter notebook
  • 深度学习环境:TensorFlow2.4.1
import tensorflow as tfgpus = tf.config.list_physical_devices("GPU")if gpus:tf.config.experimental.set_memory_growth(gpus[0], True)  #设置GPU显存用量按需使用tf.config.set_visible_devices([gpus[0]],"GPU")

2. 导入数据

import matplotlib.pyplot as plt
# 支持中文
plt.rcParams['font.sans-serif'] = ['SimHei']  # 用来正常显示中文标签
plt.rcParams['axes.unicode_minus'] = False  # 用来正常显示负号import os,PIL# 设置随机种子尽可能使结果可以重现
import numpy as np
np.random.seed(1)# 设置随机种子尽可能使结果可以重现
import tensorflow as tf
tf.random.set_seed(1)from tensorflow import keras
from tensorflow.keras import layers,modelsimport pathlib
data_dir = "weather_photos/"
data_dir = pathlib.Path(data_dir)

3. 查看数据

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

二、数据预处理

文件夹数量
Bananaquit166 张
Black Throated Bushtiti111 张
Black skimmer122 张
Cockatoo166张

1. 加载数据

使用image_dataset_from_directory方法将磁盘中的数据加载到tf.data.Dataset

batch_size = 32
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)
Found 565 files belonging to 4 classes.
Using 452 files for training.
val_ds = tf.keras.preprocessing.image_dataset_from_directory(data_dir,validation_split=0.2,subset="validation",seed=123,image_size=(img_height, img_width),batch_size=batch_size)
Found 565 files belonging to 4 classes.
Using 113 files for validation.

我们可以通过class_names输出数据集的标签。标签将按字母顺序对应于目录名称。

class_names = train_ds.class_names
print(class_names)
['Bananaquit', 'Black Skimmer', 'Black Throated Bushtiti', 'Cockatoo']

2. 可视化数据

plt.figure(figsize=(10, 5))  # 图形的宽为10高为5for images, labels in train_ds.take(1):for i in range(8):ax = plt.subplot(2, 4, i + 1)  plt.imshow(images[i].numpy().astype("uint8"))plt.title(class_names[labels[i]])plt.axis("off")

在这里插入图片描述

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

在这里插入图片描述

3. 再次检查数据

for image_batch, labels_batch in train_ds:print(image_batch.shape)print(labels_batch.shape)break
(8, 224, 224, 3)
(8,)
  • Image_batch是形状的张量(8, 224, 224, 3)。这是一批形状240x240x3的8张图片(最后一维指的是彩色通道RGB)。
  • Label_batch是形状(8,)的张量,这些标签对应8张图片

4. 配置数据集

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

三、残差网络(ResNet)介绍

1. 残差网络解决了什么

残差网络是为了解决神经网络隐藏层过多时,而引起的网络退化问题。退化(degradation)问题是指:当网络隐藏层变多时,网络的准确度达到饱和然后急剧退化,而且这个退化不是由于过拟合引起的。

拓展: 深度神经网络的“两朵乌云”

  • 梯度弥散/爆炸

简单来讲就是网络太深了,会导致模型训练难以收敛。这个问题可以被标准初始化和中间层正规化的方法有效控制。(现阶段知道这么一回事就好了)

  • 网络退化

随着网络深度增加,网络的表现先是逐渐增加至饱和,然后迅速下降,这个退化不是由于过拟合引起的。

2. ResNet-50介绍

ResNet-50有两个基本的块,分别名为Conv BlockIdentity Block

在这里插入图片描述
在这里插入图片描述

四、构建ResNet-50网络模型

下面是本文的重点,可以试着按照上面三张图自己构建一下ResNet-50

from keras import layersfrom keras.layers import Input,Activation,BatchNormalization,Flatten
from keras.layers import Dense,Conv2D,MaxPooling2D,ZeroPadding2D,AveragePooling2D
from keras.models import Modeldef identity_block(input_tensor, kernel_size, filters, stage, block):filters1, filters2, filters3 = filtersname_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)x = layers.add([x, input_tensor] ,name=name_base + 'add')x = Activation('relu', name=name_base + 'relu4')(x)return xdef conv_block(input_tensor, kernel_size, filters, stage, block, strides=(2, 2)):filters1, filters2, filters3 = filtersres_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)x = layers.add([x, shortcut], name=name_base+'add')x = Activation('relu', name=name_base+'relu4')(x)return xdef ResNet50(input_shape=[224,224,3],classes=1000):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 = Dense(classes, activation='softmax', name='fc1000')(x)model = Model(img_input, x, name='resnet50')# 加载预训练模型model.load_weights("resnet50_weights_tf_dim_ordering_tf_kernels.h5")return modelmodel = 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 (BatchNormali (None, 55, 55, 64)   256         2a_conv_block_conv1[0][0]        
__________________________________________________________________________________________________
2a_conv_block_relu1 (Activation (None, 55, 55, 64)   0           2a_conv_block_bn1[0][0]          
__________________________________________________________________________________________________
2a_conv_block_conv2 (Conv2D)    (None, 55, 55, 64)   36928       2a_conv_block_relu1[0][0]        
__________________________________________________________________________________________________
2a_conv_block_bn2 (BatchNormali (None, 55, 55, 64)   256         2a_conv_block_conv2[0][0]        
__________________________________________________________________________________________________
2a_conv_block_relu2 (Activation (None, 55, 55, 64)   0           2a_conv_block_bn2[0][0]          
__________________________________________________________________________________________________
2a_conv_block_conv3 (Conv2D)    (None, 55, 55, 256)  16640       2a_conv_block_relu2[0][0]        
__________________________________________________________________________________________________
2a_conv_block_res_conv (Conv2D) (None, 55, 55, 256)  16640       max_pooling2d[0][0]              
__________________________________________________________________________________________________
2a_conv_block_bn3 (BatchNormali (None, 55, 55, 256)  1024        2a_conv_block_conv3[0][0]        
__________________________________________________________________________________________________
2a_conv_block_res_bn (BatchNorm (None, 55, 55, 256)  1024        2a_conv_block_res_conv[0][0]     
__________________________________________________________________________________________________
2a_conv_block_add (Add)         (None, 55, 55, 256)  0           2a_conv_block_bn3[0][0]          2a_conv_block_res_bn[0][0]       
__________________________________________________________________________________________________
2a_conv_block_relu4 (Activation (None, 55, 55, 256)  0           2a_conv_block_add[0][0]          
__________________________________________________________________________________________________
2b_identity_block_conv1 (Conv2D (None, 55, 55, 64)   16448       2a_conv_block_relu4[0][0]        
__________________________________________________________________________________________________
2b_identity_block_bn1 (BatchNor (None, 55, 55, 64)   256         2b_identity_block_conv1[0][0]    
__________________________________________________________________________________________________
2b_identity_block_relu1 (Activa (None, 55, 55, 64)   0           2b_identity_block_bn1[0][0]      
__________________________________________________________________________________________________
2b_identity_block_conv2 (Conv2D (None, 55, 55, 64)   36928       2b_identity_block_relu1[0][0]    
__________________________________________________________________________________________________
2b_identity_block_bn2 (BatchNor (None, 55, 55, 64)   256         2b_identity_block_conv2[0][0]    
__________________________________________________________________________________________________
2b_identity_block_relu2 (Activa (None, 55, 55, 64)   0           2b_identity_block_bn2[0][0]      
__________________________________________________________________________________________________
2b_identity_block_conv3 (Conv2D (None, 55, 55, 256)  16640       2b_identity_block_relu2[0][0]    
__________________________________________________________________________________________________
2b_identity_block_bn3 (BatchNor (None, 55, 55, 256)  1024        2b_identity_block_conv3[0][0]    
__________________________________________________________________________________________________
2b_identity_block_add (Add)     (None, 55, 55, 256)  0           2b_identity_block_bn3[0][0]      2a_conv_block_relu4[0][0]        
__________________________________________________________________________________________________
2b_identity_block_relu4 (Activa (None, 55, 55, 256)  0           2b_identity_block_add[0][0]      
__________________________________________________________________________________________________
2c_identity_block_conv1 (Conv2D (None, 55, 55, 64)   16448       2b_identity_block_relu4[0][0]    
__________________________________________________________________________________________________
2c_identity_block_bn1 (BatchNor (None, 55, 55, 64)   256         2c_identity_block_conv1[0][0]    
__________________________________________________________________________________________________
2c_identity_block_relu1 (Activa (None, 55, 55, 64)   0           2c_identity_block_bn1[0][0]      
__________________________________________________________________________________________________
2c_identity_block_conv2 (Conv2D (None, 55, 55, 64)   36928       2c_identity_block_relu1[0][0]    
__________________________________________________________________________________________________
2c_identity_block_bn2 (BatchNor (None, 55, 55, 64)   256         2c_identity_block_conv2[0][0]    
__________________________________________________________________________________________________
2c_identity_block_relu2 (Activa (None, 55, 55, 64)   0           2c_identity_block_bn2[0][0]      
__________________________________________________________________________________________________
2c_identity_block_conv3 (Conv2D (None, 55, 55, 256)  16640       2c_identity_block_relu2[0][0]    
__________________________________________________________________________________________________
2c_identity_block_bn3 (BatchNor (None, 55, 55, 256)  1024        2c_identity_block_conv3[0][0]    
__________________________________________________________________________________________________
2c_identity_block_add (Add)     (None, 55, 55, 256)  0           2c_identity_block_bn3[0][0]      2b_identity_block_relu4[0][0]    
__________________________________________________________________________________________________
2c_identity_block_relu4 (Activa (None, 55, 55, 256)  0           2c_identity_block_add[0][0]      
__________________________________________________________________________________________________
3a_conv_block_conv1 (Conv2D)    (None, 28, 28, 128)  32896       2c_identity_block_relu4[0][0]    
__________________________________________________________________________________________________
3a_conv_block_bn1 (BatchNormali (None, 28, 28, 128)  512         3a_conv_block_conv1[0][0]        
__________________________________________________________________________________________________
3a_conv_block_relu1 (Activation (None, 28, 28, 128)  0           3a_conv_block_bn1[0][0]          
__________________________________________________________________________________________________
3a_conv_block_conv2 (Conv2D)    (None, 28, 28, 128)  147584      3a_conv_block_relu1[0][0]        
__________________________________________________________________________________________________
3a_conv_block_bn2 (BatchNormali (None, 28, 28, 128)  512         3a_conv_block_conv2[0][0]        
__________________________________________________________________________________________________
3a_conv_block_relu2 (Activation (None, 28, 28, 128)  0           3a_conv_block_bn2[0][0]          
__________________________________________________________________________________________________
3a_conv_block_conv3 (Conv2D)    (None, 28, 28, 512)  66048       3a_conv_block_relu2[0][0]        
__________________________________________________________________________________________________
3a_conv_block_res_conv (Conv2D) (None, 28, 28, 512)  131584      2c_identity_block_relu4[0][0]    
__________________________________________________________________________________________________
3a_conv_block_bn3 (BatchNormali (None, 28, 28, 512)  2048        3a_conv_block_conv3[0][0]        
__________________________________________________________________________________________________
3a_conv_block_res_bn (BatchNorm (None, 28, 28, 512)  2048        3a_conv_block_res_conv[0][0]     
__________________________________________________________________________________________________
3a_conv_block_add (Add)         (None, 28, 28, 512)  0           3a_conv_block_bn3[0][0]          3a_conv_block_res_bn[0][0]       
__________________________________________________________________________________________________
3a_conv_block_relu4 (Activation (None, 28, 28, 512)  0           3a_conv_block_add[0][0]          
__________________________________________________________________________________________________
3b_identity_block_conv1 (Conv2D (None, 28, 28, 128)  65664       3a_conv_block_relu4[0][0]        
__________________________________________________________________________________________________
3b_identity_block_bn1 (BatchNor (None, 28, 28, 128)  512         3b_identity_block_conv1[0][0]    
__________________________________________________________________________________________________
3b_identity_block_relu1 (Activa (None, 28, 28, 128)  0           3b_identity_block_bn1[0][0]      
__________________________________________________________________________________________________
3b_identity_block_conv2 (Conv2D (None, 28, 28, 128)  147584      3b_identity_block_relu1[0][0]    
__________________________________________________________________________________________________
3b_identity_block_bn2 (BatchNor (None, 28, 28, 128)  512         3b_identity_block_conv2[0][0]    
__________________________________________________________________________________________________
3b_identity_block_relu2 (Activa (None, 28, 28, 128)  0           3b_identity_block_bn2[0][0]      
__________________________________________________________________________________________________
3b_identity_block_conv3 (Conv2D (None, 28, 28, 512)  66048       3b_identity_block_relu2[0][0]    
__________________________________________________________________________________________________
3b_identity_block_bn3 (BatchNor (None, 28, 28, 512)  2048        3b_identity_block_conv3[0][0]    
__________________________________________________________________________________________________
3b_identity_block_add (Add)     (None, 28, 28, 512)  0           3b_identity_block_bn3[0][0]      3a_conv_block_relu4[0][0]        
__________________________________________________________________________________________________
3b_identity_block_relu4 (Activa (None, 28, 28, 512)  0           3b_identity_block_add[0][0]      
__________________________________________________________________________________________________
3c_identity_block_conv1 (Conv2D (None, 28, 28, 128)  65664       3b_identity_block_relu4[0][0]    
__________________________________________________________________________________________________
3c_identity_block_bn1 (BatchNor (None, 28, 28, 128)  512         3c_identity_block_conv1[0][0]    
__________________________________________________________________________________________________
3c_identity_block_relu1 (Activa (None, 28, 28, 128)  0           3c_identity_block_bn1[0][0]      
__________________________________________________________________________________________________
3c_identity_block_conv2 (Conv2D (None, 28, 28, 128)  147584      3c_identity_block_relu1[0][0]    
__________________________________________________________________________________________________
3c_identity_block_bn2 (BatchNor (None, 28, 28, 128)  512         3c_identity_block_conv2[0][0]    
__________________________________________________________________________________________________
3c_identity_block_relu2 (Activa (None, 28, 28, 128)  0           3c_identity_block_bn2[0][0]      
__________________________________________________________________________________________________
3c_identity_block_conv3 (Conv2D (None, 28, 28, 512)  66048       3c_identity_block_relu2[0][0]    
__________________________________________________________________________________________________
3c_identity_block_bn3 (BatchNor (None, 28, 28, 512)  2048        3c_identity_block_conv3[0][0]    
__________________________________________________________________________________________________
3c_identity_block_add (Add)     (None, 28, 28, 512)  0           3c_identity_block_bn3[0][0]      3b_identity_block_relu4[0][0]    
__________________________________________________________________________________________________
3c_identity_block_relu4 (Activa (None, 28, 28, 512)  0           3c_identity_block_add[0][0]      
__________________________________________________________________________________________________
3d_identity_block_conv1 (Conv2D (None, 28, 28, 128)  65664       3c_identity_block_relu4[0][0]    
__________________________________________________________________________________________________
3d_identity_block_bn1 (BatchNor (None, 28, 28, 128)  512         3d_identity_block_conv1[0][0]    
__________________________________________________________________________________________________
3d_identity_block_relu1 (Activa (None, 28, 28, 128)  0           3d_identity_block_bn1[0][0]      
__________________________________________________________________________________________________
3d_identity_block_conv2 (Conv2D (None, 28, 28, 128)  147584      3d_identity_block_relu1[0][0]    
__________________________________________________________________________________________________
3d_identity_block_bn2 (BatchNor (None, 28, 28, 128)  512         3d_identity_block_conv2[0][0]    
__________________________________________________________________________________________________
3d_identity_block_relu2 (Activa (None, 28, 28, 128)  0           3d_identity_block_bn2[0][0]      
__________________________________________________________________________________________________
3d_identity_block_conv3 (Conv2D (None, 28, 28, 512)  66048       3d_identity_block_relu2[0][0]    
__________________________________________________________________________________________________
3d_identity_block_bn3 (BatchNor (None, 28, 28, 512)  2048        3d_identity_block_conv3[0][0]    
__________________________________________________________________________________________________
3d_identity_block_add (Add)     (None, 28, 28, 512)  0           3d_identity_block_bn3[0][0]      3c_identity_block_relu4[0][0]    
__________________________________________________________________________________________________
3d_identity_block_relu4 (Activa (None, 28, 28, 512)  0           3d_identity_block_add[0][0]      
__________________________________________________________________________________________________
4a_conv_block_conv1 (Conv2D)    (None, 14, 14, 256)  131328      3d_identity_block_relu4[0][0]    
__________________________________________________________________________________________________
4a_conv_block_bn1 (BatchNormali (None, 14, 14, 256)  1024        4a_conv_block_conv1[0][0]        
__________________________________________________________________________________________________
4a_conv_block_relu1 (Activation (None, 14, 14, 256)  0           4a_conv_block_bn1[0][0]          
__________________________________________________________________________________________________
4a_conv_block_conv2 (Conv2D)    (None, 14, 14, 256)  590080      4a_conv_block_relu1[0][0]        
__________________________________________________________________________________________________
4a_conv_block_bn2 (BatchNormali (None, 14, 14, 256)  1024        4a_conv_block_conv2[0][0]        
__________________________________________________________________________________________________
4a_conv_block_relu2 (Activation (None, 14, 14, 256)  0           4a_conv_block_bn2[0][0]          
__________________________________________________________________________________________________
4a_conv_block_conv3 (Conv2D)    (None, 14, 14, 1024) 263168      4a_conv_block_relu2[0][0]        
__________________________________________________________________________________________________
4a_conv_block_res_conv (Conv2D) (None, 14, 14, 1024) 525312      3d_identity_block_relu4[0][0]    
__________________________________________________________________________________________________
4a_conv_block_bn3 (BatchNormali (None, 14, 14, 1024) 4096        4a_conv_block_conv3[0][0]        
__________________________________________________________________________________________________
4a_conv_block_res_bn (BatchNorm (None, 14, 14, 1024) 4096        4a_conv_block_res_conv[0][0]     
__________________________________________________________________________________________________
4a_conv_block_add (Add)         (None, 14, 14, 1024) 0           4a_conv_block_bn3[0][0]          4a_conv_block_res_bn[0][0]       
__________________________________________________________________________________________________
4a_conv_block_relu4 (Activation (None, 14, 14, 1024) 0           4a_conv_block_add[0][0]          
__________________________________________________________________________________________________
4b_identity_block_conv1 (Conv2D (None, 14, 14, 256)  262400      4a_conv_block_relu4[0][0]        
__________________________________________________________________________________________________
4b_identity_block_bn1 (BatchNor (None, 14, 14, 256)  1024        4b_identity_block_conv1[0][0]    
__________________________________________________________________________________________________
4b_identity_block_relu1 (Activa (None, 14, 14, 256)  0           4b_identity_block_bn1[0][0]      
__________________________________________________________________________________________________
4b_identity_block_conv2 (Conv2D (None, 14, 14, 256)  590080      4b_identity_block_relu1[0][0]    
__________________________________________________________________________________________________
4b_identity_block_bn2 (BatchNor (None, 14, 14, 256)  1024        4b_identity_block_conv2[0][0]    
__________________________________________________________________________________________________
4b_identity_block_relu2 (Activa (None, 14, 14, 256)  0           4b_identity_block_bn2[0][0]      
__________________________________________________________________________________________________
4b_identity_block_conv3 (Conv2D (None, 14, 14, 1024) 263168      4b_identity_block_relu2[0][0]    
__________________________________________________________________________________________________
4b_identity_block_bn3 (BatchNor (None, 14, 14, 1024) 4096        4b_identity_block_conv3[0][0]    
__________________________________________________________________________________________________
4b_identity_block_add (Add)     (None, 14, 14, 1024) 0           4b_identity_block_bn3[0][0]      4a_conv_block_relu4[0][0]        
__________________________________________________________________________________________________
4b_identity_block_relu4 (Activa (None, 14, 14, 1024) 0           4b_identity_block_add[0][0]      
__________________________________________________________________________________________________
4c_identity_block_conv1 (Conv2D (None, 14, 14, 256)  262400      4b_identity_block_relu4[0][0]    
__________________________________________________________________________________________________
4c_identity_block_bn1 (BatchNor (None, 14, 14, 256)  1024        4c_identity_block_conv1[0][0]    
__________________________________________________________________________________________________
4c_identity_block_relu1 (Activa (None, 14, 14, 256)  0           4c_identity_block_bn1[0][0]      
__________________________________________________________________________________________________
4c_identity_block_conv2 (Conv2D (None, 14, 14, 256)  590080      4c_identity_block_relu1[0][0]    
__________________________________________________________________________________________________
4c_identity_block_bn2 (BatchNor (None, 14, 14, 256)  1024        4c_identity_block_conv2[0][0]    
__________________________________________________________________________________________________
4c_identity_block_relu2 (Activa (None, 14, 14, 256)  0           4c_identity_block_bn2[0][0]      
__________________________________________________________________________________________________
4c_identity_block_conv3 (Conv2D (None, 14, 14, 1024) 263168      4c_identity_block_relu2[0][0]    
__________________________________________________________________________________________________
4c_identity_block_bn3 (BatchNor (None, 14, 14, 1024) 4096        4c_identity_block_conv3[0][0]    
__________________________________________________________________________________________________
4c_identity_block_add (Add)     (None, 14, 14, 1024) 0           4c_identity_block_bn3[0][0]      4b_identity_block_relu4[0][0]    
__________________________________________________________________________________________________
4c_identity_block_relu4 (Activa (None, 14, 14, 1024) 0           4c_identity_block_add[0][0]      
__________________________________________________________________________________________________
4d_identity_block_conv1 (Conv2D (None, 14, 14, 256)  262400      4c_identity_block_relu4[0][0]    
__________________________________________________________________________________________________
4d_identity_block_bn1 (BatchNor (None, 14, 14, 256)  1024        4d_identity_block_conv1[0][0]    
__________________________________________________________________________________________________
4d_identity_block_relu1 (Activa (None, 14, 14, 256)  0           4d_identity_block_bn1[0][0]      
__________________________________________________________________________________________________
4d_identity_block_conv2 (Conv2D (None, 14, 14, 256)  590080      4d_identity_block_relu1[0][0]    
__________________________________________________________________________________________________
4d_identity_block_bn2 (BatchNor (None, 14, 14, 256)  1024        4d_identity_block_conv2[0][0]    
__________________________________________________________________________________________________
4d_identity_block_relu2 (Activa (None, 14, 14, 256)  0           4d_identity_block_bn2[0][0]      
__________________________________________________________________________________________________
4d_identity_block_conv3 (Conv2D (None, 14, 14, 1024) 263168      4d_identity_block_relu2[0][0]    
__________________________________________________________________________________________________
4d_identity_block_bn3 (BatchNor (None, 14, 14, 1024) 4096        4d_identity_block_conv3[0][0]    
__________________________________________________________________________________________________
4d_identity_block_add (Add)     (None, 14, 14, 1024) 0           4d_identity_block_bn3[0][0]      4c_identity_block_relu4[0][0]    
__________________________________________________________________________________________________
4d_identity_block_relu4 (Activa (None, 14, 14, 1024) 0           4d_identity_block_add[0][0]      
__________________________________________________________________________________________________
4e_identity_block_conv1 (Conv2D (None, 14, 14, 256)  262400      4d_identity_block_relu4[0][0]    
__________________________________________________________________________________________________
4e_identity_block_bn1 (BatchNor (None, 14, 14, 256)  1024        4e_identity_block_conv1[0][0]    
__________________________________________________________________________________________________
4e_identity_block_relu1 (Activa (None, 14, 14, 256)  0           4e_identity_block_bn1[0][0]      
__________________________________________________________________________________________________
4e_identity_block_conv2 (Conv2D (None, 14, 14, 256)  590080      4e_identity_block_relu1[0][0]    
__________________________________________________________________________________________________
4e_identity_block_bn2 (BatchNor (None, 14, 14, 256)  1024        4e_identity_block_conv2[0][0]    
__________________________________________________________________________________________________
4e_identity_block_relu2 (Activa (None, 14, 14, 256)  0           4e_identity_block_bn2[0][0]      
__________________________________________________________________________________________________
4e_identity_block_conv3 (Conv2D (None, 14, 14, 1024) 263168      4e_identity_block_relu2[0][0]    
__________________________________________________________________________________________________
4e_identity_block_bn3 (BatchNor (None, 14, 14, 1024) 4096        4e_identity_block_conv3[0][0]    
__________________________________________________________________________________________________
4e_identity_block_add (Add)     (None, 14, 14, 1024) 0           4e_identity_block_bn3[0][0]      4d_identity_block_relu4[0][0]    
__________________________________________________________________________________________________
4e_identity_block_relu4 (Activa (None, 14, 14, 1024) 0           4e_identity_block_add[0][0]      
__________________________________________________________________________________________________
4f_identity_block_conv1 (Conv2D (None, 14, 14, 256)  262400      4e_identity_block_relu4[0][0]    
__________________________________________________________________________________________________
4f_identity_block_bn1 (BatchNor (None, 14, 14, 256)  1024        4f_identity_block_conv1[0][0]    
__________________________________________________________________________________________________
4f_identity_block_relu1 (Activa (None, 14, 14, 256)  0           4f_identity_block_bn1[0][0]      
__________________________________________________________________________________________________
4f_identity_block_conv2 (Conv2D (None, 14, 14, 256)  590080      4f_identity_block_relu1[0][0]    
__________________________________________________________________________________________________
4f_identity_block_bn2 (BatchNor (None, 14, 14, 256)  1024        4f_identity_block_conv2[0][0]    
__________________________________________________________________________________________________
4f_identity_block_relu2 (Activa (None, 14, 14, 256)  0           4f_identity_block_bn2[0][0]      
__________________________________________________________________________________________________
4f_identity_block_conv3 (Conv2D (None, 14, 14, 1024) 263168      4f_identity_block_relu2[0][0]    
__________________________________________________________________________________________________
4f_identity_block_bn3 (BatchNor (None, 14, 14, 1024) 4096        4f_identity_block_conv3[0][0]    
__________________________________________________________________________________________________
4f_identity_block_add (Add)     (None, 14, 14, 1024) 0           4f_identity_block_bn3[0][0]      4e_identity_block_relu4[0][0]    
__________________________________________________________________________________________________
4f_identity_block_relu4 (Activa (None, 14, 14, 1024) 0           4f_identity_block_add[0][0]      
__________________________________________________________________________________________________
5a_conv_block_conv1 (Conv2D)    (None, 7, 7, 512)    524800      4f_identity_block_relu4[0][0]    
__________________________________________________________________________________________________
5a_conv_block_bn1 (BatchNormali (None, 7, 7, 512)    2048        5a_conv_block_conv1[0][0]        
__________________________________________________________________________________________________
5a_conv_block_relu1 (Activation (None, 7, 7, 512)    0           5a_conv_block_bn1[0][0]          
__________________________________________________________________________________________________
5a_conv_block_conv2 (Conv2D)    (None, 7, 7, 512)    2359808     5a_conv_block_relu1[0][0]        
__________________________________________________________________________________________________
5a_conv_block_bn2 (BatchNormali (None, 7, 7, 512)    2048        5a_conv_block_conv2[0][0]        
__________________________________________________________________________________________________
5a_conv_block_relu2 (Activation (None, 7, 7, 512)    0           5a_conv_block_bn2[0][0]          
__________________________________________________________________________________________________
5a_conv_block_conv3 (Conv2D)    (None, 7, 7, 2048)   1050624     5a_conv_block_relu2[0][0]        
__________________________________________________________________________________________________
5a_conv_block_res_conv (Conv2D) (None, 7, 7, 2048)   2099200     4f_identity_block_relu4[0][0]    
__________________________________________________________________________________________________
5a_conv_block_bn3 (BatchNormali (None, 7, 7, 2048)   8192        5a_conv_block_conv3[0][0]        
__________________________________________________________________________________________________
5a_conv_block_res_bn (BatchNorm (None, 7, 7, 2048)   8192        5a_conv_block_res_conv[0][0]     
__________________________________________________________________________________________________
5a_conv_block_add (Add)         (None, 7, 7, 2048)   0           5a_conv_block_bn3[0][0]          5a_conv_block_res_bn[0][0]       
__________________________________________________________________________________________________
5a_conv_block_relu4 (Activation (None, 7, 7, 2048)   0           5a_conv_block_add[0][0]          
__________________________________________________________________________________________________
5b_identity_block_conv1 (Conv2D (None, 7, 7, 512)    1049088     5a_conv_block_relu4[0][0]        
__________________________________________________________________________________________________
5b_identity_block_bn1 (BatchNor (None, 7, 7, 512)    2048        5b_identity_block_conv1[0][0]    
__________________________________________________________________________________________________
5b_identity_block_relu1 (Activa (None, 7, 7, 512)    0           5b_identity_block_bn1[0][0]      
__________________________________________________________________________________________________
5b_identity_block_conv2 (Conv2D (None, 7, 7, 512)    2359808     5b_identity_block_relu1[0][0]    
__________________________________________________________________________________________________
5b_identity_block_bn2 (BatchNor (None, 7, 7, 512)    2048        5b_identity_block_conv2[0][0]    
__________________________________________________________________________________________________
5b_identity_block_relu2 (Activa (None, 7, 7, 512)    0           5b_identity_block_bn2[0][0]      
__________________________________________________________________________________________________
5b_identity_block_conv3 (Conv2D (None, 7, 7, 2048)   1050624     5b_identity_block_relu2[0][0]    
__________________________________________________________________________________________________
5b_identity_block_bn3 (BatchNor (None, 7, 7, 2048)   8192        5b_identity_block_conv3[0][0]    
__________________________________________________________________________________________________
5b_identity_block_add (Add)     (None, 7, 7, 2048)   0           5b_identity_block_bn3[0][0]      5a_conv_block_relu4[0][0]        
__________________________________________________________________________________________________
5b_identity_block_relu4 (Activa (None, 7, 7, 2048)   0           5b_identity_block_add[0][0]      
__________________________________________________________________________________________________
5c_identity_block_conv1 (Conv2D (None, 7, 7, 512)    1049088     5b_identity_block_relu4[0][0]    
__________________________________________________________________________________________________
5c_identity_block_bn1 (BatchNor (None, 7, 7, 512)    2048        5c_identity_block_conv1[0][0]    
__________________________________________________________________________________________________
5c_identity_block_relu1 (Activa (None, 7, 7, 512)    0           5c_identity_block_bn1[0][0]      
__________________________________________________________________________________________________
5c_identity_block_conv2 (Conv2D (None, 7, 7, 512)    2359808     5c_identity_block_relu1[0][0]    
__________________________________________________________________________________________________
5c_identity_block_bn2 (BatchNor (None, 7, 7, 512)    2048        5c_identity_block_conv2[0][0]    
__________________________________________________________________________________________________
5c_identity_block_relu2 (Activa (None, 7, 7, 512)    0           5c_identity_block_bn2[0][0]      
__________________________________________________________________________________________________
5c_identity_block_conv3 (Conv2D (None, 7, 7, 2048)   1050624     5c_identity_block_relu2[0][0]    
__________________________________________________________________________________________________
5c_identity_block_bn3 (BatchNor (None, 7, 7, 2048)   8192        5c_identity_block_conv3[0][0]    
__________________________________________________________________________________________________
5c_identity_block_add (Add)     (None, 7, 7, 2048)   0           5c_identity_block_bn3[0][0]      5b_identity_block_relu4[0][0]    
__________________________________________________________________________________________________
5c_identity_block_relu4 (Activa (None, 7, 7, 2048)   0           5c_identity_block_add[0][0]      
__________________________________________________________________________________________________
avg_pool (AveragePooling2D)     (None, 1, 1, 2048)   0           5c_identity_block_relu4[0][0]    
__________________________________________________________________________________________________
flatten (Flatten)               (None, 2048)         0           avg_pool[0][0]                   
__________________________________________________________________________________________________
fc1000 (Dense)                  (None, 1000)         2049000     flatten[0][0]                    
==================================================================================================
Total params: 25,636,712
Trainable params: 25,583,592
Non-trainable params: 53,120
__________________________________________________________________________________________________

五、编译

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

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

# 设置优化器,我这里改变了学习率。
opt = tf.keras.optimizers.Adam(learning_rate=1e-7)model.compile(optimizer="adam",loss='sparse_categorical_crossentropy',metrics=['accuracy'])

六、训练模型

epochs = 10history = model.fit(train_ds,validation_data=val_ds,epochs=epochs
)
Epoch 1/10
57/57 [==============================] - 12s 87ms/step - loss: 2.4394 - accuracy: 0.6620 - val_loss: 484.4415 - val_accuracy: 0.1858
Epoch 2/10
57/57 [==============================] - 3s 55ms/step - loss: 0.3268 - accuracy: 0.8904 - val_loss: 5.5874 - val_accuracy: 0.4513
Epoch 3/10
57/57 [==============================] - 3s 52ms/step - loss: 0.1593 - accuracy: 0.9558 - val_loss: 2.0023 - val_accuracy: 0.6726
Epoch 4/10
57/57 [==============================] - 3s 52ms/step - loss: 0.0546 - accuracy: 0.9869 - val_loss: 1.4410 - val_accuracy: 0.7788
Epoch 5/10
57/57 [==============================] - 3s 51ms/step - loss: 0.1656 - accuracy: 0.9567 - val_loss: 2.1653 - val_accuracy: 0.5487
Epoch 6/10
57/57 [==============================] - 3s 51ms/step - loss: 0.2403 - accuracy: 0.9221 - val_loss: 1.0641 - val_accuracy: 0.7257
Epoch 7/10
57/57 [==============================] - 3s 52ms/step - loss: 0.1774 - accuracy: 0.9377 - val_loss: 0.4922 - val_accuracy: 0.8673
Epoch 8/10
57/57 [==============================] - 3s 51ms/step - loss: 0.0733 - accuracy: 0.9760 - val_loss: 0.2036 - val_accuracy: 0.9381
Epoch 9/10
57/57 [==============================] - 3s 51ms/step - loss: 0.0185 - accuracy: 0.9992 - val_loss: 0.1091 - val_accuracy: 0.9735
Epoch 10/10
57/57 [==============================] - 3s 51ms/step - loss: 0.0086 - accuracy: 1.0000 - val_loss: 0.1246 - val_accuracy: 0.9735

六、模型评估

acc = history.history['accuracy']
val_acc = history.history['val_accuracy']loss = history.history['loss']
val_loss = history.history['val_loss']epochs_range = range(epochs)plt.figure(figsize=(12, 4))
plt.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()

八、保存and加载模型

# 保存模型
model.save('model/my_model.h5')
# 加载模型
new_model = keras.models.load_model('model/my_model.h5')

九、预测

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

在这里插入图片描述

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

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

相关文章

基于社交网络算法优化概率神经网络PNN的分类预测 - 附代码

基于社交网络算法优化概率神经网络PNN的分类预测 - 附代码 文章目录 基于社交网络算法优化概率神经网络PNN的分类预测 - 附代码1.PNN网络概述2.变压器故障诊街系统相关背景2.1 模型建立 3.基于社交网络优化的PNN网络5.测试结果6.参考文献7.Matlab代码 摘要:针对PNN神…

一、MySQL-Replication(主从复制)

1.1、MySQL Replication 主从复制(也称 AB 复制)允许将来自一个MySQL数据库服务器(主服务器)的数据复制到一个或多个MySQL数据库服务器(从服务器)。 根据配置,您可以复制数据库中的所有数据库&a…

Flowable工作流基础篇

文章目录 一、Flowable介绍二、Flowable基础1.创建ProcessEngine2.部署流程定义3.启动流程实例4.查看任务5.完成任务6.流程的删除7.查看历史信息 三、Flowable流程设计器1.Eclipse Designer1.1 下载安装Eclipse1.2 安装Flowable插件1.3 创建项目1.4 创建流程图1.5 部署流程 2.F…

Maven工程继承关系,多个模块要使用同一个框架,它们应该是同一个版本,项目中使用的框架版本需要统一管理。

1、父工程pom.xml <?xml version"1.0" encoding"UTF-8"?> <project xmlns"http://maven.apache.org/POM/4.0.0"xmlns:xsi"http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation"http://maven.apache.org/PO…

KMP——字符串匹配

朴素匹配的逻辑&#xff1a; 将原串的指针移动至本次发起点的下一个位置&#xff08;b字符处&#xff09;&#xff1b;匹配串的指针移动至起始位置。尝试匹配&#xff0c;发现对不上&#xff0c;原串的指针会一直往后移动&#xff0c;直到能够与匹配串对上位置。 如图&#x…

(02)vite环境变量配置

文章目录 将开发环境和生产环境区分开环境变量vite处理环境变量loadEnv 业务代码需要使用环境变量.env.env.development.env.test修改VITE_前缀 将开发环境和生产环境区分开 分别创建三个vite 的配置文件&#xff0c;并将它们引入vite.config.js vite.base.config.js import…

深入探讨软件测试技术:方法、工具与最佳实践

&#x1f482; 个人网站:【 海拥】【神级代码资源网站】【办公神器】&#x1f91f; 基于Web端打造的&#xff1a;&#x1f449;轻量化工具创作平台&#x1f485; 想寻找共同学习交流的小伙伴&#xff0c;请点击【全栈技术交流群】 引言 软件测试是软件开发生命周期中至关重要的…

SO3 与so3 SE3与se3 SIM3

文章目录 1 旋转*叉乘1.1 旋转矩阵的导数1.2 物理意义1.3 实例1.4 角轴与反对称矩阵 2 SO3 与so32.1 so3 2 SO32.2 SO3 2 so3 3 SE3 与se33.1 se3 2 SE3:3.2 SE3 2 se3 4 SIM3 与sim35 Adjoint Map 1 旋转*叉乘 1.1 旋转矩阵的导数 根据旋转矩阵的性质&#xff1a; R R T I …

2023年以就业为目的学习Java还有必要吗?

文章目录 1活力四射的 Java2从零开始学会 Java3talk is cheap, show me the code4结语写作末尾 现在学 Java 找工作还有优势吗&#xff1f; 在某乎上可以看到大家对此问题的热议&#xff1a;“2023年以就业为目的学习Java还有必要吗&#xff1f;” 。有人说市场饱和&#xff0c…

基于白冠鸡算法优化概率神经网络PNN的分类预测 - 附代码

基于白冠鸡算法优化概率神经网络PNN的分类预测 - 附代码 文章目录 基于白冠鸡算法优化概率神经网络PNN的分类预测 - 附代码1.PNN网络概述2.变压器故障诊街系统相关背景2.1 模型建立 3.基于白冠鸡优化的PNN网络5.测试结果6.参考文献7.Matlab代码 摘要&#xff1a;针对PNN神经网络…

django ModelSerializer自定义显示字段

文章目录 前言一、问题二、解决 前言 最近在复习django的时候&#xff0c;发现了一个有趣的问题&#xff0c;解决了之后特意记录下来&#xff0c;以供以后参考。 一、问题 相信大家使用django的时候&#xff0c;被其DRF的强大功能所折服&#xff0c;因为它能通过简单的代码就…

威班11月份PMP模拟考试实录

11月份模拟考试于2023年11月18日在深圳市福田区鹏基商务时空大厦成功举办&#xff01; 本次线下模拟考试依旧是通过线上线下同步的方式进行&#xff0c;在深圳周边的学员直接到达现场参与模拟考试&#xff0c;全国各地不能到达现场的其他学员已提前收到考试所需资料&#xff0…

C++ LibCurl实现Web指纹识别

Web指纹识别是一种通过分析Web应用程序的特征和元数据&#xff0c;以确定应用程序所使用的技术栈和配置的技术。这项技术旨在识别Web服务器、Web应用框架、后端数据库、JavaScript库等组件的版本和配置信息。通过分析HTTP响应头、HTML源代码、JavaScript代码、CSS文件等&#x…

【ARM Trace32(劳特巴赫) 使用介绍 2.3 -- TRACE32 进阶命令之 参数传递介绍】

请阅读【ARM Coresight SoC-400/SoC-600 专栏导读】 文章目录 参数传递命令 ENTRY 参数传递命令 ENTRY ENTRY <parlist>The ENTRY command can be used to Pass parameters to a PRACTICE script or to a subroutineTo return a value from a subroutine 使用示例&am…

《洛谷深入浅出基础篇》P3916 图的遍历——逆向搜索

上链接&#xff1a; P3916 图的遍历 - 洛谷 | 计算机科学教育新生态 (luogu.com.cn)https://www.luogu.com.cn/problem/P3916上题干&#xff1a; 题目描述 给出 N 个点&#xff0c;M 条边的有向图&#xff0c;对于每个点 v&#xff0c;求 A(v) 表示从点 v 出发&#xff0c;能到…

合并区间(排序、贪心)

LCR 074. 合并区间 - 力扣&#xff08;LeetCode&#xff09; 题目描述 以数组 intervals 表示若干个区间的集合&#xff0c;其中单个区间为 intervals[i] [starti, endi] 。请你合并所有重叠的区间&#xff0c;并返回一个不重叠的区间数组&#xff0c;该数组需恰好覆盖输入中…

改进YOLOv8:结合Biformer——基于动态稀疏注意力构建高效金字塔网络架构

🗝️YOLOv8实战宝典--星级指南:从入门到精通,您不可错过的技巧   -- 聚焦于YOLO的 最新版本, 对颈部网络改进、添加局部注意力、增加检测头部,实测涨点 💡 深入浅出YOLOv8:我的专业笔记与技术总结   -- YOLOv8轻松上手, 适用技术小白,文章代码齐全,仅需 …

Unity 场景烘培 ——unity灯光和设置天空盒(二)

提示&#xff1a;文章有错误的地方&#xff0c;还望诸位大神指出。 文章目录 前言一、光源种类1.Directional Light(方向光&#xff0c;平行光)2.Point Light&#xff08;点光源&#xff09;3.Spotlight&#xff08;聚光灯&#xff09;4.Area Light&#xff08;区域光&#xff…

【C++】——多态性与模板(其二)

&#x1f383;个人专栏&#xff1a; &#x1f42c; 算法设计与分析&#xff1a;算法设计与分析_IT闫的博客-CSDN博客 &#x1f433;Java基础&#xff1a;Java基础_IT闫的博客-CSDN博客 &#x1f40b;c语言&#xff1a;c语言_IT闫的博客-CSDN博客 &#x1f41f;MySQL&#xff1a…

import.meta.glob() 如何导入多个目录下的资源

import.meta.glob() 如何导入多个目录下的资源 刚开始用 vite&#xff0c;在做动态路由的时候遇到了这个问题&#xff0c;看到其它教程上都是只引用了一个目录层级的内容&#xff0c;比如这样&#xff1a; let RouterModules import.meta.glob("/src/view/*/*.vue"…