cnn卷积神经网络_5分钟内卷积神经网络(CNN)

本文简要介绍了卷积神经网络(CNN),它是一种广泛应用于图像识别和计算机视觉任务的深度学习模型。通过快速概览CNN的核心概念,包括卷积层、池化层和过滤器,读者可以在短时间内掌握CNN的基本工作原理。
摘要由CSDN通过智能技术生成

cnn卷积神经网络

Convolutional neural networks (CNNs) are the most popular machine leaning models for image and video analysis.

卷积神经网络(CNN)是用于图像和视频分析的最流行的机器学习模型。

示例任务 (Example Tasks)

Here are some example tasks that can be performed with a CNN:

以下是一些可以使用CNN执行的示例任务:

  • Binary Classification: given an input image from a medical scan, determine if the patient has a lung nodule (1) or not (0)

    二进制分类:给定来自医学扫描的输入图像,确定患者是否患有肺结节(1)(0)
  • Multilabel Classification: given an input image from a medical scan, determine if the patient has none, some, or all of the following: lung opacity, nodule, mass, atelectasis, cardiomegaly, pneumothorax

    多标签分类:给定来自医学扫描的输入图像,确定患者是否患有以下疾病:肺浑浊,结节,肿块,肺不张,心脏肥大,气胸

CNN如何运作 (How CNNs Work)

In a CNN, a convolutional filter slides across an image to produce a feature map (which is labeled “convolved feature” in the image below):

在CNN中,卷积滤镜会在图像上滑动以生成特征图(下图中标记为“卷积特征”):

A filter detects a pattern.

过滤器检测图案。

High values in the output feature map are produced when the filter passes over an area of the image containing the pattern.

当滤镜经过包含图案的图像区域时,将在输出要素图中产生较高的值。

Different filters detect different patterns.

不同的过滤器检测不同的模式。

The kind of pattern that a filter detects is determined by the filter’s weights, which are shown as red numbers in the animation above.

过滤器检测到的模式类型取决于过滤器的权重,权重在上方的动画中显示为红色数字。

A filter weight gets multiplied against the corresponding pixel value, and then the results of these multiplications are summed up to produce the output value that goes in the feature map.

将滤镜权重与相应的像素值相乘,然后将这些相乘的结果相加,以生成输出到特征图中的输出值。

A convolutional neural network involves applying this convolution operation many time, with many different filters.

卷积神经网络需要使用许多不同的滤波器多次应用此卷积运算。

This figure shows the first layer of a CNN:

此图显示了CNN的第一层:

Image for post
Radiopedia) Radiopedia )

In the diagram above, a CT scan slice is the input to a CNN. A convolutional filter labeled “filter 1” is shown in red. This filter slides across the input CT slice to produce a feature map, shown in red as “map 1.”

在上图中,CT扫描切片是CNN的输入。 标记为“过滤器1”的卷积过滤器以红色显示。 该滤镜在输入CT切片上滑动以生成特征图,以红色显示为“图1”。

Then a different filter called “filter 2” (not explicitly shown) which detects a different pattern slides across the input CT slice to produce feature map 2, shown in purple as “map 2.”

然后,一个称为“过滤器2”(未明确显示)的不同过滤器会在输入的CT切片上滑动,以检测不同的模式,以生成特征图2,以紫色显示为“图2”。

This process is repeated for filter 3 (producing map 3 in yellow), filter 4 (producing map 4 in blue) and so on, until filter 8 (producing map 8 in red).

对滤镜3(以黄色生成图3),滤镜4(以蓝色生成图4)等重复此过程,直到滤镜8(以红色生成图8)。

This is the “first layer” of the CNN. The output of the first layer is thus a 3D chunk of numbers, consisting in this example of 8 different 2D feature maps.

这是CNN的“第一层”。 因此,第一层的输出是3D数字块,在此示例中包含8个不同的2D特征图。

Image for post
Image by Author
图片作者

Next we go to the second layer of the CNN, which is shown above. We take our 3D representation (of 8 feature maps) and apply a filter called “filter a” to this. “Filter a” (in gray) is part of the second layer of the CNN. Notice that “filter a” is actually three dimensional, because it has a little 2×2 square of weights on each of the 8 different feature maps. Therefore the size of “filter a” is 8 x 2 x 2. In general, the filters in a “2D” CNN are 3D, and the filters in a “3D” CNN are 4D.

接下来,我们进入CNN的第二层,如上所示。 我们采用3D表示法(包含8个要素图),并对此应用一个称为“ filter a”的过滤器。 “过滤器a”(灰色)是CNN第二层的一部分。 请注意,“过滤器a”实际上是三维的,因为在8个不同的特征图中,每个过滤器的权重只有2×2平方。 因此,“过滤器a”的大小为8 x 2 x2。通常,“ 2D” CNN中的过滤器为3D,而“ 3D” CNN中的过滤器为4D。

We slide filter a across the representation to produce map a, shown in grey. Then, we slide filter b across to get map b, and filter c across to get map c, and so on. This completes the second layer of the CNN.

我们在表示中滑动滤镜a,以生成地图a,以灰色显示。 然后,我们将过滤器b滑到地图b上,将过滤器c滑到地图c上,依此类推。 这样就完成了CNN的第二层。

We can then continue on to a third layer, a fourth layer, etc. for however many layers of the CNN are desired. CNNs can have many layers. As an example, a ResNet-18 CNN architecture has 18 layers.

