【发布时间】:2023-03-10 16:54:01
【问题描述】:
我对 Stacked LSTM 模型感到困惑。 Lstm 有不同类型的应用程序。 例如,在图像中,显示了两种类型的 LSTM,机器翻译和视频分类。
我的模型如下。
def create_stack_lstm_model(units):
model = Sequential()
model.add(LSTM(units, activation='relu', return_sequences=True, input_shape=(n_steps, n_features)))
model.add(LSTM(units, activation='relu'))
model.add(Dense(n_features))
model.compile(optimizer='adam', loss='mse')
return model
stack_lstm_model = create_stack_lstm_model(100)
def fit_model(model):
early_stop = keras.callbacks.EarlyStopping(monitor = 'val_loss', patience = 10)
#history = model.fit(x,y,epochs = 200,validation_split = 0.2,batch_size = 1,shuffle = False,callbacks = [early_stop])
history = model.fit(x,y,epochs = 250)
return history
history_gru = fit_model(stack_lstm_model)
输入 x 的形状为 (1269, 4, 7)。 输入x和输出y的几个样本如下。
[[ 6 11 14 15 28 45 35]
[ 2 18 19 21 39 45 36]
[22 32 41 42 43 44 31]
[ 5 12 17 18 38 40 22]] [ 5 10 25 27 36 39 40]
[[ 2 18 19 21 39 45 36]
[22 32 41 42 43 44 31]
[ 5 12 17 18 38 40 22]
[ 5 10 25 27 36 39 40]] [ 5 13 25 27 40 44 2]
[[22 32 41 42 43 44 31]
[ 5 12 17 18 38 40 22]
[ 5 10 25 27 36 39 40]
[ 5 13 25 27 40 44 2]] [ 2 5 9 20 21 42 15]
[[ 5 12 17 18 38 40 22]
[ 5 10 25 27 36 39 40]
[ 5 13 25 27 40 44 2]
[ 2 5 9 20 21 42 15]] [ 4 16 21 26 31 37 24]
此实现属于机器翻译还是视频分类?
【问题讨论】:
-
你的问题是什么?
-
对不起,我编辑了我的帖子。
标签: python tensorflow keras lstm recurrent-neural-network