基于可解释性深度学习的马铃薯叶病害检测

news2024/11/28 5:41:22

数据集来自kaggle文章,代码较为简单。

import numpy as np # linear algebra
import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)


# Input data files are available in the read-only "../input/" directory
# For example, running this (by clicking run or pressing Shift+Enter) will list all files under the input directory


import os
for dirname, _, filenames in os.walk('/kaggle/input'):
    for filename in filenames:
        print(os.path.join(dirname, filename))

Neural Network Model with TensorFlow and Keras for Classification

import tensorflow as tf
from tensorflow.keras import models,layers
import matplotlib.pyplot as plt


BATCH_SIZE=32
IMAGE_SIZE=224
CHANNELS=3
EPOCHS=50

Loading Image Dataset for Training

dataset=tf.keras.preprocessing.image_dataset_from_directory(
    "/kaggle/input/potato-dataset/PlantVillage",
    shuffle=True,
    image_size=(IMAGE_SIZE,IMAGE_SIZE),
    batch_size=BATCH_SIZE
)

Retrieving Class Names from the Dataset

class_names=dataset.class_names
class_names

Data Visualization

import os


Potato___Early_blight_dir = '/kaggle/input/potato-dataset/PlantVillage/Potato___Early_blight'
Potato___Late_blight_dir = '/kaggle/input/potato-dataset/PlantVillage/Potato___Late_blight'
Potato___healthy_dir = '/kaggle/input/potato-dataset/PlantVillage/Potato___healthy'
import matplotlib.pyplot as plt


# Define the categories and corresponding counts
categories = ['Early Leaf Blight','Late Leaf Blight','Healthy']
counts = [len(os.listdir(Potato___Early_blight_dir)), len(os.listdir(Potato___Late_blight_dir)), len(os.listdir(Potato___healthy_dir))]


# Create a bar plot to visualize the distribution of images
plt.figure(figsize=(12, 6))
plt.bar(categories, counts, color='skyblue')
plt.xlabel('Categories')
plt.ylabel('Number of Images')
plt.title('Distribution of Images in Different Categories')
plt.show()

Visualizing Sample Images from the Dataset

plt.figure(figsize=(10,10))
for image_batch, labels_batch in dataset.take(1):
    print(image_batch.shape)
    print(labels_batch.numpy())
    for i in range(12):
        ax=plt.subplot(3,4,i+1)
        plt.imshow(image_batch[i].numpy().astype("uint8"))
        plt.title(class_names[labels_batch[i]])
        plt.axis("off")

Function to Split Dataset into Training and Validation Set

def get_dataset_partitions_tf(ds, train_split=0.8, val_split=0.2, shuffle=True, shuffle_size=10000):
    assert(train_split+val_split)==1


    ds_size=len(ds)


    if shuffle:
        ds=ds.shuffle(shuffle_size, seed=12)


    train_size=int(train_split*ds_size)
    val_size=int(val_split*ds_size)


    train_ds=ds.take(train_size)
    val_ds=ds.skip(train_size).take(val_size)


    return train_ds, val_ds
train_ds, val_ds =get_dataset_partitions_tf(dataset)

Data Augmentation

train_ds= train_ds.cache().shuffle(1000).prefetch(buffer_size=tf.data.AUTOTUNE)
val_ds= val_ds.cache().shuffle(1000).prefetch(buffer_size=tf.data.AUTOTUNE)
for image_batch, labels_batch in dataset.take(1):
    print(image_batch[0].numpy()/255)
pip install preprocessing
resize_and_rescale = tf.keras.Sequential([
    layers.Resizing(IMAGE_SIZE, IMAGE_SIZE),
    layers.Rescaling(1./255),
])
data_augmentation=tf.keras.Sequential([
    layers.RandomFlip("horizontal_and_vertical"),
    layers.RandomRotation(0.2),
])
n_classes=3

Our own Convolutional Neural Network (CNN) for Image Classification

input_shape=(BATCH_SIZE, IMAGE_SIZE,IMAGE_SIZE,CHANNELS)
n_classes=3


