提交 41452a31 编写于 作者: W wizardforcel

2021-01-16 21:09:17

上级 bc4074ad
......@@ -227,7 +227,7 @@ CNN 可以执行不同的任务,这些任务适用于所有监督学习问题
此练习不需要编码,而是由基于我们前面提到的概念的计算组成。
1. Calculate the output shape of a matrix derived from a convolutional layer with an input of shape 64 x 64 x 3 and a filter of shape 3 x 3 x 3:
1. 计算从卷积层派生的矩阵的输出形状,该卷积层的输入形状为`64 x 64 x 3`,过滤器形状为`3 x 3 x 3`
```py
Output height = 64 -3 + 1 = 62
......@@ -235,7 +235,7 @@ CNN 可以执行不同的任务,这些任务适用于所有监督学习问题
Output depth = 1
```
2. Calculate the output shape of a matrix derived from a convolutional layer with an input of shape 32 x 32 x 3, 10 filters of shape 5 x 5 x 3, and padding of 2:
2. 计算从卷积层派生的矩阵的输出形状,该卷积层的输入形状为`32 x 32 x 3`,10个形状为`5 x 5 x 3`的滤波器,填充为2:
```py
Output height = 32 - 5 + (2 * 2) + 1 = 32
......@@ -243,7 +243,7 @@ CNN 可以执行不同的任务,这些任务适用于所有监督学习问题
Output depth = 10
```
3. Calculate the output shape of a matrix derived from a convolutional layer with an input of shape 128 x 128 x 1, five filters of shape 5 x 5 x 1, and stride of 3:
3. 计算从卷积层派生的矩阵的输出形状,该卷积层的输入形状为`128 x 128 x 1`,五个形状为`5 x 5 x 1`的滤波器,步幅为3:
```py
Output height = (128 - 5)/ 3 + 1 = 42
......@@ -251,7 +251,7 @@ CNN 可以执行不同的任务,这些任务适用于所有监督学习问题
Output depth = 5
```
4. Calculate the output shape of a matrix derived from a convolutional layer with an input of shape 64 x 64 x 1, a filter of shape 8 x 8 x 1, padding of 3, and a stride of 3:
4. 计算从卷积层派生的矩阵的输出形状,该卷积层的输入形状为`64 x 64 x 1`,形状为`8 x 8 x 1`的滤波器,填充为3,步幅为3:
```py
Output height = ((64 - 8 + (2 * 3)) / 3) +1 = 21.6 ≈ 21
......@@ -328,11 +328,11 @@ class CNN_network(nn.Module):
1. 卷积层,具有 16 个大小为 3 的滤镜,步幅和填充为 1。
2. 池层还具有大小为 2 的过滤器以及大小为 2 的步幅。
3. 卷积层,具有八个大小为 7 的滤镜,跨度为 1,填充为 3。
4. A pooling layer with a filter of size two and a stride of two as well.
4. 池化层,其过滤器的大小为2,步幅也为2。
经过每一层后,矩阵的输出大小如下:
1. After the first convolutional layer:
1. 在第一个卷积层之后:
```py
output_width/height = ((256 – 3) + 2 * 1)/1 + 1 = 256
......@@ -342,7 +342,7 @@ class CNN_network(nn.Module):
output_matrix_size = 256 x 256 x 16
```
2. After the first pooling layer:
2. 在第一个池化层之后:
```py
output_width/height = (256 – 2) / 2 + 1 = 128
......@@ -352,7 +352,7 @@ class CNN_network(nn.Module):
output_matrix_size = 128 x 128 x 16
```
3. After the second convolutional layer:
3. 在第二个卷积层之后:
```py
output_width/height = ((128 – 7) + 2 =* 3)/1 + 1 = 128
......@@ -362,7 +362,7 @@ class CNN_network(nn.Module):
output_matrix_size = 128 x 128 x 8
```
4. After the second pooling layer:
4. 在第二个池化层之后:
```py
output_width/height = (128 – 2) / 2 + 1 = 64
......@@ -549,7 +549,7 @@ test_loader = torch.utils.data.DataLoader(test_data, \
3. 设置批量为 100 张图像,并从 **CIFAR10** 数据集下载训练和测试数据。
4. 使用 20% 的验证大小,定义将用于将数据集分为这两组的训练和验证采样器。
5. 使用`DataLoader()`函数定义用于每组数据的批量。
6. Define the architecture of your network. Use the following information to do so:
6. 定义您的网络架构。 使用以下信息来这样做:
Conv1:卷积层,将彩色图像作为输入,并将其通过大小为 3 的 10 个滤镜。应将 padding 和 stride 都设置为 1。
......@@ -570,7 +570,7 @@ test_loader = torch.utils.data.DataLoader(test_data, \
7. 定义训练模型所需的所有参数。 将纪元数设置为 50。
8. 训练您的网络,并确保保存训练和验证集的损失和准确率值。
9. 绘制两组的损失和准确率。
10. Check the model's accuracy on the testing set—it should be around 72%.
10. 在测试集上检查模型的准确度--它应该在72%左右。
注意
......@@ -588,7 +588,7 @@ test_loader = torch.utils.data.DataLoader(test_data, \
在开发计算机视觉问题的解决方案时,这成为一个相关问题,主要是由于两个原因:
* The larger the dataset, the better the results, and larger datasets are crucial to arrive at decent enough models. This is true considering that training a model is a matter of tuning a bunch of parameters so that it is capable of mapping a relationship between an input and an output. This is achieved by minimizing the loss function to make the predicted value come as close as possible to the ground truth. Here, the more complex the model, the more parameters it requires.
* 数据集越大,结果越好,并且更大的数据集对于获得足够好的模型至关重要。 考虑到训练模型是调整一堆参数的问题,以便能够映射输入和输出之间的关系,这是正确的。 这是通过最小化损失函数以使预测值尽可能接近基本事实来实现的。 在此,模型越复杂,所需的参数就越多。
考虑到这一点,有必要向模型提供大量示例,以便能够找到这样的模式,其中训练示例的数量应与要调整的参数的数量成比例。
......@@ -668,13 +668,13 @@ test_data = datasets.CIFAR10('data', train=False, download=True, \
您创建的模型不错,但是其准确率达不到期望的水平。 您被要求考虑一种可以改善模型性能的方法。 请按照以下步骤完成此活动:
1. 复制上一个活动中的笔记本。
2. Change the definition of the **transform** variable so that it includes, in addition to normalizing and converting the data into tensors, the following transformations:
2. 修改`transform`变量的定义,使其除了将数据归一化并转换为张量外,还包括以下转换:
对于训练/验证集,`RandomHorizo​​ntalFlip`函数的概率为 50% (0.5),`RandomGrayscale`函数的概率为 10% (0.1)。
对于测试集,请勿添加任何其他转换。
3. Train the model for 100 epochs. The resulting plots for loss and accuracy on the training and validation sets should be similar to the ones shown here:
3. 训练模型100个纪元。由此得到的训练集和验证集的损失和准确度图应与这里所示的相似。
![Figure 4.18: Resulting plot showing the loss of the sets ](img/B15778_04_18.jpg)
......@@ -713,7 +713,7 @@ test_data = datasets.CIFAR10('data', train=False, download=True, \
此外,批量归一化为模型的训练过程带来了以下好处,最终可以帮助您获得性能更好的模型:
* 它允许设置更高的学习率,因为批量归一化有助于确保任何输出都不是太高或太低。 更高的学习率等同于更快的学习时间。
* It helps reduce overfitting because it has a regularization effect. This makes it possible to set the dropout probability to a lower value, which means that less information is ignored in each forward pass.
* 它有助于减少过拟合,因为它具有正则化效应。这使得可以将丢弃概率设置为一个较低的值,这意味着在每个前向通道中忽略的信息较少。
注意
......@@ -760,7 +760,7 @@ class CNN(nn.Module):
1. 复制上一个活动中的笔记本。
2. 将批量归一化添加到每个卷积层以及第一个 FC 层。
3. Train the model for 100 epochs. The resulting plots of the loss and accuracy of the training and validation sets should be similar to the ones shown here:
3. 训练模型100个纪元。由此得到的训练集和验证集的损失和准确度图应该与这里的图相似。
![Figure 4.21: Resulting plot showing the loss of the sets ](img/B15778_04_21.jpg)
......@@ -770,7 +770,7 @@ class CNN(nn.Module):
图 4.22:结果图显示了集合的丢失
4. Calculate the accuracy of the resulting model on the testing set—it should be around 78%.
4. 计算结果模型在测试集上的准确度--它应该是78%左右。
注意
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册