![](/img/trans.png)
[英]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.