在 Keras 中,以下全連接層(Dense Layer)的可學習參數數量為多少? ```python from tensorflow import keras model = keras.Sequential([ keras.layers.Dense(128, activation='relu', input_shape=(64,)), keras.layers.Dense(10, activation='softmax') ]) ```

iPAS 考題解析

在 Keras 中,以下全連接層(Dense Layer)的可學習參數數量為多少? ```python from tensorflow import keras model = keras.Sequential([ keras.layers.Dense(128, activation='relu', input_shape=(64,)), keras.layers.Dense(10, activation='softmax') ]) ```

  • A. 8,192 個
  • B. 8,192 + 128 = 8,320 個
  • C. 8,320 + 1,290 = 9,610 個 ✓ 正確答案
  • D. 8,192 + 10 = 8,202 個

詳細解析

第一層 Dense(128, input_shape=(64,)):weights = 64×128 = 8,192,biases = 128。小計:8,320。第二層 Dense(10):weights = 128×10 = 1,280,biases = 10。小計:1,290。Total = 8,320 + 1,290 = 9,610。

出題年份:114 難度:★★★