【发布时间】:2021-04-21 11:22:37
【问题描述】:
我制作了一个 Keras LSTM 模型。但我的问题是,我的 input_shape [800, 200, 48] 我预测输出形状为 [800, 200, 48]。
我只需要预测没有任何序列的 800x48 标签。
输入:800 个样本,200 个时间步长,每个时间步长 48 个特征
需要的输出是:800 个样本,每个 time_step 48 个特征
希望有人能解决这个问题!
代码:
from keras.models import Sequential
from keras.layers import Dense, LSTM
from keras.layers import Dropout
model = Sequential()
def addInputLayer(units, shape, dropout):
model.add(LSTM(input_shape=shape, units=units, use_bias=True, unit_forget_bias=True, return_sequences=True))
model.add(Dropout(dropout))
def addHiddenLayer(anz, units, dropout):
for i in range(anz):
model.add(LSTM(units=units, use_bias=True, unit_forget_bias=True, return_sequences=True))
model.add(Dropout(dropout))
def addOutputLayer(units):
model.add(Dense(units=units))
def compLstm(optimizer, loss_function):
model.compile(optimizer=optimizer, loss=loss_function)
def konfigure(feature, label, epochs, validationFeature, validationLabel, batch_size):
history = model.fit(feature, label, epochs=epochs, validation_data=(validationFeature, validationLabel), batch_size=batch_size, verbose=2)
return history
def predict(test):
predictions = model.predict(test)
return predictions
【问题讨论】:
标签: python tensorflow keras lstm tensorflow2.0