ดังนั้นฉันจึงมีลำดับของเวกเตอร์ 2 มิติที่สร้างรูปแบบ ฉันต้องการทำนายว่าลำดับจะดำเนินต่อไปอย่างไร ฉันมีอาร์เรย์ start_xy ที่ประกอบด้วยอาร์เรย์ตามลำดับ start_x และ start_y: เช่น [1, 2.4, 3.8] และเหมือนกันสำหรับ end_xy
ฉันต้องการฝึกโมเดลให้เป็นโมเดลการทำนายลำดับ:
import numpy as np
import pickle
import keras
from keras.models import Sequential
from keras.layers import LSTM, Dense
from keras.callbacks import ModelCheckpoint
import training_data_generator
tdg = training_data_generator.training_data_generator(500)
trainingdata = tdg.produceTrainingSequences()
print("Printing DATA!:")
start_xy =[]
end_xy =[]
for batch in trainingdata:
for pattern in batch:
order = 1
for sequence in pattern:
start = [order,sequence[0],sequence[1]]
start_xy.append(start)
end = [order,sequence[2],sequence[3]]
end_xy.append(end)
order = order +1
model = Sequential()
model.add(LSTM(64, return_sequences=False, input_shape=(2,len(start_xy))))
model.add(Dense(2, activation='relu'))
model.compile(loss='mse', optimizer='adam')
model.fit(start_xy,end_xy,batch_size=len(start_xy), epochs=5000, verbose=2)
แต่ฉันได้รับข้อความแสดงข้อผิดพลาด:
ValueError: Input 0 of layer sequential is incompatible with the layer: expected ndim=3, found ndim=2. Full shape received: [320, 3]
ฉันสงสัยว่าฉันต้องปรับรูปแบบอินพุตของฉันใหม่ แต่ฉันยังไม่เข้าใจวิธีการ ฉันจะทำให้งานนี้สำเร็จได้อย่างไร? ฉันทำสิ่งนี้ถูกวิธีหรือยัง?