Keras 深度學習入門
Miguel Esteban
Data Scientist & Founder






from tensorflow.keras.models import Sequentialfrom tensorflow.keras.layers import Dense# 建立新的順序式模型 model = Sequential()# 加入輸入層與全連接層 model.add(Dense(2, input_shape=(3,)))# 加入最後 1 個神經元的層 model.add(Dense(1))

from tensorflow.keras.models import Sequentialfrom tensorflow.keras.layers import Dense# 建立新的順序式模型 model = Sequential()# 加入輸入層與全連接層 model.add(Dense(2, input_shape=(3,)))# 加入最後 1 個神經元的層 model.add(Dense(1))

from tensorflow.keras.models import Sequentialfrom tensorflow.keras.layers import Dense# 建立新的順序式模型 model = Sequential()# 加入輸入層與全連接層 model.add(Dense(2, input_shape=(3,), activation="relu"))# 加入最後 1 個神經元的層 model.add(Dense(1))

model.summary()
Layer (type) Output Shape Param #
=================================================================
dense_3 (Dense) (None, 2) 8
_________________________________________________________________
dense_4 (Dense) (None, 1) 3
=================================================================
Total params: 11
Trainable params: 11
Non-trainable params: 0
_________________________________________________________________


model.summary()
Layer (type) Output Shape Param #
=================================================================
dense_3 (Dense) (None, 2) --> 8 <--
_________________________________________________________________
dense_4 (Dense) (None, 1) 3
=================================================================
Total params: 11
Trainable params: 11
Non-trainable params: 0
_________________________________________________________________
Keras 深度學習入門