【发布时间】:2021-11-23 20:02:29
【问题描述】:
我对 keras 层的输出形状有点困惑。我创建了一个示例 keras 模型并显示了它的摘要。
numberOfLSTMcells=1
n_timesteps_in=129
n_features=61
inp =Input(shape=(n_timesteps_in, n_features))
lstm= LSTM(numberOfLSTMcells,return_sequences=True, return_state=False) (inp)
fc=Dense(64,activation='relu',name='hidden_layer')(lstm)
out=Dense(1,activation='sigmoid',name='last_layer')(fc)
model = Model(inputs=inp, outputs=out)
模型总结
Model: "model_1"
_________________________________________________________________
Layer (type) Output Shape Param #
=================================================================
input_3 (InputLayer) [(None, 129, 61)] 0
_________________________________________________________________
lstm_2 (LSTM) (None, 129, 1) 252
_________________________________________________________________
hidden_layer (Dense) (None, 129, 64) 128
_________________________________________________________________
last_layer (Dense) (None, 129, 1) 65
=================================================================
Total params: 445
Trainable params: 445
Non-trainable params: 0
我认为最后一层的形状应该是(None,64,1)。因为 hidden_layers 有 64 个神经元作为 last_layer 的输入
【问题讨论】:
标签: python tensorflow keras