我是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是什么?以及如何计算?
答案 0 :(得分:3)
它不是计算出来的,而是一个超参数(该参数不是由数据估计的,而是由 you 在运行模型之前选择的)。它实质上决定了模型的复杂性。神经元越多,它可以在数据中建模的关系就越复杂。
答案 1 :(得分:2)
128
是一个超级参数,它是倒数第二层中的节点数。
它不是计算出来的,您可以将其更改为任意值,请尝试[18,32,64...etc]
。您做的越大,训练的速度就越慢;但是,由于有更多节点可以捕获数据集的信号,因此您的模型可能更准确。