# 《机器学习实战：基于Scikit-Learn、Keras和TensorFlow第2版》-学习笔记（3）

· Hands-On Machine Learning with Scikit-Learn, Keras, and TensorFlow, 2nd Edition, by Aurélien Géron (O’Reilly). Copyright 2019 Aurélien Géron, 978-1-492-03264-9.

· 环境：Anaconda（Python 3.8） + Pycharm
· 学习时间：2022.04.01~2022.04.02

[En]

[En]

This chapter will try to do a classification task. The contents are roughly as follows:

## 3.1 MNIST

Scikit-Learn提供了许多助手功能来帮助你下载流行的数据集。MNIST也是其中之一。下面是获取MNIST数据集的代码：


from sklearn.datasets import fetch_openml
mnist = fetch_openml('mnist_784', version=1, as_frame=False)

print(mnist.keys())



Scikit-Learn加载的数据集通常具有类似的字典结构，包括：

• DESCR键: 描述数据集;
• data键: 包含一个数组，每个实例为一行，每个特征为一列;
• target键: 包含一个带有标记的数组.

X, y = mnist["data"], mnist["target"]
print(X.shape)
print(y.shape)



import matplotlib.pyplot as plt
some_digit = X[1]
some_digit_image = some_digit.reshape(28, 28)
plt.imshow(some_digit_image, cmap="binary")
plt.axis("off")
plt.show()
print(y[1])

import numpy as np
y = y.astype(np.uint8)


[En]

Before you start delving into the data, you should still create a test set and put it aside.

X_train, y_train = X[:60000], y[:60000]
X_test, y_test = X[60000:], y[60000:]


[En]

Finally, we mix and wash the training set data.

• 这确保了交叉验证期间所有折叠都是相同的(您当然不希望某个折叠丢失一些数字)
[En]

this ensures that all folds are the same during cross-validation (you certainly don’t want a fold to lose some numbers)*

• 此外，一些机器学习算法对训练实例的顺序敏感，如果连续输入许多相似的实例，可能会导致性能较差。调整数据集只是为了确保这种情况不会发生。
[En]

in addition, some machine learning algorithms are sensitive to the order of training instances, which may lead to poor performance if many similar instances are entered continuously. Shuffling the dataset is just to make sure this doesn’t happen.*

## 3.2 训练二元分类器

[En]

As a beginner, simplify the problem and try to identify only one number, such as the number 5.

y_train_5 = (y_train == 5)
y_test_5 = (y_test == 5)



from sklearn.linear_model import SGDClassifier
sgd_clf = SGDClassifier(random_state=42)

sgd_clf.fit(X_train, y_train_5)


print(sgd_clf.predict([some_digit]))


## 3.3 性能测量

[En]

Evaluating classifiers is much more difficult than evaluating regression machines, so this chapter will devote a lot of space to this topic and involve many performance assessment methods.

[En]

In this case, you can implement cross-validation on your own, and the operation is simple and straightforward.

from sklearn.model_selection import StratifiedKFold
from sklearn.base import clone

skfolds = StratifiedKFold(n_splits=3, shuffle=True, random_state=42)

for train_index, test_index in skfolds.split(X_train, y_train_5):

clone_clf = clone(sgd_clf)
X_train_folds = X_train[train_index]
y_train_folds = y_train_5[train_index]
X_test_fold = X_train[test_index]
y_test_fold = y_train_5[test_index]
clone_clf.fit(X_train_folds, y_train_folds)
y_pred = clone_clf.predict(X_test_fold)
n_correct = sum(y_pred == y_test_fold)
print(n_correct / len(y_pred))


from sklearn.model_selection import cross_val_score
cross_val_score_result = cross_val_score(sgd_clf, X_train, y_train_5, cv=3, scoring="accuracy")
print(cross_val_score_result)


[En]

The accuracy of all folding cross-validation (the rate of correct prediction) is more than 93%? It looks amazing, doesn’t it?

from sklearn.base import BaseEstimator

class Never5Classifier(BaseEstimator):
def fit(self, X, y=None):
return self

def predict(self, X):
return np.zeros((len(X), 1), dtype=bool)


[En]

Can you guess the accuracy of this model? Let’s see:

