[英]ValueError: Output tensors to a Model must be the output of a TensorFlow Layer with tf.keras Lambda layer
[英]How can I choose the value of output neurons for the hidden layer of tf.keras model?
我是 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 的值是多少? 以及它是如何计算的?
128
是一个超参数,它是倒数第二层中的节点数。
它不是计算出来的,你可以把它改成你想要的任何东西,试试[18,32,64...etc]
。 你设置得越大,你的训练就越慢; 但是您的模型可能更准确,因为有更多节点可以捕获数据集的信号。
它不是计算出来的,而是一个超参数(不是由数据估计的参数,而是在运行模型之前由您选择的参数)。 它本质上决定了模型的复杂性。 神经元越多,它可以在数据中建模越复杂的关系。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.