model_1= models.Sequential([
    resize_and_rescale,
    data_augmentation,
    layers.Conv2D(32, kernel_size=(3,3), activation='relu', input_shape=input_shape),
    layers.MaxPooling2D((2,2)),
    layers.Conv2D(64, kernel_size=(3,3), activation='relu'),
    layers.MaxPooling2D((2,2)),
    layers.Conv2D(64, kernel_size=(3,3), activation='relu'),
    layers.MaxPooling2D((2,2)),
    layers.Conv2D(64, (3,3), activation='relu'),
    layers.MaxPooling2D((2,2)),
    layers.Conv2D(64, (3,3), activation='relu'),
    layers.MaxPooling2D((2,2)),
    layers.Conv2D(128, (3,3), activation='relu'),
    layers.MaxPooling2D((2,2)),
    layers.Flatten(),
    layers.Dense(256,activation='relu'),
    layers.Dense(n_classes, activation='softmax'),
])
model_1.build(input_shape=input_shape)
model_1.summary()

model_1.compile(
    optimizer='adam',
    loss=tf.keras.losses.SparseCategoricalCrossentropy(from_logits=False),
    metrics=['accuracy']
)
history=model_1.fit(
    train_ds,
    batch_size=BATCH_SIZE,
    validation_data=val_ds,
    verbose=1,
    epochs=50
)
scores=model_1.evaluate(val_ds)

Training History Metrics Extraction

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


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

Training History Visualization

EPOCHS=50
plt.figure(figsize=(20,8))
plt.subplot(1,2,1)
plt.plot(range(EPOCHS), acc, label='Training Accuracy')
plt.plot(range(EPOCHS), val_acc, label='Validation Accuracy')
plt.legend(loc='lower right')
plt.title('Training and Validation Accuracy')


plt.subplot(1, 2, 2)
plt.plot(range(EPOCHS), loss, label='Training Loss')
plt.plot(range(EPOCHS), val_loss, label='Validation Loss')
plt.legend(loc='upper right')
plt.title('Training and Validation Loss')
plt.show()

Prediction of Image Labels from Validation Dataset

import numpy as np
for images_batch, labels_batch in val_ds.take(1):
  first_image=images_batch[0].numpy().astype("uint8")
  print("First image to predict")
  plt.imshow(first_image)
  print("Actual Label:",class_names[labels_batch[0].numpy()])


  batch_prediction = model_1.predict(images_batch)
  print("Predicted Label:",class_names[np.argmax(batch_prediction[0])])

def predict(model, img):
  img_array=tf.keras.preprocessing.image.img_to_array(images[i].numpy())
  img_array=tf.expand_dims(img_array,0) #create a batch


  predictions=model.predict(img_array)


  predicted_class=class_names[np.argmax(predictions[0])]
  confidence=round(100*(np.max(predictions[0])),2)
  return predicted_class, confidence
plt.figure(figsize=(15,15))
for images, labels in val_ds.take(1):
  for i in range(1):
    ax=plt.subplot(3,3,i+1)
    plt.imshow(images[i].numpy().astype("uint8"))
    predicted_class, confidence=predict(model_1, images[i].numpy())


    actual_class=class_names[labels[i]]
    plt.title(f"Actual: {actual_class}, \n Predicted: {predicted_class}. \n Confidence: {confidence}%")
    plt.axis("off")

plt.figure(figsize=(15,15))
for images, labels in val_ds.take(1):
  for i in range(9):
    ax=plt.subplot(3,3,i+1)
    plt.imshow(images[i].numpy().astype("uint8"))
    predicted_class, confidence=predict(model_1, images[i].numpy())


    actual_class=class_names[labels[i]]
    plt.title(f"Actual: {actual_class}, \n Predicted: {predicted_class}. \n Confidence: {confidence}%")
    plt.axis("off")

Saving the TensorFlow Model

from tensorflow.keras.models import save_model


# Save the TensorFlow model in .h5 format


# With this line
model_1.save('/kaggle/working/model_potato_50epochs_99%acc.keras')

Evaluating Model Predictions on Validation Dataset

# Initialize lists to store the results
y_true = []
y_pred = []


