tensorflow案例5--基于改进VGG16模型的马铃薯识别,准确率提升0.6%,计算量降低78.07%

  • 🍨 本文为🔗365天深度学习训练营 中的学习记录博客
  • 🍖 原作者:K同学啊

前言

  • 本次采用VGG16模型进行预测,准确率达到了98.875,但是修改VGG16网络结构, 准确率达到了0.9969,并且计算量下降78.07%

1、API积累

VGG16简介

VGG优缺点分析:

  • VGG优点

VGG的结构非常简洁,整个网络都使用了同样大小的卷积核尺寸(3x3)和最大池化尺寸(2x2)

  • VGG缺点

1)训练时间过长,调参难度大。2)需要的存储容量大,不利于部署。例如存储VGG-16权重值文件的大小为500多MB,不利于安装到嵌入式系统中。

后面优化也是基于VGG的缺点来进行

VGG结构图如下(PPT绘制):

在这里插入图片描述

API积累

🚄 优化

  • shuffle() :打乱数据,关于此函数的详细介绍可以参考:https://zhuanlan.zhihu.com/p/42417456
  • prefetch() :预取数据,加速运行,TensorFlow的prefetch方法用于在GPU执行计算时,由CPU预处理下一个批次的数据,实现生产者/消费者重叠,提高训练效率,参考本专栏案例一:https://yxzbk.blog.csdn.net/article/details/142862154
  • cache() :将数据集缓存到内存当中,加速运行

💂 像素归一化

讲像素映射到—> [0, 1]中,代码如下:

# 归一化数据
normalization_layer = layers.experimental.preprocessing.Rescaling(1.0 / 255)# 训练集和验证集归一化
train_ds = train_ds.map(lambda x, y : (normalization_layer(x), y))
val_ds = val_ds.map(lambda x, y : (normalization_layer(x), y))

💛 优化器

本文全连接层最后一层采用softmax,故优化器为SparseCategoricalCrossentropy

SparseCategoricalCrossentropy函数注意事项:

from_logits参数:

  • 布尔值,默认值为 False
  • 当为 True 时,函数假设传入的预测值是未经过激活函数处理的原始 logits 值。如果模型的最后一层没有使用 softmax 激活函数(即返回 logits),需要将 from_logits 设置为 True
  • 当为 False 时,函数假设传入的预测值已经是经过 softmax 处理的概率分布。

2、案例

1、数据处理

1、导入库

import tensorflow as tf 
from tensorflow.keras import models, layers, datasets
import matplotlib.pyplot as plt 
import numpy as np # 判断支持gpu
gpus = tf.config.list_physical_devices("GPU")if gpus:gpu0 = gpus[0]tf.config.experimental.set_memory_growth(gpu0, True)tf.config.set_visible_devices([gpu0], "GPU")gpus
[PhysicalDevice(name='/physical_device:GPU:0', device_type='GPU')]

2、查看数据目录,获取类别

数据存储格式:data/ 下每个类别分别存储在不同模块中

import os, pathlibdata_dir = './data/'
data_dir = pathlib.Path(data_dir)# 查看data_dir下的所有文件名
classnames = os.listdir(data_dir)
classnames
['Dark', 'Green', 'Light', 'Medium']

3、导入数据与划分数据集

# 训练集 : 测试集 = 8 :2batch_size = 32 
img_width, img_height = 224, 224train_ds = tf.keras.preprocessing.image_dataset_from_directory('./data/',validation_split = 0.2,batch_size=batch_size,image_size = (img_width, img_height),shuffle = True,subset='training',seed=42
)val_ds = tf.keras.preprocessing.image_dataset_from_directory('./data/',validation_split = 0.2,batch_size=batch_size,image_size = (img_width, img_height),shuffle = True,subset='validation',seed=42
)
Found 1200 files belonging to 4 classes.
Using 960 files for training.
Found 1200 files belonging to 4 classes.
Using 240 files for validation.
# 查看数据格式
for X, y in train_ds.take(1):print("[N, W, H, C]", X.shape)print("lables: ", y)break
[N, W, H, C] (32, 224, 224, 3)
lables:  tf.Tensor([0 0 2 3 1 1 1 3 0 1 2 2 2 1 0 2 0 2 1 0 0 1 2 1 3 2 2 2 1 0 2 3], shape=(32,), dtype=int32)
# 查看原始数据像素
imgs, labelss = next(iter(train_ds))  # 获取一批数据
first = imgs[0]
print(first.shape)
print(np.min(first), np.max(first))
(224, 224, 3)
0.0 255.0