然后,我们可以继续进行到第三层,第四层等,因为需要CNN的许多层。 CNN可以有很多层。 例如,ResNet-18 CNN体系结构具有18层。

The figure below, from Krizhevsky et al., shows example filters from the early layers of a CNN. The filters early on in a CNN detect simple patterns like edges and lines going in certain directions, or simple color combinations.

下图来自Krizhevsky等人 ,显示了来自CNN早期层的示例过滤器。 CNN早期的滤镜可检测简单的图案,例如沿特定方向延伸的边缘和线条,或简单的颜色组合。

Image for post

The figure below, from Siegel et al. adapted from Lee et al., shows examples of early layer filters at the bottom, intermediate layer filters in the middle, and later layer filters at the top.

下图来自Siegel等。 改编自李等人。 的示例在底部显示早期层过滤器,在中间显示中间层过滤器,在顶部显示较后层过滤器。

The early layer filters once again detect simple patterns like lines going in certain directions, while the intermediate layer filters detect more complex patterns like parts of faces, parts of cars, parts of elephants, and parts of chairs. The later layer filters detect patterns that are even more complicated, like whole faces, whole cars, etc. In this visualization each later layer filter is visualized as a weighted linear combination of the previous layer’s filters.

早期的层过滤器再次检测简单的图案,例如沿特定方向的线条,而中间层的过滤器检测更复杂的图案,例如面部,汽车部分,大象部分和椅子部分。 后面的图层过滤器检测甚至更复杂的模式,例如整张脸,整辆汽车等。在此可视化中,每个后面的图层过滤器都可视为上一层过滤器的加权线性组合。

Image for post

如何学习过滤器 (How to Learn the Filters)

How do we know what feature values to use inside of each filter? We learn the feature values from the data. This is the “learning” part of “machine learning” or “deep learning.”

我们如何知道在每个过滤器内部使用哪些特征值? 我们从数据中学习特征值。 这是“机器学习”或“深度学习”的“学习”部分。

Steps:

脚步:

  1. Randomly initialize the feature values (weights). At this stage, the model produces garbage — its predictions are completely random and have nothing to do with the input.

    随机初始化特征值(权重)。 在此阶段,模型产生垃圾-其预测完全是随机的,与输入无关。
  2. Repeat the following steps for a bunch of training examples: (a) Feed a training example to the model (b) Calculate how wrong the model was using the loss function (c) Use the backpropagation algorithm to make tiny adjustments to the feature values (weights), so that the model will be less wrong next time. As the model becomes less and less wrong with each training example, it will ideally learn how to perform the task very well by the end of training.

    对一堆训练示例重复以下步骤:(a)向模型提供训练示例(b)使用损失函数计算模型的错误程度(c)使用反向传播算法对特征值进行微小调整(权重),这样下次模型就不会出错了。 随着模型在每个训练示例中的错误越来越少,理想情况下,它将在训练结束之前学习如何很好地执行任务。
  3. Evaluate model on test examples it’s never seen before. The test examples are images that were set aside and not used in training. If the model does well on the test examples, then it’s learned generalizable principles and is a useful model. If the model does badly on the test examples, then it’s memorized the training data and is a useless model.

    根据前所未有的测试示例评估模型。 测试示例是被搁置而未在训练中使用的图像。 如果该模型在测试示例上运行良好,那么它就可以学习通用原则,并且是有用的模型。 如果该模型在测试示例上表现不佳,则它会记住训练数据,并且是无用的模型。

The following animation created by Tamas Szilagyi shows a neural network model learning. The animation shows a feedforward neural network rather than a convolutional neural network, but the learning principle is the same. In this animation each line represents a weight. The number shown next to the line is the weight value. The weight value changes as the model learns.

Tamas Szilagyi创建的以下动画显示了神经网络模型学习。 动画显示的是前馈神经网络,而不是卷积神经网络,但是学习原理是相同的。 在此动画中,每条线代表一个权重。 该行旁边显示的数字是重量值。 权重值随模型学习而变化。

Image for post

衡量绩效:AUROC (Measuring Performance: AUROC)

Image for post
Image by Author
图片作者

One popular performance metric for CNNs is the AUROC, or area under the receiver operating characteristic. This performance metric indicates whether the model can correctly rank examples. The AUROC is the probability that a randomly selected positive example has a higher predicted probability of being positive than a randomly selected negative example. An AUROC of 0.5 corresponds to a coin flip or useless model, while an AUROC of 1.0 corresponds to a perfect model.

CNN的一种流行性能指标是AUROC,即接收机工作特性下的面积。 此性能指标指示模型是否可以正确对示例进行排名。 AUROC是随机选择的阳性示例比随机选择的阴性示例具有更高的阳性预测概率的概率。 AUROC为0.5对应于硬币翻转或无用模型,而AUROC为1.0对应于理想模型。

附加阅读 (Additional Reading)

For more details about CNNs, see:

有关CNN的更多详细信息,请参阅:

For more details about how neural networks learn, see Introduction to Neural Networks.

有关神经网络学习方式的更多详细信息,请参见《神经网络简介》

Finally, for more details about AUROC, see:

最后,有关AUROC的更多详细信息,请参见:

Originally published at http://glassboxmedicine.com on August 3, 2020.

最初于 2020年8月3日 发布在 http://glassboxmedicine.com 上。

翻译自: https://towardsdatascience.com/convolutional-neural-networks-cnns-in-5-minutes-dc86d0e27e1e

cnn卷积神经网络

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值