# Iterate over the validation dataset
for images, labels in val_ds:
    # Get the model's predictions
    predictions = model_1.predict(images)


    # Get the indices of the maximum values along an axis using argmax
    pred_labels = np.argmax(predictions, axis=1)


    # Extend the 'y_true' and 'y_pred' lists
    y_true.extend(labels.numpy())
    y_pred.extend(pred_labels)


# Convert lists to numpy arrays
y_true = np.array(y_true)
y_pred = np.array(y_pred)

Evaluation Metrics Calculation

from sklearn.metrics import accuracy_score, precision_score, recall_score, f1_score


# Calculate metrics
accuracy = accuracy_score(y_true, y_pred)
precision = precision_score(y_true, y_pred, average='weighted')
recall = recall_score(y_true, y_pred, average='weighted')
f1 = f1_score(y_true, y_pred, average='weighted')


print(f'Accuracy: {accuracy}')  # (accuracy = (TP+TN)/(TP+FP+TN+FN))
print(f'Precision: {precision}')  # (precision = TP/(TP+FP))
print(f'Recall: {recall}')  # (recall = TP/(TP+FN))
print(f'F1 Score: {f1}')  # (f1 score = 2/((1/Precision)+(1/Recall)))

Visualization of Confusion Matrix

import seaborn as sns
from sklearn.metrics import confusion_matrix
import matplotlib.pyplot as plt


# Assuming y_true and y_pred are defined
cm = confusion_matrix(y_true, y_pred)
plt.figure(figsize=(10, 10))
sns.heatmap(cm, annot=True, fmt='d', cmap='Blues')
plt.xlabel('Predicted labels')
plt.ylabel('True labels')
plt.title('Confusion Matrix')
plt.show()

ROC Curve

from sklearn.metrics import roc_curve, auc
from sklearn.preprocessing import LabelBinarizer
import matplotlib.pyplot as plt


# Binarize the output
lb = LabelBinarizer()
lb.fit(y_true)
y_test = lb.transform(y_true)
y_pred = lb.transform(y_pred)


n_classes = y_test.shape[1]


# Compute ROC curve and ROC area for each class
fpr = dict()
tpr = dict()
roc_auc = dict()
for i in range(n_classes):
    fpr[i], tpr[i], _ = roc_curve(y_test[:, i], y_pred[:, i])
    roc_auc[i] = auc(fpr[i], tpr[i])


# Plot all ROC curves
plt.figure()
for i in range(n_classes):
    plt.plot(fpr[i], tpr[i],
             label='ROC curve of class {0} (area = {1:0.2f})'
             ''.format(i, roc_auc[i]))


plt.plot([0, 1], [0, 1], 'k--')
plt.xlim([0.0, 1.0])
plt.ylim([0.0, 1.05])
plt.xlabel('False Positive Rate')
plt.ylabel('True Positive Rate')
plt.title('Receiver Operating Characteristic to Multi-Class')
plt.legend(loc="lower right")
plt.show()

AUC Score

from sklearn.metrics import roc_auc_score


# Assuming y_true and y_pred are defined
# 'ovo' stands for One-vs-One
# 'macro' calculates metrics for each label, and finds their unweighted mean
auc = roc_auc_score(y_true, y_pred, multi_class='ovo', average='macro')


print(f'AUC Score: {auc}')  # (AUC Score = Area Under the ROC Curve)

Saving the TensorFlow Model

from tensorflow.keras.models import save_model


# Save the TensorFlow model in .h5 format


# With this line
model_1.save('/kaggle/working/model_potato_50epochs_99%acc1.keras')

CNN Architecture Specification of the Base Research Paper

#Proposed Model in Research Paper
# activation units=64,128,256,512,512,4096,4096,1000
# kernel= 3,3
# max pooling =2,2
input_shape=(224,224,3)

Paper-Based CNN Model Architecture

from tensorflow.keras import Input