4、展示一批数据

plt.figure(figsize=(20, 10))for images, labels in train_ds.take(1):for i in range(20):plt.subplot(5, 10, i + 1)  # H, Wplt.imshow(images[i].numpy().astype("uint8"))plt.title(classnames[labels[i]])plt.axis('off')plt.show()


在这里插入图片描述

5、配置数据集与归一化数据

  • shuffle() :打乱数据,关于此函数的详细介绍可以参考:https://zhuanlan.zhihu.com/p/42417456
  • prefetch() :预取数据,加速运行,TensorFlow的prefetch方法用于在GPU执行计算时,由CPU预处理下一个批次的数据,实现生产者/消费者重叠,提高训练效率,参考本专栏案例一:https://yxzbk.blog.csdn.net/article/details/142862154
  • cache() :将数据集缓存到内存当中,加速运行
# 加速
# 变量名比较复杂,但是代码比较固定
from tensorflow.data.experimental import AUTOTUNEAUTOTUNE = tf.data.experimental.AUTOTUNE# 打乱加速
train_ds = train_ds.cache().shuffle(1000).prefetch(buffer_size=AUTOTUNE)
val_ds = val_ds.cache().prefetch(buffer_size=AUTOTUNE)
# 归一化数据
normalization_layer = layers.experimental.preprocessing.Rescaling(1.0 / 255)# 训练集和验证集归一化
train_ds = train_ds.map(lambda x, y : (normalization_layer(x), y))
val_ds = val_ds.map(lambda x, y : (normalization_layer(x), y))
# 查看归一化数据
image_batch, label_batch = next(iter(val_ds))
# 取一个元素
first_image = image_batch[0]# 查看
print(np.min(first_image), np.max(first_image))   # 查看像素最大值,最小值
print(image_batch.shape)
print(first_image.shape)
0.0 1.0
(32, 224, 224, 3)
(224, 224, 3)
2024-11-08 18:37:15.334784: W tensorflow/core/kernels/data/cache_dataset_ops.cc:856] The calling iterator did not fully read the dataset being cached. In order to avoid unexpected truncation of the dataset, the partially cached contents of the dataset  will be discarded. This can happen if you have an input pipeline similar to `dataset.cache().take(k).repeat()`. You should use `dataset.take(k).cache().repeat()` instead.

2、手动搭建VGG16网络

