如何确定神经网络的层数和节点数
How to determine the number of layers and nodes of a neural network
我目前正在为具有 387 个特征和 3000 个样本的数据集构建神经网络。输出为 3 类。我配置的网络结构如下:
输入->200->{300->100}->50->输出
我选择的节点数和层数是否正确?如何确定每一层(输入、隐藏和输出)的节点数?有什么规定吗?
规则?想吃多少就吃多少 none。这是 Neural Network FAQ 的摘录,这是一个很好的基本问题参考页面:
A: How many hidden units should I use? ==========================================
There is no way to determine a good network topology just from the
number of inputs and outputs. It depends critically on the number
of training examples and the complexity of the classification you
are trying to learn. There are problems with one input and one
output that require millions of hidden units, and problems with a
million inputs and a million outputs that require only one hidden
unit, or none at all.
Some books and articles offer "rules of
thumb" for choosing a topopology -- Ninputs plus Noutputs dividied
by two, maybe with a square root in there somewhere -- but such
rules are total garbage. Other rules relate to the number of
examples available: Use at most so many hidden units that the number of weights in the network times 10 is smaller than the number
of examples. Such rules are only concerned with overfitting and are
unreliable as well.
但是,对于您的情况,可以肯定地说网络太复杂了(即使您应用了强正则化)。为什么有这么多隐藏层?从一个隐藏层开始——尽管深度学习令人兴奋——并且使用最少的隐藏节点。增加隐藏节点数,直到获得良好的性能。只有在没有的情况下,我才会添加更多层。此外,使用交叉验证和适当的正则化。
图层
正如蒙特利尔学习算法研究所所长 Yoshua Bengio remarks:
"Very simple. Just keep adding layers until the test error does not improve anymore."
Geoff Hinton 推荐的一种方法是添加层,直到你开始过度拟合你的训练集。然后添加 dropout 或其他正则化方法。
节点
你的任务:
- 输入层 应包含每个特征的 387 个节点。
- 输出层 应包含每个 class.
的 3 个节点
- 隐藏层 我发现逐渐减少每层神经元的数量效果很好(this list of tips and tricks 在为压缩任务创建自动编码器时同意这一点)。也许在第一个隐藏层尝试 200,在第二个隐藏层尝试 100;同样,它是一个需要优化的超参数,并且非常依赖于数据集大小。
正如他们所说,没有 "magic" 计算神经网络隐藏层数和节点数的规则,但有一些提示或建议可以帮助您找到最佳的。
隐藏节点的数量基于以下关系:
- 输入输出节点数
- 可用的训练数据量
- 试图学习的函数的复杂性
- 训练算法
为了最大限度地减少错误并拥有一个泛化能力良好的训练网络,您需要选择最佳数量的隐藏层,以及每个隐藏层中的节点。
太少的节点会导致您的系统出现高误差,因为预测因素可能太复杂以至于少量节点无法捕获
过多的节点会过度拟合您的训练数据并且不能很好地泛化
您可以在此页面上找到一些一般性建议:
Section - How many hidden units should I use?
如果您的数据是线性可分的,那么您根本不需要任何隐藏层。否则,对于添加额外隐藏层的性能差异存在共识:通过第二个(或第三个等)隐藏层提高性能的情况非常小。因此,一个隐藏层足以解决绝大多数问题。
有一些 empirically-derived rules-of-thumb,其中,最常依赖的是 'the optimal size of the hidden layer is usually between the size of the input and size of the output layers'。
总而言之,对于大多数问题,仅使用两个规则设置隐藏层配置可能会获得不错的性能:
- 隐藏层数等于一个
- 该层的神经元数量是输入层和输出层神经元的平均值。
this StackExchange post 中有很多不同的方法,非常好!
我目前正在为具有 387 个特征和 3000 个样本的数据集构建神经网络。输出为 3 类。我配置的网络结构如下:
输入->200->{300->100}->50->输出
我选择的节点数和层数是否正确?如何确定每一层(输入、隐藏和输出)的节点数?有什么规定吗?
规则?想吃多少就吃多少 none。这是 Neural Network FAQ 的摘录,这是一个很好的基本问题参考页面:
A: How many hidden units should I use? ==========================================
There is no way to determine a good network topology just from the number of inputs and outputs. It depends critically on the number of training examples and the complexity of the classification you are trying to learn. There are problems with one input and one output that require millions of hidden units, and problems with a million inputs and a million outputs that require only one hidden unit, or none at all.
Some books and articles offer "rules of thumb" for choosing a topopology -- Ninputs plus Noutputs dividied by two, maybe with a square root in there somewhere -- but such rules are total garbage. Other rules relate to the number of examples available: Use at most so many hidden units that the number of weights in the network times 10 is smaller than the number of examples. Such rules are only concerned with overfitting and are unreliable as well.
但是,对于您的情况,可以肯定地说网络太复杂了(即使您应用了强正则化)。为什么有这么多隐藏层?从一个隐藏层开始——尽管深度学习令人兴奋——并且使用最少的隐藏节点。增加隐藏节点数,直到获得良好的性能。只有在没有的情况下,我才会添加更多层。此外,使用交叉验证和适当的正则化。
图层
正如蒙特利尔学习算法研究所所长 Yoshua Bengio remarks:
"Very simple. Just keep adding layers until the test error does not improve anymore."
Geoff Hinton 推荐的一种方法是添加层,直到你开始过度拟合你的训练集。然后添加 dropout 或其他正则化方法。
节点
你的任务:
- 输入层 应包含每个特征的 387 个节点。
- 输出层 应包含每个 class. 的 3 个节点
- 隐藏层 我发现逐渐减少每层神经元的数量效果很好(this list of tips and tricks 在为压缩任务创建自动编码器时同意这一点)。也许在第一个隐藏层尝试 200,在第二个隐藏层尝试 100;同样,它是一个需要优化的超参数,并且非常依赖于数据集大小。
正如他们所说,没有 "magic" 计算神经网络隐藏层数和节点数的规则,但有一些提示或建议可以帮助您找到最佳的。
隐藏节点的数量基于以下关系:
- 输入输出节点数
- 可用的训练数据量
- 试图学习的函数的复杂性
- 训练算法
为了最大限度地减少错误并拥有一个泛化能力良好的训练网络,您需要选择最佳数量的隐藏层,以及每个隐藏层中的节点。
太少的节点会导致您的系统出现高误差,因为预测因素可能太复杂以至于少量节点无法捕获
过多的节点会过度拟合您的训练数据并且不能很好地泛化
您可以在此页面上找到一些一般性建议:
Section - How many hidden units should I use?
如果您的数据是线性可分的,那么您根本不需要任何隐藏层。否则,对于添加额外隐藏层的性能差异存在共识:通过第二个(或第三个等)隐藏层提高性能的情况非常小。因此,一个隐藏层足以解决绝大多数问题。
有一些 empirically-derived rules-of-thumb,其中,最常依赖的是 'the optimal size of the hidden layer is usually between the size of the input and size of the output layers'。
总而言之,对于大多数问题,仅使用两个规则设置隐藏层配置可能会获得不错的性能:
- 隐藏层数等于一个
- 该层的神经元数量是输入层和输出层神经元的平均值。
this StackExchange post 中有很多不同的方法,非常好!