model_paper = models.Sequential([
    Input(shape=input_shape),
    resize_and_rescale,
    data_augmentation,
    # conv1
    layers.Conv2D(64, kernel_size=(3,3), activation='relu'),
    layers.MaxPooling2D((2,2)),


    #conv2
    layers.Conv2D(128, kernel_size=(3,3), activation='relu'),
    layers.MaxPooling2D((2,2)),


    #conv3
    layers.Conv2D(256, kernel_size=(3,3), activation='relu'),
    layers.MaxPooling2D((2,2)),


    #conv4
    layers.Conv2D(512, (3,3), activation='relu'),
    layers.MaxPooling2D((2,2)),


    #conv5
    layers.Conv2D(512, (3,3), activation='relu'),
    layers.MaxPooling2D((2,2)),


    layers.Flatten(),
    layers.Dense(4096, activation='relu'),
    layers.Dense(4096, activation='relu'),
    layers.Dense(1000, activation='relu'),
    layers.Dense(n_classes, activation='softmax'),
])
model_paper.summary()

Compilation of the Paper-Based CNN Model

model_paper.compile(
    optimizer='adam',
    loss=tf.keras.losses.SparseCategoricalCrossentropy(from_logits=False),
    metrics=['accuracy']
)

Training the Paper-Based CNN Model

history_paper=model_paper.fit(
    train_ds,
    batch_size=BATCH_SIZE,
    validation_data=val_ds,
    verbose=1,
    epochs=50
)
scores_paper=model_paper.evaluate(val_ds)
acc=history_paper.history['accuracy']
val_acc=history_paper.history['val_accuracy']


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

Visualization of Training and Validation Metrics of Base Paper Model

EPOCHS=50
plt.figure(figsize=(20,8))
plt.subplot(1,2,1)
plt.plot(range(EPOCHS), acc, label='Training Accuracy')
plt.plot(range(EPOCHS), val_acc, label='Validation Accuracy')
plt.legend(loc='lower right')
plt.title('Training and Validation Accuracy')


plt.subplot(1, 2, 2)
plt.plot(range(EPOCHS), loss, label='Training Loss')
plt.plot(range(EPOCHS), val_loss, label='Validation Loss')
plt.legend(loc='upper right')
plt.title('Training and Validation Loss')
plt.show()

Prediction of Image Label from Validation Dataset

import numpy as np
for images_batch, labels_batch in val_ds.take(1):
  first_image=images_batch[0].numpy().astype("uint8")
  print("First image to predict")
  plt.imshow(first_image)
  print("Actual Label:",class_names[labels_batch[0].numpy()])


  batch_prediction = model_paper.predict(images_batch)
  print("Predicted Label:",class_names[np.argmax(batch_prediction[0])])

def predict(model, img):
  img_array=tf.keras.preprocessing.image.img_to_array(images[i].numpy())
  img_array=tf.expand_dims(img_array,0) #create a batch


  predictions=model.predict(img_array)


  predicted_class=class_names[np.argmax(predictions[0])]
  confidence=round(100*(np.max(predictions[0])),2)
  return predicted_class, confidence
plt.figure(figsize=(15,15))
for images, labels in val_ds.take(1):
  for i in range(1):
    ax=plt.subplot(3,3,i+1)
    plt.imshow(images[i].numpy().astype("uint8"))
    predicted_class, confidence=predict(model_paper, images[i].numpy())


    actual_class=class_names[labels[i]]
    plt.title(f"Actual: {actual_class}, \n Predicted: {predicted_class}. \n Confidence: {confidence}%")
    plt.axis("off")

plt.figure(figsize=(15,15))
for images, labels in val_ds.take(1):
  for i in range(9):
    ax=plt.subplot(3,3,i+1)
    plt.imshow(images[i].numpy().astype("uint8"))
    predicted_class, confidence=predict(model_paper, images[i].numpy())


    actual_class=class_names[labels[i]]
    plt.title(f"Actual: {actual_class}, \n Predicted: {predicted_class}. \n Confidence: {confidence}%")
    plt.axis("off")

Saving the Tensorflow model of the base paper

from tensorflow.keras.models import save_model


# Save the TensorFlow model in .h5 format


# With this line
model_paper.save('/kaggle/working/model_potato_basepaper.keras')
# Initialize lists to store the results
y_true = []
y_pred = []


