model = Sequential() model.add(Dense(units=32, activation='relu', input_dim=5)) model.add(Dense(units=16, activation='relu')) model.add(Dense(units=8, activation='relu')) model.add(Dense(units=16, activation='sigmoid')) model.summary()
时间: 2024-01-07 11:03:15 浏览: 131
Keras中的两种模型:Sequential和Model用法
这是一个基于Keras的神经网络模型的定义和摘要。模型包含了4个密集连接层(Dense)。第一个层有32个隐藏单元,激活函数为ReLU,输入维度为5。第二个和第三个层都有16个隐藏单元,激活函数为ReLU。最后一个层有16个隐藏单元,激活函数为Sigmoid。
以下是模型的摘要信息:
```
Model: "sequential"
_________________________________________________________________
Layer (type) Output Shape Param #
=================================================================
dense (Dense) (None, 32) 192
_________________________________________________________________
dense_1 (Dense) (None, 16) 528
_________________________________________________________________
dense_2 (Dense) (None, 8) 136
_________________________________________________________________
dense_3 (Dense) (None, 16) 144
=================================================================
Total params: 1,000
Trainable params: 1,000
Non-trainable params: 0
_________________________________________________________________
```
阅读全文