never_5_clf = Never5Classifier()
cross_val_score_result = cross_val_score(never_5_clf, X_train, y_train_5, cv=3, scoring="accuracy")
print(cross_val_score_result)


[En]

The rows in the confusion matrix represent the actual categories and the columns represent the forecast categories.

[En]

To calculate the confusion matrix, you need to have a set of predictions before you can compare it with the actual target. Of course, you can predict through the test set, but don’t touch it for now.

（测试集最好留到项目的最后，准备启动分类器时再使用）。作为替代，可以使用cross_val_predict（）函数：

from sklearn.model_selection import cross_val_predict
y_train_pred = cross_val_predict(sgd_clf, X_train, y_train_5, cv=3)


from sklearn.metrics import confusion_matrix
SGD_confusion_matrix = confusion_matrix(y_train_5, y_train_pred)
print(SGD_confusion_matrix)



[En]

A perfect classifier has only real classes and true negative classes, so its confusion matrix will only have a non-zero value on its diagonal (upper left to lower right):

y_train_perfect_predictions = y_train_5
print(confusion_matrix(y_train_5, y_train_perfect_predictions))



[En]

Confusion matrices can provide a lot of information, but sometimes you may want the metrics to be more concise.

[En]

Therefore, accuracy is usually used in conjunction with another indicator, which is the recall rate, also known as sensitivity or true class rate:

Scikit-Learn提供了计算多种分类器指标的函数，包括精度和召回率：

from sklearn.metrics import precision_score, recall_score
print(precision_score(y_train_5, y_train_pred))
print(recall_score(y_train_5, y_train_pred))


F1分数是精度和召回率的谐波平均值

F 1 − s c o r e = 2 1 精 度 + 1 召 回 率 = 2 ∗ 精 度 ∗ 召 回 率 精 度 + 召 回 率 = T P T P + F N + F P 2 F1-score = \frac{2}{\frac{1}{精度} + \frac{1}{召回率}} = 2 * \frac{精度*召回率}{精度+召回率} = \frac{TP}{TP + \frac{FN+FP}{2}}F 1 −s c o r e =精度1 ​+召回率1 ​2 ​=2 ∗精度+召回率精度∗召回率​=T P +2 F N +F P ​T P ​

from sklearn.metrics import f1_score
print(f1_score(y_train_5, y_train_pred))


F1分数对那些具有相近的精度和召回率的分类器更为有利。这不一定能一直符合你的期望：

[En]

In some cases, you are more concerned with accuracy, while in others, you may really care about the recall rate.

[En]