# Iterate over the validation dataset
for images, labels in val_ds:
    # Get the model's predictions
    predictions = model_paper.predict(images)


    # Get the indices of the maximum values along an axis using argmax
    pred_labels = np.argmax(predictions, axis=1)


    # Extend the 'y_true' and 'y_pred' lists
    y_true.extend(labels.numpy())
    y_pred.extend(pred_labels)


# Convert lists to numpy arrays
y_true = np.array(y_true)
y_pred = np.array(y_pred)

Calculating Classification Metrics

from sklearn.metrics import accuracy_score, precision_score, recall_score, f1_score


# Calculate metrics
accuracy = accuracy_score(y_true, y_pred)
precision = precision_score(y_true, y_pred, average='weighted')
recall = recall_score(y_true, y_pred, average='weighted')
f1 = f1_score(y_true, y_pred, average='weighted')


print(f'Accuracy: {accuracy}')
print(f'Precision: {precision}')
print(f'Recall: {recall}')
print(f'F1 Score: {f1}')

The provided code segment visualizes the confusion matrix using Seaborn's heatmap function

import seaborn as sns
from sklearn.metrics import confusion_matrix
import matplotlib.pyplot as plt


# Assuming y_true and y_pred are defined
cm = confusion_matrix(y_true, y_pred)
plt.figure(figsize=(10, 10))
sns.heatmap(cm, annot=True, fmt='d', cmap='Blues')
plt.xlabel('Predicted labels')
plt.ylabel('True labels')
plt.title('Confusion Matrix')
plt.show()

from sklearn.metrics import roc_curve, auc
from sklearn.preprocessing import LabelBinarizer
import matplotlib.pyplot as plt


# Binarize the output
lb = LabelBinarizer()
lb.fit(y_true)
y_test = lb.transform(y_true)
y_pred = lb.transform(y_pred)


n_classes = y_test.shape[1]


# Compute ROC curve and ROC area for each class
fpr = dict()
tpr = dict()
roc_auc = dict()
for i in range(n_classes):
    fpr[i], tpr[i], _ = roc_curve(y_test[:, i], y_pred[:, i])
    roc_auc[i] = auc(fpr[i], tpr[i])


# Plot all ROC curves
plt.figure()
for i in range(n_classes):
    plt.plot(fpr[i], tpr[i],
             label='ROC curve of class {0} (area = {1:0.2f})'
             ''.format(i, roc_auc[i]))


plt.plot([0, 1], [0, 1], 'k--')
plt.xlim([0.0, 1.0])
plt.ylim([0.0, 1.05])
plt.xlabel('False Positive Rate')
plt.ylabel('True Positive Rate')
plt.title('Receiver Operating Characteristic to Multi-Class')
plt.legend(loc="lower right")
plt.show()

from sklearn.metrics import roc_auc_score


# Assuming y_true and y_pred are defined
# 'ovo' stands for One-vs-One
# 'macro' calculates metrics for each label, and finds their unweighted mean
auc = roc_auc_score(y_true, y_pred, multi_class='ovo', average='macro')


print(f'AUC Score: {auc}')  # (AUC Score = Area Under the ROC Curve)

Using Explainable AI to explain the predictions of our own CNN model,Taking an image and predicting it's class using our own CNN Model

import numpy as np
import matplotlib.pyplot as plt


for images_batch, labels_batch in val_ds.take(1):
  first_image = images_batch[0].numpy().astype("uint8")
  print("First image to predict")
  plt.imshow(first_image)
  print("Actual Label:", class_names[labels_batch[0].numpy()])


  batch_prediction = model_1.predict(images_batch)
  top_3_pred_indices = np.argsort(batch_prediction[0])[-3:][::-1]
  top_3_pred_labels = [class_names[index] for index in top_3_pred_indices]
  top_3_pred_values = [batch_prediction[0][index] for index in top_3_pred_indices]
  top_3_pred_percentages = [value * 100 for value in top_3_pred_values]
  print("Top 3 Predicted Labels:", top_3_pred_labels)
  print("Top 3 Predicted Probabilities (%):", top_3_pred_percentages)


  # Plotting the top 3 predictions
  plt.figure(figsize=(6, 3))
  plt.bar(top_3_pred_labels, top_3_pred_percentages)
  plt.title('Top 3 Predictions')
  plt.xlabel('Classes')
  plt.ylabel('Prediction Probabilities (%)')
  plt.show()

