我已经实现了以下LSTM架构。我特灵训练它来预测数字序列,但当我测试它不工作。我认为我给出了错误的输入和错误的测试数据。
import numpy as np
import tensorflow as tf
import keras
from keras.models import Sequential
from keras.layers import LSTM,Dense
X_train = np.array([
[[1, 2, 3], [4, 5, 6], [7, 8, 9]],
[[10, 11, 12], [13, 14, 15], [16, 17, 18]],
])
y_train = np.array([
[4, 5, 6],
[13, 14, 15],
])
#X_train = X_train.reshape((X_train.shape[0], 5, 5))
model = keras.Sequential()
model.add(keras.layers.LSTM(3,input_shape =(3, 3))) #### The input_shape has to correspond to the input data
model.compile(loss="mean_squared_error", optimizer="adam")
model.fit(X_train, y_train, epochs=100)
X_new = np.array([[1,2,3]])
X_new = np.reshape(X_new, (1,3))
y_pred = model.predict(X_new)
print(y_pred)
有人能给予我正确的输入数据和测试数据来训练这个架构吗?
1条答案
按热度按时间von4xj4u1#
为问题设置输入和输出大小的一种方法如下(不一定是唯一的方法):