[英]How can I choose the value of output neurons for the hidden layer of tf.keras model?
I am new to Keras and starting with this code from tf tutorial :我是 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
])
I wonder what the value 128 is?我想知道 128 的值是多少? and how it was calculated?
以及它是如何计算的?
128
is a hyper parameter which is the number of nodes in your second to last layer. 128
是一个超参数,它是倒数第二层中的节点数。
It isn't calculated, you can change it to whatever you want, try [18,32,64...etc]
.它不是计算出来的,你可以把它改成你想要的任何东西,试试
[18,32,64...etc]
。 The larger you make it the slower your training will be;你设置得越大,你的训练就越慢; however your model might be more accurate since there are more nodes to capture the signal of your dataset.
但是您的模型可能更准确,因为有更多节点可以捕获数据集的信号。
It's not calculated, it's a hyperparameter (a parameter that isn't estimated by the data, but selected by you prior to running the model).它不是计算出来的,而是一个超参数(不是由数据估计的参数,而是在运行模型之前由您选择的参数)。 It essentially determines the complexity of the model.
它本质上决定了模型的复杂性。 The more neurons, the more complex relationships it can model in the data.
神经元越多,它可以在数据中建模越复杂的关系。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.