def VGG16(class_num, input_shape):inputs = layers.Input(input_shape)# 1st blockx = layers.Conv2D(64, kernel_size=(3, 3), activation='relu', strides=(1, 1), padding='same')(inputs)x = layers.Conv2D(64, kernel_size=(3, 3), activation='relu', strides=(1, 1), padding='same')(x)x = layers.MaxPooling2D((2, 2), strides=(2, 2))(x)# 2nd blockx = layers.Conv2D(128, kernel_size=(3, 3), activation='relu', strides=(1, 1), padding='same')(x)x = layers.Conv2D(128, kernel_size=(3, 3), activation='relu', strides=(1, 1), padding='same')(x)x = layers.MaxPooling2D((2, 2), strides=(2, 2))(x)# 3rd blockx = layers.Conv2D(256, kernel_size=(3, 3), activation='relu', strides=(1, 1), padding='same')(x)x = layers.Conv2D(256, kernel_size=(3, 3), activation='relu', strides=(1, 1), padding='same')(x)x = layers.Conv2D(256, kernel_size=(3, 3), activation='relu', strides=(1, 1), padding='same')(x)x = layers.MaxPooling2D((2, 2), strides=(2, 2))(x)# 4th blockx = layers.Conv2D(512, kernel_size=(3, 3), activation='relu', strides=(1, 1), padding='same')(x)x = layers.Conv2D(512, kernel_size=(3, 3), activation='relu', strides=(1, 1), padding='same')(x)x = layers.Conv2D(512, kernel_size=(3, 3), activation='relu', strides=(1, 1), padding='same')(x)x = layers.MaxPooling2D((2, 2), strides=(2, 2))(x)# 5th blockx = layers.Conv2D(512, kernel_size=(3, 3), activation='relu', strides=(1, 1), padding='same')(x)x = layers.Conv2D(512, kernel_size=(3, 3), activation='relu', strides=(1, 1), padding='same')(x)x = layers.Conv2D(512, kernel_size=(3, 3), activation='relu', strides=(1, 1), padding='same')(x)x = layers.MaxPooling2D((2, 2), strides=(2, 2))(x)# 全连接层, 这里修改以下x = layers.Flatten()(x)x = layers.Dense(4096, activation='relu')(x)x = layers.Dense(4096, activation='relu')(x)# 最后一层用激活函数:softmaxout_shape = layers.Dense(class_num, activation='softmax')(x)# 创建模型model = models.Model(inputs=inputs, outputs=out_shape)return modelmodel = VGG16(len(classnames), (img_width, img_height, 3))
model.summary()
Model: "model"
_________________________________________________________________Layer (type)                Output Shape              Param #   
=================================================================input_1 (InputLayer)        [(None, 224, 224, 3)]     0         conv2d (Conv2D)             (None, 224, 224, 64)      1792      conv2d_1 (Conv2D)           (None, 224, 224, 64)      36928     max_pooling2d (MaxPooling2D  (None, 112, 112, 64)     0         )                                                               conv2d_2 (Conv2D)           (None, 112, 112, 128)     73856     conv2d_3 (Conv2D)           (None, 112, 112, 128)     147584    max_pooling2d_1 (MaxPooling  (None, 56, 56, 128)      0         2D)                                                             conv2d_4 (Conv2D)           (None, 56, 56, 256)       295168    conv2d_5 (Conv2D)           (None, 56, 56, 256)       590080    conv2d_6 (Conv2D)           (None, 56, 56, 256)       590080    max_pooling2d_2 (MaxPooling  (None, 28, 28, 256)      0         2D)                                                             conv2d_7 (Conv2D)           (None, 28, 28, 512)       1180160   conv2d_8 (Conv2D)           (None, 28, 28, 512)       2359808   conv2d_9 (Conv2D)           (None, 28, 28, 512)       2359808   max_pooling2d_3 (MaxPooling  (None, 14, 14, 512)      0         2D)                                                             conv2d_10 (Conv2D)          (None, 14, 14, 512)       2359808   conv2d_11 (Conv2D)          (None, 14, 14, 512)       2359808   conv2d_12 (Conv2D)          (None, 14, 14, 512)       2359808   max_pooling2d_4 (MaxPooling  (None, 7, 7, 512)        0         2D)                                                             flatten (Flatten)           (None, 25088)             0         dense (Dense)               (None, 4096)              102764544 dense_1 (Dense)             (None, 4096)              16781312  dense_2 (Dense)             (None, 4)                 16388     =================================================================
Total params: 134,276,932
Trainable params: 134,276,932
Non-trainable params: 0
_________________________________________________________________

3、模型的训练

1、设置超参数

learn_rate = 1e-4# 动态学习率
lr_schedule = tf.keras.optimizers.schedules.ExponentialDecay(learn_rate,decay_steps=20,decay_rate=0.95,staircase=True
)# 设置优化器
opt = tf.keras.optimizers.Adam(learning_rate=learn_rate)# 设置超参数
model.compile(optimizer=opt,loss=tf.keras.losses.SparseCategoricalCrossentropy(from_logits=False),metrics=['accuracy']
)

2、模型训练

from tensorflow.keras.callbacks import ModelCheckpoint, EarlyStopping# 设置训练次数
epochs = 20# 设置早停
earlystopper = EarlyStopping(monitor='val_accuracy',min_delta=0.001,patience=20,verbose=1)# 保存最佳模型
checkpointer = ModelCheckpoint('best_model.h5',monitor='val_accuracy',verbose=1,save_best_only=True,save_weight_only=True)history = model.fit(x=train_ds,validation_data=val_ds,epochs=epochs,verbose=1,callbacks=[earlystopper, checkpointer]
)
Epoch 1/20
2024-11-08 18:37:27.650111: I tensorflow/stream_executor/cuda/cuda_dnn.cc:384] Loaded cuDNN version 8101
2024-11-08 18:37:31.754452: I tensorflow/stream_executor/cuda/cuda_blas.cc:1786] TensorFloat-32 will be used for the matrix multiplication. This will only be logged once.
30/30 [==============================] - ETA: 0s - loss: 1.3401 - accuracy: 0.3094
Epoch 1: val_accuracy improved from -inf to 0.55833, saving model to best_model.h5
30/30 [==============================] - 17s 255ms/step - loss: 1.3401 - accuracy: 0.3094 - val_loss: 0.9073 - val_accuracy: 0.5583
Epoch 2/20
30/30 [==============================] - ETA: 0s - loss: 0.9208 - accuracy: 0.5406
Epoch 2: val_accuracy improved from 0.55833 to 0.63333, saving model to best_model.h5
30/30 [==============================] - 7s 223ms/step - loss: 0.9208 - accuracy: 0.5406 - val_loss: 0.6053 - val_accuracy: 0.6333
Epoch 3/20
30/30 [==============================] - ETA: 0s - loss: 0.6325 - accuracy: 0.6594
Epoch 3: val_accuracy did not improve from 0.63333
30/30 [==============================] - 4s 128ms/step - loss: 0.6325 - accuracy: 0.6594 - val_loss: 0.7538 - val_accuracy: 0.5542
Epoch 4/20
30/30 [==============================] - ETA: 0s - loss: 0.5219 - accuracy: 0.7115
Epoch 4: val_accuracy improved from 0.63333 to 0.82083, saving model to best_model.h5
30/30 [==============================] - 7s 246ms/step - loss: 0.5219 - accuracy: 0.7115 - val_loss: 0.4044 - val_accuracy: 0.8208
Epoch 5/20
30/30 [==============================] - ETA: 0s - loss: 0.3322 - accuracy: 0.8771
Epoch 5: val_accuracy improved from 0.82083 to 0.86667, saving model to best_model.h5
30/30 [==============================] - 7s 238ms/step - loss: 0.3322 - accuracy: 0.8771 - val_loss: 0.3286 - val_accuracy: 0.8667
Epoch 6/20
30/30 [==============================] - ETA: 0s - loss: 0.1433 - accuracy: 0.9573
Epoch 6: val_accuracy improved from 0.86667 to 0.95417, saving model to best_model.h5
30/30 [==============================] - 7s 230ms/step - loss: 0.1433 - accuracy: 0.9573 - val_loss: 0.1310 - val_accuracy: 0.9542
Epoch 7/20
30/30 [==============================] - ETA: 0s - loss: 0.0982 - accuracy: 0.9594
Epoch 7: val_accuracy improved from 0.95417 to 0.97917, saving model to best_model.h5
30/30 [==============================] - 7s 233ms/step - loss: 0.0982 - accuracy: 0.9594 - val_loss: 0.0739 - val_accuracy: 0.9792
Epoch 8/20
30/30 [==============================] - ETA: 0s - loss: 0.0630 - accuracy: 0.9802
Epoch 8: val_accuracy did not improve from 0.97917
30/30 [==============================] - 4s 127ms/step - loss: 0.0630 - accuracy: 0.9802 - val_loss: 0.2461 - val_accuracy: 0.9250
Epoch 9/20
30/30 [==============================] - ETA: 0s - loss: 0.1089 - accuracy: 0.9625
Epoch 9: val_accuracy improved from 0.97917 to 0.98333, saving model to best_model.h5
30/30 [==============================] - 6s 217ms/step - loss: 0.1089 - accuracy: 0.9625 - val_loss: 0.0717 - val_accuracy: 0.9833
Epoch 10/20
30/30 [==============================] - ETA: 0s - loss: 0.0392 - accuracy: 0.9885
Epoch 10: val_accuracy did not improve from 0.98333
30/30 [==============================] - 4s 126ms/step - loss: 0.0392 - accuracy: 0.9885 - val_loss: 0.0901 - val_accuracy: 0.9708
Epoch 11/20
30/30 [==============================] - ETA: 0s - loss: 0.0297 - accuracy: 0.9854
Epoch 11: val_accuracy improved from 0.98333 to 0.98750, saving model to best_model.h5
30/30 [==============================] - 7s 232ms/step - loss: 0.0297 - accuracy: 0.9854 - val_loss: 0.0629 - val_accuracy: 0.9875
Epoch 12/20
30/30 [==============================] - ETA: 0s - loss: 0.0331 - accuracy: 0.9885
Epoch 12: val_accuracy did not improve from 0.98750
30/30 [==============================] - 4s 127ms/step - loss: 0.0331 - accuracy: 0.9885 - val_loss: 0.0384 - val_accuracy: 0.9875
Epoch 13/20
30/30 [==============================] - ETA: 0s - loss: 0.1043 - accuracy: 0.9708
Epoch 13: val_accuracy did not improve from 0.98750
30/30 [==============================] - 4s 128ms/step - loss: 0.1043 - accuracy: 0.9708 - val_loss: 0.0445 - val_accuracy: 0.9833
Epoch 14/20
30/30 [==============================] - ETA: 0s - loss: 0.0352 - accuracy: 0.9833
Epoch 14: val_accuracy did not improve from 0.98750
30/30 [==============================] - 4s 134ms/step - loss: 0.0352 - accuracy: 0.9833 - val_loss: 0.1387 - val_accuracy: 0.9500
Epoch 15/20
30/30 [==============================] - ETA: 0s - loss: 0.1128 - accuracy: 0.9594
Epoch 15: val_accuracy did not improve from 0.98750
30/30 [==============================] - 4s 128ms/step - loss: 0.1128 - accuracy: 0.9594 - val_loss: 0.4397 - val_accuracy: 0.8125
Epoch 16/20
30/30 [==============================] - ETA: 0s - loss: 0.0949 - accuracy: 0.9646
Epoch 16: val_accuracy did not improve from 0.98750
30/30 [==============================] - 4s 130ms/step - loss: 0.0949 - accuracy: 0.9646 - val_loss: 0.1068 - val_accuracy: 0.9500
Epoch 17/20
30/30 [==============================] - ETA: 0s - loss: 0.0618 - accuracy: 0.9781
Epoch 17: val_accuracy did not improve from 0.98750
30/30 [==============================] - 4s 128ms/step - loss: 0.0618 - accuracy: 0.9781 - val_loss: 0.1663 - val_accuracy: 0.9292
Epoch 18/20
30/30 [==============================] - ETA: 0s - loss: 0.0351 - accuracy: 0.9854
Epoch 18: val_accuracy did not improve from 0.98750
30/30 [==============================] - 4s 128ms/step - loss: 0.0351 - accuracy: 0.9854 - val_loss: 0.0687 - val_accuracy: 0.9792
Epoch 19/20
30/30 [==============================] - ETA: 0s - loss: 0.0609 - accuracy: 0.9781
Epoch 19: val_accuracy did not improve from 0.98750
30/30 [==============================] - 4s 128ms/step - loss: 0.0609 - accuracy: 0.9781 - val_loss: 0.0963 - val_accuracy: 0.9708
Epoch 20/20
30/30 [==============================] - ETA: 0s - loss: 0.0263 - accuracy: 0.9896
Epoch 20: val_accuracy did not improve from 0.98750
30/30 [==============================] - 4s 127ms/step - loss: 0.0263 - accuracy: 0.9896 - val_loss: 0.2104 - val_accuracy: 0.9458
  • 最好效果:val_accuracy did not improve from 0.98750

