開始使用免費開始

輸出層

輸出層其實就是 Dense 層!輸出層的用途是把輸入的維度壓縮到輸出的維度。你會在第 4 章更深入了解輸出維度,不過目前先以單一輸出為主,相當於使用 Dense(1),也就是只有 1 個單元的 Dense 層。

本練習屬於課程

使用 Keras 的進階深度學習

檢視課程

練習說明

  • keras.layers 匯入 InputDense 函式。
  • 建立形狀為 1 的輸入層。
  • 再次建立一個具有 1 個單元的 Dense 層,並將 input_tensor 直接傳入該層。

動手互動練習

試著完成這個範例程式碼,體驗一下這個練習。

# Load layers
____

# Input layer
input_tensor = ____(shape=(____,))

# Create a dense layer and connect the dense layer to the input_tensor in one step
# Note that we did this in 2 steps in the previous exercise, but are doing it in one step now
output_tensor = ____(____)(____)
編輯並執行程式碼