Model Explainability with LIME (Local Interpretable Model-Agnostic Explanations)

pip install lime

Setting up Lime for Image Explanation

%load_ext autoreload
%autoreload 2
import os,sys
try:
    import lime
except:
    sys.path.append(os.path.join('..', '..')) # add the current directory
    import lime
from lime import lime_image
explainer = lime_image.LimeImageExplainer()
%%time
# Hide color is the color for a superpixel turned OFF. Alternatively, if it is NONE, the superpixel will be replaced by the average of its pixels
explanation = explainer.explain_instance(images_batch[0].numpy().astype('double'), model_1.predict, top_labels=3, hide_color=0, num_samples=1000)
from skimage.segmentation import mark_boundaries

Superpixel for the top most Prediction

#here hide_rest is True
temp, mask = explanation.get_image_and_mask(explanation.top_labels[0], positive_only=True, num_features=3, hide_rest=True)
plt.imshow(mark_boundaries(temp / 2 + 0.5, mask))

#here hide_rest is False
temp, mask = explanation.get_image_and_mask(explanation.top_labels[0], positive_only=True, num_features=10, hide_rest=False)
plt.imshow(mark_boundaries(temp / 2 + 0.5, mask))

Visualizing 'pros and cons'

temp, mask = explanation.get_image_and_mask(explanation.top_labels[0], positive_only=False, num_features=10, hide_rest=False)
plt.imshow(mark_boundaries(temp / 2 + 0.5, mask))

temp, mask = explanation.get_image_and_mask(explanation.top_labels[0], positive_only=False, num_features=1000, hide_rest=False, min_weight=0.1)
plt.imshow(mark_boundaries(temp / 2 + 0.5, mask))

Explaination Heatmap plot with weights

#Select the same class explained on the figures above.
ind =  explanation.top_labels[0]


#Map each explanation weight to the corresponding superpixel
dict_heatmap = dict(explanation.local_exp[ind])
heatmap = np.vectorize(dict_heatmap.get)(explanation.segments)


#Plot. The visualization makes more sense if a symmetrical colorbar is used.
plt.imshow(heatmap, cmap = 'RdBu', vmin  = -heatmap.max(), vmax = heatmap.max())
plt.colorbar()

Second Prediction in the List

temp, mask = explanation.get_image_and_mask(explanation.top_labels[1], positive_only=True, num_features=5, hide_rest=True)
plt.imshow(mark_boundaries(temp / 2 + 0.5, mask))

Rest of the image from the second prediction i.e. top_labels[1]

temp, mask = explanation.get_image_and_mask(explanation.top_labels[1], positive_only=True, num_features=5, hide_rest=False)
plt.imshow(mark_boundaries(temp / 2 + 0.5, mask))

Visualizing 'pros and cons'

temp, mask = explanation.get_image_and_mask(explanation.top_labels[1], positive_only=False, num_features=10, hide_rest=False)
plt.imshow(mark_boundaries(temp / 2 + 0.5, mask))

temp, mask = explanation.get_image_and_mask(explanation.top_labels[1], positive_only=False, num_features=1000, hide_rest=False, min_weight=0.1)
plt.imshow(mark_boundaries(temp / 2 + 0.5, mask))

#Select the same class explained on the figures above.
ind =  explanation.top_labels[1]


#Map each explanation weight to the corresponding superpixel
dict_heatmap = dict(explanation.local_exp[ind])
heatmap = np.vectorize(dict_heatmap.get)(explanation.segments)


#Plot. The visualization makes more sense if a symmetrical colorbar is used.
plt.imshow(heatmap, cmap = 'RdBu', vmin  = -heatmap.max(), vmax = heatmap.max())
plt.colorbar()

