是否有规则可以找到并设置DNN隐藏层的神经元数?
我的情况是:多类分类问题,具有5个功能(我的数据中的列),15个类,单标签。 我的模型是:一个带有5个神经元的输入层,只有一个带有relu的隐藏层,一个带有SoftMax的输出层。 我有两个问题:
- 输入层有多少个神经元?确定它是根据功能的数量加上偏差设置的?我尝试调整输入层中神经元的数量,例如77个神经元,性能有所改善,因此我感到困惑。
- 我尝试了随机搜索简历以找到隐藏层的数量,神经元的数量和学习率,我在Scikit学习中使用了随机搜索,然后BEST_PARAMS将显示这样的东西:
{'Learning_rate':0.0023716395806862335,'n_layer':1,'n_neurons':291}
因此,问题是,如果它显示出best_params'n_layer':2,但是'n_neurons':2,但是'N_neurons':每一层为291个神经元,模型中有2个隐藏层?
先感谢您!
My situation is that: multiclass classification problem, with 5 features (columns in my data), 15 classes, single label.
My model is : one input layer with 5 neurons, just one hidden layer with ReLU, and one output layer with softmax.
I have two questions:
- How many neurons for the input layer? Is it certain that it is set according to the number of features plus bias? I tried tweaking the number of neurons in the input layer, say 77 neurons, the performance improved so I am confused.
- I tried Randomized Search cv to find the number of hidden layer, number of neurons and learning rate, I used Randomizedsearchcv in Scikit learn, then the best_params will display something like this:
{'learning_rate': 0.0023716395806862335, 'n_layer': 1, 'n_neurons': 291}
So, the question is that, let's say,if it showed best_params 'n_layer': 2, but 'n_neurons': 291. so is it interpreted as 291 neurons per each layer, and 2 hidden layers in the model?
Thank you in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您第一个问题的答案:输入层的形状设置基础数字。在您的问题中,您需要5个功能,然后输入层需要5个功能,在我的示例中,我有784个功能,然后输入层形状应为784。
是的,我们有规则可以找到DNN层中神经元的数量。我强烈建议您使用
keras tuner
。 Kerastuner找到了最佳的超参数值,用于使用贝叶斯优化的模型,超频带和随机搜索算法。我写作。
fashion_mnist
数据集的一个示例,其中包括您在问题中解释的模型。我使用epoch = 2
,您可以将此搜索与较大的时期一起使用。对于此问题,kerastuner
发现第一层的最佳NUM神经元= 416
(< - 您想找到此)和最佳Learning_rate-0.0001
。输出:
The answer to your first question: input layer's shape set base num of features. In your problem you need 5 features then the input layer needs to be 5 and in my example, I have 784 features then the input layer shape should be 784.
Yes, We have the rule to find the number of neurons in the layer for DNN. I highly recommend you to use
Keras Tuner
. KerasTuner finds the best hyperparameter values for your models with Bayesian Optimization, Hyperband, and Random Search algorithms. I write an example with thefashion_mnist
dataset with the model that you explain in your question. I useepoch=2
, you can use this search with larger epochs for your problem. For this problem,KerasTuner
finds that the best num neuron for thefirst layer = 416
(<- you want to find this) and bestlearning_rate-0.0001
.Output: