import tensorflow as tf
test = Sequential()
test.add(Dense(1024, input_dim=784, activation="relu", name="First"))
test.add(Dense(512, activation=tf.keras.layers.LeakyReLU(alpha=0.01), name="middle"))
test.add(Dense(1, activation='sigmoid', name="Last"))
test.compile(loss='binary_crossentropy', optimizer="adam")
print(test.summary())
输出:
Model: "sequential"
_________________________________________________________________
Layer (type) Output Shape Param #
=================================================================
First (Dense) (None, 1024) 803840
_________________________________________________________________
middle (Dense) (None, 512) 524800
_________________________________________________________________
Last (Dense) (None, 1) 513
=================================================================