改变卷积神经网络的参数
Change parameters in Convolution neural network
我正在练习 CNN。我阅读了一些关于训练 MNIST 数据集使用 CNNs.size 图像的论文是 28x28 并使用架构 5 层:输入>conv1-maxpool1>conv2-maxpool2>完全连接>输出
Convolutional Layer #1
- Computes 32 features using a 5x5 filter with ReLU activation.
- Padding is added to preserve width and height.
- Input Tensor Shape: [batch_size, 28, 28, 1]
- Output Tensor Shape: [batch_size, 28, 28, 32]
Pooling Layer #1
- First max pooling layer with a 2x2 filter and stride of 2
- Input Tensor Shape: [batch_size, 28, 28, 32]
- Output Tensor Shape: [batch_size, 14, 14, 32]
Convolutional Layer #2
- Computes 64 features using a 5x5 filter.
- Padding is added to preserve width and height.
- Input Tensor Shape: [batch_size, 14, 14, 32]
- Output Tensor Shape: [batch_size, 14, 14, 64]
Pooling Layer #2
- Second max pooling layer with a 2x2 filter and stride of 2
- Input Tensor Shape: [batch_size, 14, 14, 64]
- Output Tensor Shape: [batch_size, 7, 7, 64]
Flatten tensor into a batch of vectors
- Input Tensor Shape: [batch_size, 7, 7, 64]
- Output Tensor Shape: [batch_size, 7 * 7 * 64]
Fully Connected Layer
- Densely connected layer with 1024 neurons
- Input Tensor Shape: [batch_size, 7 * 7 * 64]
- Output Tensor Shape: [batch_size, 1024] Output layer
- Input Tensor Shape: [batch_size, 1024]
- Output Tensor Shape: [batch_size, 10]
在 conv1 中,1 个输入使用 5x5 过滤器计算 32 个特征,在 conv2 中,conv1 的 32 个输入使用相同的过滤器计算 64 个特征。 32、64、2x2 滤波器等参数的选择依据是什么?它们是基于图像的大小吗?
如果图像尺寸大于 28x28,例如 128x128。我应该增加 5 层以上的层数吗?以上参数如何随其他尺寸的图像变化?
提前致谢
在基础级别,这些输入称为超参数,通常不由任何特定规则集定义。也就是说,我们经常使用经验法则(启发式)来选择一组超参数,然后使用超参数优化来提高性能或效率等。
对此的一个很好的解释是 Here
编辑:
本文中的更多信息 - 这是一个广泛研究的问题,查看 Arxiv 和 Stats.Stackexchange 了解更多信息,但这是我在学习时使用的一篇很棒的论文 Here
What are parameters such as 32,64,2x2 filter chosen based on? Do they
based on size of image?
你提到的参数(32,64,2x2)是卷积层的过滤器数量和过滤器大小。它们是您可以在训练模型时 select 和调整的超参数。根据您的数据集、应用程序和模型性能,您可以控制它们。
对于许多过滤器,您可以使用它来控制模型学习的特征数量。在您的模型中,您的过滤器数量在最大池化层之后从 32 增加到 64。具有 2x2 过滤器的 Maxpooling 层会将特征数量减少一半。通过将过滤器数量增加一倍,它将在模型中保持相同数量的特征。按照惯例,在 2x2 maxpooling 层之后,过滤器数量将因此增加一倍。
而对于filter size,如果是针对maxpooling层,则决定了feature reduction的大小。如果是卷积层,它将决定输入图像的学习细节。例如,如果您尝试处理小像素或特征区分对象的图像,您可以选择小尺寸的过滤器,例如 3x3 或 5x5。对于大过滤器尺寸,反之亦然。
理解这些超参数的一种方法是了解它们如何影响模型的学习,您将知道如何根据每种情况控制它们。另一种方法是查看这些是如何为其他人使用的模型设置的。您可能会发现一些约定,例如过滤器数量在最大池化层之后增加。
If size of images is larger than 28x28 such as 128x128. Should I
increse the number of layers over 5 layers? How are above parameters
changed with other size of images?
关于层,层数越多,模型越深,参数也越多。这意味着您的模型将变得更加复杂,并且能够更多地了解图像特征。因此,拥有深层架构有利于学习高分辨率的图像。因为大分辨率意味着有很多特征需要学习。然而,这也将视具体情况而定。好的方法是从具有少量层的简单模型开始,然后逐渐增加层数,同时它对您的模型有益。
我正在练习 CNN。我阅读了一些关于训练 MNIST 数据集使用 CNNs.size 图像的论文是 28x28 并使用架构 5 层:输入>conv1-maxpool1>conv2-maxpool2>完全连接>输出
Convolutional Layer #1
- Computes 32 features using a 5x5 filter with ReLU activation.
- Padding is added to preserve width and height.
- Input Tensor Shape: [batch_size, 28, 28, 1]
- Output Tensor Shape: [batch_size, 28, 28, 32]
Pooling Layer #1
- First max pooling layer with a 2x2 filter and stride of 2
- Input Tensor Shape: [batch_size, 28, 28, 32]
- Output Tensor Shape: [batch_size, 14, 14, 32]
Convolutional Layer #2
- Computes 64 features using a 5x5 filter.
- Padding is added to preserve width and height.
- Input Tensor Shape: [batch_size, 14, 14, 32]
- Output Tensor Shape: [batch_size, 14, 14, 64]
Pooling Layer #2
- Second max pooling layer with a 2x2 filter and stride of 2
- Input Tensor Shape: [batch_size, 14, 14, 64]
- Output Tensor Shape: [batch_size, 7, 7, 64]
Flatten tensor into a batch of vectors
- Input Tensor Shape: [batch_size, 7, 7, 64]
- Output Tensor Shape: [batch_size, 7 * 7 * 64]
Fully Connected Layer
- Densely connected layer with 1024 neurons
- Input Tensor Shape: [batch_size, 7 * 7 * 64]
- Output Tensor Shape: [batch_size, 1024] Output layer
- Input Tensor Shape: [batch_size, 1024]
- Output Tensor Shape: [batch_size, 10]
在 conv1 中,1 个输入使用 5x5 过滤器计算 32 个特征,在 conv2 中,conv1 的 32 个输入使用相同的过滤器计算 64 个特征。 32、64、2x2 滤波器等参数的选择依据是什么?它们是基于图像的大小吗?
如果图像尺寸大于 28x28,例如 128x128。我应该增加 5 层以上的层数吗?以上参数如何随其他尺寸的图像变化?
提前致谢
在基础级别,这些输入称为超参数,通常不由任何特定规则集定义。也就是说,我们经常使用经验法则(启发式)来选择一组超参数,然后使用超参数优化来提高性能或效率等。
对此的一个很好的解释是 Here
编辑: 本文中的更多信息 - 这是一个广泛研究的问题,查看 Arxiv 和 Stats.Stackexchange 了解更多信息,但这是我在学习时使用的一篇很棒的论文 Here
What are parameters such as 32,64,2x2 filter chosen based on? Do they based on size of image?
你提到的参数(32,64,2x2)是卷积层的过滤器数量和过滤器大小。它们是您可以在训练模型时 select 和调整的超参数。根据您的数据集、应用程序和模型性能,您可以控制它们。
对于许多过滤器,您可以使用它来控制模型学习的特征数量。在您的模型中,您的过滤器数量在最大池化层之后从 32 增加到 64。具有 2x2 过滤器的 Maxpooling 层会将特征数量减少一半。通过将过滤器数量增加一倍,它将在模型中保持相同数量的特征。按照惯例,在 2x2 maxpooling 层之后,过滤器数量将因此增加一倍。
而对于filter size,如果是针对maxpooling层,则决定了feature reduction的大小。如果是卷积层,它将决定输入图像的学习细节。例如,如果您尝试处理小像素或特征区分对象的图像,您可以选择小尺寸的过滤器,例如 3x3 或 5x5。对于大过滤器尺寸,反之亦然。
理解这些超参数的一种方法是了解它们如何影响模型的学习,您将知道如何根据每种情况控制它们。另一种方法是查看这些是如何为其他人使用的模型设置的。您可能会发现一些约定,例如过滤器数量在最大池化层之后增加。
If size of images is larger than 28x28 such as 128x128. Should I increse the number of layers over 5 layers? How are above parameters changed with other size of images?
关于层,层数越多,模型越深,参数也越多。这意味着您的模型将变得更加复杂,并且能够更多地了解图像特征。因此,拥有深层架构有利于学习高分辨率的图像。因为大分辨率意味着有很多特征需要学习。然而,这也将视具体情况而定。好的方法是从具有少量层的简单模型开始,然后逐渐增加层数,同时它对您的模型有益。