from lime import lime_image
explainer = lime_image.LimeImageExplainer()
explanation = explainer.explain_instance(images_batch[0].numpy().astype('double'), model_1.predict,top_labels=3, hide_color=0, num_samples=1000)
from skimage.segmentation import mark_boundaries


temp_1, mask_1 = explanation.get_image_and_mask(explanation.top_labels[0], positive_only=True, num_features=5, hide_rest=True)
temp_2, mask_2 = explanation.get_image_and_mask(explanation.top_labels[0], positive_only=False, num_features=10, hide_rest=False)


fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(15,15))
ax1.imshow(mark_boundaries(temp_1, mask_1))
ax2.imshow(mark_boundaries(temp_2, mask_2))
ax1.axis('off')
ax2.axis('off')


plt.savefig('mask_default.png')

工学博士,担任《Mechanical System and Signal Processing》《中国电机工程学报》《控制与决策》等期刊审稿专家,擅长领域:现代信号处理,机器学习,深度学习,数字孪生,时间序列分析,设备缺陷检测、设备异常检测、设备智能故障诊断与健康管理PHM等。

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

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

相关文章

Modbus TCP转CanOpen网关携手FANUC机器人助力新能源汽车

Modbus TCP转CanOpen网关与FANUC机器手臂的现场应用可以实现FANUC机器手臂与其他设备之间的数据交换和通信。CANopen是一种常见的网络协议,用于处理机器和设备之间的通信,并广泛应用于自动化领域。而Modbus TCP是一种基于TCP/IP协议的通信协议&#xff0…

【C++关键字】auto的使用(C++11)

auto的使用(C11) auto关键字auto的使用细则auto使用场景 随着程序的复杂化,程序中用到的类型也越来越复杂化,经常体现在: 1.类型难以拼写 2.含义不明确导致容易出错 在C语言阶段处理这类问题的方法,可以使…

GDPU Java 天码行空15 数据库编程

一、实验目的 1、 了解数据库的基础知识。 2、 掌握MySQL的下载、安装与配置。 3、 掌握MySQL可视化工具的使用。 4、 了解SQL语言。 5、 掌握JDBC中的API,并能进行简单的数据库操作。 二、实验内容 1、 安装MySQL 👨‍🏫 视频教程 2、建…

计算机组成刷题一轮(包过版)

搭配食用 计算机组成原理一轮-CSDN博客 目录 一、计算机系统概述 选择 计算机系统组成 冯诺依曼机 软件和硬件的功能 CPU等概念 计算机系统的工作原理 机器字长 运行速度 求MIPS 编译程序 机器语言程序 平均CPI和CPU执行时间 综合应用 存储程序原理 二…

线性预测器的等价性

摘要 尽管线性模型很简单,但它在时间序列预测中表现良好,即使是在与更深入、更昂贵的模型竞争时也是如此。已经提出了许多线性模型的变体,通常包括某种形式的特征归一化,以提高模型的泛化。本文分析了用这些线性模型体系结构可表…

学生宿舍人走断电系统的开发

学生宿舍人走断电管理系统是一款智能化的电力管理设备,旨在解决学生宿舍用电问题。以下是一些该系统的功能特点: 1.智能控制:系统能够自动识别宿舍内是否有人,当无人时自动断电,避免能源浪费和事故的发生。 2.:系统具有过载保护、短路保护、过…

基于51单片机的串口乒乓球小游戏

基于51单片机的乒乓球小游戏 (仿真+程序) 功能介绍 具体功能: 1.用两块单片机串口进行通信; 2.一排LED模拟乒乓球运动(哪里亮表示运动到哪); 3.当最左边LED亮,表示球…

C 语言实现Linux终端显示IP二维码

调试信息:开发者可以在终端生成二维码,包含调试信息或日志数据,便于移动设备扫描和查看。设备配置:物联网设备配置时,通过终端生成配置二维码,扫描后进行设备配置。 Ubuntu/Debian 环境安装二维码库 sudo a…

以无厚,入有间,做一件事为什么靠努力不行,不能长期维持

庖丁解牛,并不是在说人和技巧,而是在说解牛不在于刀的锋利,而是怎样才能做到让刀不产生损耗,就是熟悉牛肉纹路,按照纹路和肉骨间隙进行操刀。这就是尊重自然规律,对于人也是一样的,如果所有事情…