But the remaining videos are safe (high-precision) classifiers, not high recall rates, but there may be some very bad video classifiers in the product (in this case

[En]

You may even add a manual pipeline to check the videos selected by the classifier. On the other hand, if you train a classifier to detect thieves through image surveillance:

[En]

Unfortunately, you can’t have both. You can’t increase precision and reduce recall at the same time, and vice versa. This is called a precision / recall trade-off.

Scikit-Learn不允许直接设置阈值，但是可以访问它用于预测的决策分数。不是调用分类器的predic()方法，而是调用decision_function()方法，


y_scores = sgd_clf.decision_function([some_digit])
print(y_scores)
threshold = 0
y_some_digit_pred1 = (y_scores > threshold)
threshold = 8000
y_some_digit_pred2 = (y_scores > threshold)
print(y_some_digit_pred1, '\n', y_some_digit_pred2)


[En]

This proves that raising the threshold can indeed reduce the recall rate.


y_scores = cross_val_predict(sgd_clf, X_train, y_train_5, cv=3, method="decision_function")
from sklearn.metrics import precision_recall_curve
precisions, recalls, thresholds = precision_recall_curve(y_train_5, y_scores)




import matplotlib as mpl

def plot_precision_recall_vs_threshold(precisions, recalls, thresholds):
plt.style.use('seaborn')
mpl.rcParams["font.sans-serif"] = ["SimHei"]
mpl.rcParams["axes.unicode_minus"] = False
plt.plot(thresholds, precisions[:-1], "b--", label="Precision")
plt.plot(thresholds, recalls[:-1], "g-", label="Recall")
plt.xlabel('阈值', fontsize=20)
plt.legend(fontsize=18)

plot_precision_recall_vs_threshold(precisions, recalls, thresholds)
plt.show()


[En]

You may wonder why the precision curve is more rugged than the recall curve in figure 3-4. The reason is that when you raise the threshold, accuracy may sometimes decline (although the overall trend is upward).


from sklearn.metrics import PrecisionRecallDisplay
pr_display = PrecisionRecallDisplay(precision=precisions, recall=recalls).plot()
plt.show()


（np.argmax()会给你最大值的第一个索引，在这种情况下，它表示第一个True值）：

threshold_90_precision = thresholds[np.argmax(precisions >= 0.90)]
print(threshold_90_precision)


y_train_pred_90 = (y_scores >= threshold_90_precision)
print(y_train_pred_90)


[En]

Check the accuracy and recall rate of these predictions:

y_train_pred_90_p_score = precision_score(y_train_5, y_train_pred_90)
y_train_pred_90_r_score = recall_score(y_train_5, y_train_pred_90)
print('精度：', y_train_pred_90_p_score, '\n', '召回率：', y_train_pred_90_r_score)


[En]

As long as the threshold is high enough! However, if the recall rate is too low, no matter how high the precision is, it is not very useful!

ROC与精度/召回率曲线非常相似，但绘制的不是精度和召回率，而是真正类率（召回率的另一名称）和假正类率（FPR）。
FPR是被错误分为正类的负类实例比率。它等于1减去真负类率（TNR），后者是被正确分类为负类的负类实例比率，也称为特异度。


from sklearn.metrics import roc_curve
fpr, tpr, thresholds = roc_curve(y_train_5, y_scores)

def plot_roc_curve(fpr, tpr, label=None):
plt.style.use('seaborn')
mpl.rcParams["font.sans-serif"] = ["SimHei"]
mpl.rcParams["axes.unicode_minus"] = False
plt.plot(fpr, tpr, linewidth=2, label=label)
plt.plot([0, 1], [0, 1], 'k--')
plt.xlabel('假正率', fontsize=18)
plt.ylabel('真正率（召回率）', fontsize=18)

plot_roc_curve(fpr, tpr)
plt.show()


Scikit-Learn提供计算ROC AUC的函数：

from sklearn.metrics import roc_auc_score
roc_auc_score_forSGD = roc_auc_score(y_train_5, y_scores)
print(roc_auc_score_forSGD)


[En]

First, get the score of each instance in the training set.

Scikit-Learn的分类器通常都会有这两种方法中的一种（或两种都有）。

dict_proba()方法会返回一个数组，其中每行代表一个实例，每列代表一个类别，意思是某个给定实例属于某个给定类别的概率
（例如，这张图片有70%的可能是数字5）


from sklearn.ensemble import RandomForestClassifier
forest_clf = RandomForestClassifier(random_state=42)
y_probas_forest = cross_val_predict(forest_clf, X_train, y_train_5, cv=3, method="predict_proba")

y_scores_forest = y_probas_forest[:, 1]
fpr_forest, tpr_forest, thresholds_forest = roc_curve(y_train_5, y_scores_forest)

plt.plot(fpr, tpr, "b:", label="SGD")
plot_roc_curve(fpr_forest, tpr_forest, "Random Forest")
plt.legend(loc="lower right")
print('\n\ntest')
plt.show()

RandomForest_roc_auc_score = roc_auc_score(y_train_5, y_scores_forest)
print(RandomForest_roc_auc_score)


RandomForestClassifier的ROC曲线看起来比SGDClassifier好很多，它离左上角更接近，因此它的ROC AUC分数也高得多。

[En]

I hope now you have mastered how to train the binary classifier and how to select the appropriate index to evaluate the classifier by cross-validation.

## 3.4 多类分类器

[En]

Binary classifiers are distinguished between two classes, while multi-class classifiers (also known as multinomial classifiers) can distinguish more than two classes.

[En]

Some algorithms, such as random forest classifier or naive Bayesian classifier, can deal with multiple classes directly. There are also some strict binary classifiers (such as support vector machine classifier or linear classifier).

[En]

However, there are several strategies that allow you to achieve the purpose of multi-class classification with several binary classifiers:

• 要创建一个将数字图像划分为10个类别(从0到9)的系统，一种方法是训练10个二进制分类器，每个数字一个分类器(0-检测器、1-检测器、2-检测器等等)。
[En]

to create a system to divide digital pictures into 10 categories (from 0 to 9), one way is to train 10 binary classifiers, one for each number (0-detector, 1-detector, 2-detector, and so on).

然后，当你需要对一幅图像进行检测和分类时，得到每个分类器的决策分数，哪个分类器给出最高的分数就会被划分到哪个类别。

[En]

Then, when you need to detect and classify an image, get the decision score of each classifier, and which classifier gives the highest score will be divided into which category.

这称为 一对剩余（OvR）策略，也称为 一对多（one-versus-all）*。

• 另一种方法是为每对数字训练一个二进制分类器：一个区分0和1，一个区分0和2，一个区分1和2，以此类推。
[En]

another method is to train a binary classifier for each pair of numbers: one to distinguish between 0 and 1, one to distinguish between 0 and 2, one to distinguish between 1 and 2, and so on.

这称为一对一（OvO）策略。如果存在N个类别，那么这需要训练N×（N-1）/2个分类器。对于MNIST问题，这意味着要训练45个二元分类器！
当你需要对一张图片进行分类时，你需要运行45个分类器来对图片进行分类，看看哪一类赢得最多。

[En]

When you need to classify an image, you need to run 45 classifiers to classify the picture and see which category wins the most.*

OvO的主要优点在于，每个分类器只需要用到部分训练集对其必须区分的两个类进行训练。有些算法（例如支持向量机分类器）在数据规模扩大时表现糟糕。
对于这类算法，OvO是一个优先的选择，因为在较小训练集上分别训练多个分类器比在大型数据集上训练少数分类器要快得多。
但是对大多数二元分类器来说，OvR策略还是更好的选择。

Scikit-Learn可以检测到你尝试使用二元分类算法进行多类分类任务，它会根据情况自动运行OvR或者OvO。我们用sklearn.svm.SVC类来试试SVM分类器：

one_digit = X[0]
from sklearn.svm import SVC
svm_clf = SVC()
svm_clf.fit(X_train, y_train)
one_digit_pre = svm_clf.predict([one_digit])
print(one_digit_pre)


one_digit_scores = svm_clf.decision_function([one_digit])
print(one_digit_scores)
one_digit_scores_max = np.argmax(one_digit_scores)
print(one_digit_scores_max)


print(svm_clf.classes_)
print(svm_clf.classes_[5])


[En]

You just need to create an instance and pass the classifier to its constructor (it doesn’t even have to be a binary classifier).

from sklearn.multiclass import OneVsRestClassifier
ovr_clf = OneVsRestClassifier(SVC())
ovr_clf.fit(X_train, y_train)
ovr_one_digit_pre = ovr_clf.predict([one_digit])
print(ovr_one_digit_pre)
print(len(ovr_clf.estimators_))



from sklearn.linear_model import SGDClassifier
sgd_clf = SGDClassifier(random_state=42)
sgd_clf.fit(X_train, y_train)
sgd_clf.predict([one_digit])
sgd_clf.decision_function([one_digit])

sgd_clf.decision_function([one_digit])

from sklearn.model_selection import cross_val_score
cross_val_score(sgd_clf, X_train, y_train, cv=3, scoring="accuracy")


[En]

It is more than 84% on all test folds. If it is a pure random classifier, the accuracy is about 10%, so the result is not too bad, but there is still room for improvement.

[En]

For example, simply scaling the input (as described in Chapter 2) can increase the accuracy to more than 89%:

from sklearn.preprocessing import StandardScaler
scaler = StandardScaler()
X_train_scaled = scaler.fit_transform(X_train.astype(np.float64))
cross_val_score(sgd_clf, X_train_scaled, y_train, cv=3, scoring="accuracy")


## 3.5 误差分析

[En]

Here, suppose you have found a potential model, and now you want to find some ways to further improve it. One way to do this is to analyze its error type.

from sklearn.model_selection import cross_val_predict
from sklearn.metrics import confusion_matrix
y_train_pred = cross_val_predict(sgd_clf, X_train_scaled, y_train, cv=3)
conf_mx = confusion_matrix(y_train, y_train_pred)
print(conf_mx)
plt.matshow(conf_mx, cmap=plt.cm.gray)
plt.show()


[En]

The confusion matrix looks good because most of the images are on the main diagonal, which means they are correctly classified.

[En]

Let’s focus on mistakes.

[En]

First, you need to divide each value in the confusion matrix by the number of pictures in the corresponding class, so that you compare the error rate rather than the wrong absolute value (the latter is unfair to classes with a larger number of images):

[En]

Now you can clearly see the types of errors generated by the classifier. Remember, each row represents the actual class, and each column represents the prediction class.

[En]

Note that errors are not completely symmetrical; for example, the numbers 3 and 5 are often confused (in both directions).

[En]

Alternatively, you can develop new features to improve the classifier-for example, write an algorithm to calculate the number of closed loops (for example, the number 8 has two, the number 6 has one, and the number 5 does not).

[En]

Analyzing individual errors can also provide insight into the classifier: what is it doing? Why did it fail? But this is usually more difficult and time-consuming.


def plot_digits(instances, images_per_row=10, **options):
size = 28
images_per_row = min(len(instances), images_per_row)
images = [instance.reshape(size,size) for instance in instances]
n_rows = (len(instances) - 1) // images_per_row + 1
row_images = []
n_empty = n_rows * images_per_row - len(instances)
images.append(np.zeros((size, size * n_empty)))
for row in range(n_rows):
rimages = images[row * images_per_row : (row + 1) * images_per_row]
row_images.append(np.concatenate(rimages, axis=1))
image = np.concatenate(row_images, axis=0)
plt.imshow(image, cmap=mpl.cm.binary, **options)
plt.axis('off')

cl_a, cl_b = 3, 5
X_aa = X_train[(y_train == cl_a) & (y_train_pred == cl_a)]
X_ab = X_train[(y_train == cl_a) & (y_train_pred == cl_b)]
X_ba = X_train[(y_train == cl_b) & (y_train_pred == cl_a)]
X_bb = X_train[(y_train == cl_b) & (y_train_pred == cl_b)]
plt.figure(figsize=(8, 8))
plt.subplot(221)
plot_digits(X_aa[:25], images_per_row=5)
plt.subplot(222)
plot_digits(X_ab[:25], images_per_row=5)
plt.subplot(223)
plot_digits(X_ba[:25], images_per_row=5)
plt.subplot(224)
plot_digits(X_bb[:25], images_per_row=5)
plt.show()


[En]

Some of the numbers mistaken by the classifier (that is, the matrix at the bottom left and upper right) are so poorly written that it is difficult for even humans to distinguish (for example, the number 5 in the first line really looks like the number 3).

[En]

However, for us, most of the misclassified images still seem to be very obviously wrong, and it is difficult for us to understand why the classifier is wrong.

[En]

What it does is assign each pixel a weight of each category, and when it sees a new image, it summarizes the intensity of the weighted pixels and gets a score for classification.

## 3.6 多标签分类

[En]

So far, each instance has been divided into only one class. In some cases, you want the classifier to output multiple classes for each instance.

（意思是”是爱丽丝，不是鲍勃，是查理”）这种输出多个二元标签的分类系统称为多标签分类系统。

[En]

Let’s look at a simpler example:


from sklearn.neighbors import KNeighborsClassifier
y_train_large = (y_train >= 7)
y_train_odd = (y_train % 2 == 1)
y_multilabel = np.c_[y_train_large, y_train_odd]
knn_clf = KNeighborsClassifier()
knn_clf.fit(X_train, y_multilabel)
print(knn_clf.predict([one_digit]))


[En]

There are many ways to evaluate multi-label classifiers, and how to choose the right metrics depends on your project.


from sklearn.metrics import f1_score
y_train_knn_pred = cross_val_predict(knn_clf, X_train, y_multilabel, cv=3)
knn_f1_score = f1_score(y_multilabel, y_train_knn_pred, average="macro")
print(knn_f1_score)


[En]

It is assumed that all tags are equally important, but this may not be the case. In particular, if there are a lot more Alice in the training photos than Bob and Charlie, you may want to give more weight to the classifier that distinguishes Alice.

[En]

A simple way is to give each tag a weight equal to its own support (that is, the number of instances with the target tag).

## 3.7 多输出分类

[En]

The last classification task we will discuss is called multi-output-multi-class classification (or simply called multi-output classification).

[En]

To put it simply, it is a generalization of multi-tag classification, and its tags can also be multi-class (for example, it can have more than two possible values).

[En]

It is rendered as an array of pixel intensity. Note that the output of this classifier is multiple tags (one tag per pixel), and each tag can have multiple values (pixel intensity range from 0 to 225).

[En]

So this is an example of a multi-output classifier system.

[En]

The multi-output system is not limited to classification tasks, but allows a system to output multiple tags to each instance, including class tags and value tags.

noise = np.random.randint(0, 100, (len(X_train), 784))
X_train_mod = X_train + noise
noise = np.random.randint(0, 100, (len(X_test), 784))
X_test_mod = X_test + noise
y_train_mod = X_train
y_test_mod = X_test

knn_clf.fit(X_train_mod, y_train_mod)
some_index = 0
clean_digit = knn_clf.predict([X_test_mod[some_index]])

def plot_digit(data):
image = data.reshape(28, 28)
plt.imshow(image, cmap=mpl.cm.binary, interpolation="nearest")
plt.axis("off")

plot_digit(clean_digit)
plt.show()


[En]

Looks close enough to the target. This is the end of the classifier journey. Hopefully now you know how to select good indicators for classification tasks, how to choose appropriate accuracy / recall trade-offs, how to compare multiple classifiers, and, more generally, how to build excellent classification systems for various tasks.

## 3.8 练习题

1.为MNIST数据集构建一个分类器，并在测试集上达成超过97%的准确率。

2.写一个可以将MNIST图片向任意方向（上、下、左、右）移动一个像素的功能。然后对训练集中的每张图片，创建四个位移后的副本（每个方向一个），

[En]

Add to the training set. Finally, the model is trained on the extended training set and its accuracy in the test set is measured. You should notice that the performance of the model is even better!

[En]

This technique of manually extending the training set is called data augmentation or training set expansion.

3.Kaggle上非常棒的起点：处理泰坦尼克（Titanic）数据集。

4.创建一个垃圾邮件分类器（更具挑战性的练习）：

• 从Apache SpamAssassin的公共数据集中下载垃圾邮件和非垃圾
邮件。
• 提取数据集，熟悉数据格式。
[En]

extract the dataset and be familiar with the data format.*

• 将数据集分为训练集和测试集。
[En]

divide the dataset into a training set and a test set.*

• 编写数据准备管道，将每条消息转换为特征向量。您的管道应该将电子邮件转换为一个(稀疏的)向量，该向量“表明存在所有可能的单词”。
[En]

write a data preparation pipeline to convert each message into a feature vector. Your pipeline should convert email into a (sparse) vector that “indicates the existence of all possible words”.*

比如，如果所有的邮件都只包含四个词”Hello””how””are””you”，那么邮件”Hello you Hello Hello you”会被转换成为向量[1，0，0，1]
（意思是”Hello”存在，”how”不存在，”are”不存在，”you”存在），如果你希望算上每个词出现的次数，那么这个向量就是[3，0，0，2]。

• 在流水线上添加超参数来控制是否剥离电子邮件标题，是否将每封邮件转换为小写，是否删除标点符号，是否将”URLs”替换成”URL”，
是否将所有小写number替换为”NUMBER”，甚至是否执行词干提取（即去掉单词后缀，有可用的Python库可以实现该操作）。
• 最后，再尝试几个分类器，看看能否创建一个高召回率和高准确率的垃圾邮件分类器。
[En]

finally, try several more classifiers to see if you can create a spam classifier with high recall rate and high precision.*

Original: https://blog.csdn.net/Morganfs/article/details/123926929
Author: 新四石路打卤面
Title: 《机器学习实战：基于Scikit-Learn、Keras和TensorFlow第2版》-学习笔记（3）

(0)

### 大家都在看

• #### 天险之路（下）

有时候迈出一步，需要勇气。 维度设计 维度设计基础 维度使用主键标识其唯一性，主键也是确保与之相连的任何事实表之间存在引用完整性的基础。主键有两种：代理键和自然键，它们都是用于标识…

人工智能 2023年7月18日
0182
• #### 深入浅出 Yolo 系列之 Yolov7 基础网络结构详解

从 2015 年的 YOLOV1，2016 年 YOLOV2， 2018 年的 YOLOV3，到 2020 年的 YOLOV4、 YOLOV5， 以及最近出现的 YOLOV76 和…

人工智能 2023年7月27日
0129
• #### Python基础—面试题汇总

前言 本文只涉及Python相关的面试题，面向中高级Python开发，太基本的题目不收录。 更希望通过代码演示，原理探究等来深入讲解某一知识点，做到融会贯通。 另外部分演示代码有兴…

人工智能 2023年7月5日
0165
• #### 明明安装了gpu版的pytorch可是测试的时候居然用的试cpu版的？

但我安装的时候明明安装的cuda对应的pytorch 用的清华镜像命令是 conda install pytorch torchvision cudatoolkit=10.2 -c…

人工智能 2023年7月22日
0162
• #### python数据分析多元 线性回归

人工智能 2023年7月15日
0173
• #### Transformer – 李宏毅笔记

Transformer 1.Sequence-to-sequence简介 2.transformer结构 * 2.1 transformer的Encoder – 2.1…

人工智能 2023年5月28日
0155
• #### Apollo control模块纵向控制原理及核心代码逐行解析

前言 2021/12/30 前段时间一直在看Apollo的控制代码，因为工作较忙，只能抽时间整理下代码笔记，可能稍显粗糙，部分图片手绘，作为日后调试之参照。以后有时间再优化排版，再…

人工智能 2023年6月1日
0143
• #### Transformer详解

近期Transformer系列模型的出现，增加了CV领域的多样性。但是Transformer这一不同领域的模型对学习者来说需要一个细致的学习过程.下面就是本菜鸟总结学习路线。Tra…

人工智能 2023年5月30日
0177
• #### Yolov5 v6.1网络结构

Yolov5 已经更新到v6.1版本了，与之前的版本有了不少区别，网络结构有了进一步优化。来整理一下。 本文主要参考 https://blog.csdn.net/qq_375410…

人工智能 2023年6月17日
0184
• #### [3D检测系列-PointRCNN]复现PointRCNN代码，并实现PointRCNN3D目标检测可视化，包含预训练权重下载链接（从0开始以及各种报错的解决方法）

[3D检测系列-PointRCNN] 复现PointRCNN代码 1.下载代码 2.准备数据集 (1)使用官网提供的数据集格式 (2)使用软连接 3.检测结果 4.结果可视化 (1…

人工智能 2023年6月24日
0163
• #### 论文阅读 DynGEM: Deep Embedding Method for Dynamic Graphs

2 DynGEM: Deep Embedding Method for Dynamic Graphs link:https://arxiv.org/abs/1805.11273v1…

人工智能 2023年6月4日
0156
• #### 【开源规划器】autoware的决策规划控制模块

系列文章目录 提示：这里可以添加系列文章的所有文章的目录，目录需要自己手动添加TODO:写完再整理 文章目录 系列文章目录 前言 决策规划模块功能介绍 * 1.规划常用任务 &#8…

人工智能 2023年6月1日
0150
• #### 图像处理中几何畸变校正,图像纠正的方法有哪些

如何通过人工神经网络实现图像识别 。 人工神经网络（ArtificialNeuralNetworks）（简称ANN）系统从20世纪40年代末诞生至今仅短短半个多世纪，但由于他具有信…

人工智能 2023年6月18日
0134
• #### 机器学习——线性回归案例——波士顿房价预测

因为此案例比较经典，所以数据已经镶嵌在里面了 1、导入模块。 模型获取，有线性回归、岭回归、套索回归模型 from sklearn.linear_model import Line…

人工智能 2023年6月12日
0191
• #### 逻辑回归模型在处理文本分类问题上有什么注意事项

问题背景 逻辑回归模型是一种被广泛应用于文本分类问题的机器学习方法。它通过建立一个线性模型并使用逻辑函数来预测文本的类别。在处理文本分类问题时，逻辑回归模型需要考虑一些重要的注意事…

人工智能 2023年12月31日
0148
• #### 中文文本纠错工具推荐:pycorrector

https://github.com/shibing624/pycorrector 中文文本纠错工具。音似、形似错字（或变体字）纠正，可用于中文拼音、笔画输入法的错误纠正。pyth…

人工智能 2023年5月30日
0198