4、结果显示

# 获取训练集和验证集损失率和准确率
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()


在这里插入图片描述

3、优化

讲全连接层进行优化,对其减少全连接层神经元的数量:

# 原来
x = layers.Flatten()(x)
x = layers.Dense(4096, activation='relu')(x)
x = layers.Dense(4096, activation='relu')(x)
# 最后一层用激活函数:softmax
out_shape = layers.Dense(class_num, activation='softmax')(x)# 修改
x = layers.Flatten()(x)
x = layers.Dense(1024, activation='relu')(x)
x = layers.Dense(512, activation='relu')(x)
# 最后一层用激活函数:softmax
out_shape = layers.Dense(class_num, activation='softmax')(x)

修改效果:loss: 0.0166 - accuracy: 0.9969,准确率提升:0.6%个百分点,但是计算量确实大量减少

在这里插入图片描述

修改前的全连接层参数数量

  1. 第一个 Dense 层:输入 25088,输出 4096
    • 参数数量:( (25088 + 1) \times 4096 = 102764544 )
  2. 第二个 Dense 层:输入 4096,输出 4096
    • 参数数量:( (4096 + 1) \times 4096 = 16781312 )
  3. 输出层:输入 4096,输出 4
    • 参数数量:( (4096 + 1) \times 4 = 16388 )