C# .NET 异步实现方式

一、异步编程模式 .NET 提供了执行异步操作的三种模式: 基于任务的异步模式 (TAP) ,该模式使用单一方法表示异步操作的开始和完成。 TAP 是在 .NET Framework 4 中引入的。 这是在 .NET 中进行异步编程的推荐方法。 C# 中的 async 和 await 关键词以及 …

Day47 代码随想录打卡|二叉树篇---最大二叉树

题目(leecode T654): 给定一个不重复的整数数组 nums 。 最大二叉树 可以用下面的算法从 nums 递归地构建: 创建一个根节点,其值为 nums 中的最大值。递归地在最大值 左边 的 子数组前缀上 构建左子树。递归地在最大值 右边 的 …

linux常用命令及其选项

1、常用命令 1.1、ls 选项说明-a显示所有文件及目录 (包括隐藏文件)-i显示inode-A同 -a选项 ,但不列出 "." (目前目录) 及 ".." (父目录)-l列出信息详细(如文件型态、权限、拥有者、文件大小等)-R递归显示(若目录下有文件,则以下之…

盘点 2024 Google I/O 中的 Android 方向关键更新

这里写自定义目录标题 前言1. AI 编程助手2. 生成式AI 应用3. 不同屏幕尺寸适配4. 桌面小部件(Widget)5. 跨设备类型开发6. WearOS & 可穿戴7. Android for Car8. Android TV9. Google Home API10. Kotlin Multiplatform11. Jetpack Compose12. Andr…

C# Excel操作类EPPlus

摘要 EPPlus 是一个流行的用于操作 Excel 文件的开源库,适用于 C# 和 .NET 环境。它提供了丰富的功能,能够轻松地读取、写入和格式化 Excel 文件,使得在 C# 中进行 Excel 文件处理变得更加简单和高效。EPPlus 不需要安装 Microsoft Office 或…

【机器学习基础】Python编程10:五个实用练习题的解析与总结

Python是一种广泛使用的高级编程语言,它在机器学习领域中的重要性主要体现在以下几个方面: 简洁易学:Python语法简洁清晰,易于学习,使得初学者能够快速上手机器学习项目。 丰富的库支持:Python拥有大量的机…

ChatTTS 开源文本转语音模型本地部署、API使用和搭建WebUI界面(建议收藏)

ChatTTS(Chat Text To Speech)是专为对话场景设计的文本生成语音(TTS)模型,特别适用于大型语言模型(LLM)助手的对话任务,以及诸如对话式音频和视频介绍等应用。它支持中文和英文,还可以穿插笑声、说话间的停顿、以及语…

不确定性+电动汽车!含高比例新能源和多类型电动汽车的配电网能量管理程序代码!

前言 能源供应的可持续性和清洁性是当今世界共同关注的议题,配电网与可再生能源发电相结合,通过多能互补和梯级利用,在不同时空取长补短,提高能源利用率,减少温室气体排放,是解决能源短缺和环境问题的有效…

MicroPython esp32 连接wifi 配网

整体流程: 1)开启STA 和 AP 模式 2)扫描周围wifi 保存在 变量 wifi_list(后面要用到) 3) 尝试STA模式连接Wifi,并查寻状态。 4) 如果STA 无法连网,就用AP模式,创建热点。 5&a…

汇编:宏的使用

汇编语言中的宏是用于定义可重复使用的代码块或指令集合的强大工具。宏通过简化代码编写和提高可读性,使得编写和维护汇编程序更加方便;在 MASM(Microsoft Macro Assembler)中,宏的定义和使用非常常见。以下是对汇编语…

【GD32F303红枫派使用手册】第十一节 ADC-电源电压单通道ADC检测实验

11.1 实验内容 通过本实验主要学习以下内容: ADC的简介 GD32F303 ADC工作原理 查询方式实现ADC单通道采样 11.2 实验原理 11.2.1 ADC原理 我们知道,自然界中有非常多的模拟信号,比如上一节提到的光照强度,还有其他的例如温…