如何为tf.keras模型的隐藏层选择输出神经元的值?

问题描述 投票:1回答:2

我是Keras的新手,从tf教程中的代码开始:

# choosing the layers of my models 
model = keras.Sequential([ # the sequential model of Keras library 
    keras.layers.Flatten(input_shape=(28, 28)), # the first input layer
    keras.layers.Dense(128, activation='relu'),# the hidden layer 
    keras.layers.Dense(10)# output layers and 10 corresponds to the number of used classes 
])

我想知道值128是多少?以及如何计算?

python tensorflow keras
2个回答
1
投票

未计算,它是一个超参数(该参数不是由数据估算的,而是在运行模型之前由you选择)。它实质上决定了模型的复杂性。神经元越多,可以在数据中建模的关系就越复杂。


1
投票

128是倒数第二层的节点数。它不是计算出来的,您可以将其更改为任意值,请尝试[18,32,64...etc]。您做的越大,训练的速度就越慢;但是,由于有更多节点可以捕获数据集的信号,因此您的模型可能更准确。

© www.soinside.com 2019 - 2024. All rights reserved.