总参数数量:( 102764544 + 16781312 + 16388 = 119562244 )

修改后的全连接层参数数量

  1. 第一个 Dense 层:输入 25088,输出 1024
    • 参数数量:( (25088 + 1) \times 1024 = 25690112 )
  2. 第二个 Dense 层:输入 1024,输出 512
    • 参数数量:( (1024 + 1) \times 512 = 524800 )
  3. 输出层:输入 512,输出 4
    • 参数数量:( (512 + 1) \times 4 = 2052 )

总参数数量:( 25690112 + 524800 + 2052 = 26216964 )

计算减少的百分比

减少的参数数量:
119562244−26216964=93345280

减少的百分比:
93345280 119562244 × 100 % ≈ 78.07 % \frac{93345280}{119562244}\times100\%\approx78.07\% 11956224493345280×100%78.07%

因此,修改后计算量(以参数数量衡量)减少了约 78.07%

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

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

相关文章

Spring Boot编程训练系统:构建可扩展的应用

摘要 随着信息技术在管理上越来越深入而广泛的应用,管理信息系统的实施在技术上已逐步成熟。本文介绍了编程训练系统的开发全过程。通过分析编程训练系统管理的不足,创建了一个计算机管理编程训练系统的方案。文章介绍了编程训练系统的系统分析部分&…

Java-sec-code-SSRF攻击

Java-sec-code(SSRF攻击) java-sec-code平台中也内置了SSRF攻击案例,我们来看看SSRF漏洞代码是什么样的。 案例1 直接从url参数接收数据,但是未进行任何检查和校验。 通过调用httpUtil.URLConnection方法,建立URL对…

docker基础:搭建centos7(详见B站泷羽sec)

docker的简单学习: sudo apt-get update //这个命令让系统检查有没有新软件 sudo apt-get install docker.io //安装 Docker sudo docker version //查看是否安装成功,显示docker的版本信息 启用Docker 启…

RNN(循环神经网络)详解

1️⃣ RNN介绍 前馈神经网络(CNN,全连接网络)的流程是前向传播、反向传播和参数更新,存在以下不足: 无法处理时序数据:时序数据长度一般不固定,而前馈神经网络要求输入和输出的维度是固定的&a…

解剖C++模板(2) —— 模板匹配规则及特化

众所周知,模板声明部分的尖括号中的内容是声明模板形参,而调用模板时的尖括号是给模板传参。然而这样理解仅仅停留于现象,只是将模板形参传参和函数传参的过程划等号了。C 的函数重载匹配并非真的进行匹配,因为函数名修饰规则导致…

题目讲解15 合并两个排序的链表

原题链接: 合并两个排序的链表_牛客题霸_牛客网 思路分析: 第一步:写一个链表尾插数据的方法。 typedef struct ListNode ListNode;//申请结点 ListNode* BuyNode(int x) {ListNode* node (ListNode*)malloc(sizeof(ListNode));node->…

高性能Web网关:OpenResty 基础讲解

一:概述 OpenResty是由国人章亦春开发的一个基于Nginx的可伸缩的Web平台。 openresty 是一个基于 nginx 与 lua 的高性能 web 平台,其内部集成了大量精良的 lua 库、第三方模块以及大数的依赖项。用于方便搭建能够处理超高并发、扩展性极高的动态 web 应…

OceanBase JDBC (Java数据库连接)的概念、分类与兼容性

本章将介绍 OceanBase JDBC的 概念与分类,已帮助使用 JDBC 的用户及技术人员更好的 了解JDBC,以及 OceanBase JDBC在与 MySQL 及 Oracle 兼容性方面的相关能力。 一、JDBC 基础 1.1 JDBC 的概念 JDBC 一般指 Java 数据库连接。Java 数据库连接&#xf…

小程序中引入下载到本地的iconfont字体图标加载不出来问题解决

我这个是uniapp项目,字体图标都是一样的,在vue项目中web端、uniapp运行到h5都没问题,但是运行到小程序加载不出来,报错如下: 不让用本地路径,所以我们要转为base64编码,这里给大家提供一个工具,它可以把本地字体文件转为base64:transfonter 进入官网后,第一步: …

如何在 Ubuntu 24.04 上安装和配置 Fail2ban ?

确保你的 Ubuntu 24.04 服务器的安全是至关重要的,特别是如果它暴露在互联网上。一个常见的威胁是未经授权的访问尝试,特别是通过 SSH。Fail2ban 是一个强大的工具,可以通过自动阻止可疑活动来帮助保护您的服务器。 在本指南中,我…

多商户中英双语电商系统设计与开发 PHP+mysql

随着全球电商市场的扩展,多商户平台成为了越来越多商家参与全球贸易的重要方式。为了适应不同语言用户的需求,尤其是中英双语用户的需求,设计一个支持中英双语的电商系统显得尤为重要。本文将重点探讨如何设计一个多商户中英双语电商系统&…

关于 3D Engine Design for Virtual Globes(三维数字地球引擎设计)

《3D Engine Design for Virtual Globes》是一本专注于三维虚拟地球引擎设计的专业书籍。这本书由Patrick Cozzi和Kevin Ring编写,覆盖了设计适用于虚拟球面环境的三维引擎的各个方面。虚拟地球引擎作为地理信息系统(GIS)中的一个核心组件&am…

单元测试、集成测试、系统测试有什么区别

🍅 点击文末小卡片 ,免费获取软件测试全套资料,资料在手,涨薪更快 单元测试、集成测试、系统测试有什么区别 1、粒度不同 集成测试bai粒度居中,单元测试粒度最小,系统du测试粒度最大。 2、测试方式不同…

CE2.【C++ Cont】练习题组2

1.数字反转 https://www.luogu.com.cn/problem/P5705 题目描述 输入一个不小于 100100 且小于 10001000,同时包括小数点后一位的一个浮点数,例如 123.4123.4 ,要求把这个数字翻转过来,变成 4.3214.321 并输出。 输入格式 一行一个…

Golang | Leetcode Golang题解之第557题反转字符串中的单词III

题目&#xff1a; 题解&#xff1a; func reverseWords(s string) string {length : len(s)ret : []byte{}for i : 0; i < length; {start : ifor i < length && s[i] ! {i}for p : start; p < i; p {ret append(ret, s[start i - 1 - p])}for i < le…

适合二开的web组态?

一、web组态的定义和背景 在深入探讨之前&#xff0c;我们先回顾一下“组态”的定义。在工业自动化领域&#xff0c;组态软件是用于创建监控和数据采集&#xff08;SCADA&#xff09;系统的工具&#xff0c;它允许工程师构建图形界面&#xff0c;实现与各种设备和机器的数据交互…

【大数据学习 | HBASE】hbase的读数据流程与hbase读取数据

1. hbase的读数据流程 在解析读取流程之前我们还需要知道两个功能性的组件和HFIle的格式信息 HFILE 存储在hdfs中的hbase文件&#xff0c;这个文件中会存在hbase中的数据以kv类型显示&#xff0c;同时还会存在hbase的元数据信息&#xff0c;包括整个hfile文件的索引大小&…

MySQL 忘记 root 密码,使用跳过密码验证进行登录

MySQL 忘记 root 密码&#xff0c;使用跳过密码验证进行登录 修改 /etc/my.cnf 配置文件&#xff0c;在 [mysqld] 后面任意一行添加 skip-grant-tables vim /etc/my.cnf 重启 MySQL systemctl restart mysqld 登录 MySQL&#xff08;无 -p 选项&#xff0c;无需密码登录&…

[Linux]IO多路转接(上)

1. IO 多路转接之select 1.1 select概述 select 是系统提供的一个多路转接接口&#xff0c;其核心工作在于等待。它能够让程序同时监视多个文件描述符上的事件是否就绪&#xff0c;只有当被监视的多个文件描述符中有一个或多个事件就绪时&#xff0c;select 才会成功返回&…

推荐一款电脑清理和加速工具:Wise Care 365 Pro

Wise Care 365 Pro是一款可以清理注册表和磁盘垃圾文件&#xff0c;保护个人隐私记录&#xff0c;提高电脑使用安全的软件&#xff0c;是优化系统、提高Windows系统运行速度最好的选择!实时保护注册表不被其他程序未经许可地秘密修改。例如阻止程序更改您的浏览器主页&#xff…