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:
*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.
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:
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)
*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.
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%.