簡體   English   中英

使用 Keras 使用 Python 進行深度學習的介紹部分

[英]Introduction part in Deep Learning with Keras using Python

問題指導:

  1. 實例化一個順序 model。
  2. 添加一個由 50 個神經元組成的密集層,輸入形狀為 1 個神經元。
  3. 添加兩個密集層,每個層有 50 個神經元和“relu”激活。
  4. 以具有單個神經元且無激活的 Dense 層結束 model。

下面是我的代碼:

# Instantiate a Sequential model
model = Sequential()

# Add a Dense layer with 50 neurons and an input of 1 neuron
model.add(Dense(50, input_shape=(2,), activation='relu'))

# Add two Dense layers with 50 neurons and relu activation
model.add(Dense(____,____=____))
model.____

# End your model with a Dense layer and no activation
model.____

我對這部分感到困惑

model.add(Dense(____,____=____))

model.add(Dense(___,___=___))中,您有三個空白。 第一個用於提及神經元的數量,第二個用於表示您想要設置一些activation值,第三個用於將該值設置為relu

所以你會得到model.add(Dense(50,activation='relu'))

更多信息可以在密集層文檔中找到。

文檔中,Dense 層唯一需要的參數是units ,即神經元的數量。 默認激活 function 是None ,所以如果你希望它是"relu" ,請執行activation="relu"

總之,這是一段代碼,它創建了一個具有 50 個神經元並激活為relu的 Dense 層:

model.add(Dense(50, activation="relu"))

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM