farizrahman4u / seq2seq

Sequence to Sequence Learning with Keras
GNU General Public License v2.0
3.17k stars 845 forks source link

Model.predict shape error #217

Open tudayakumar opened 6 years ago

tudayakumar commented 6 years ago

Hi, I am using simple seq2seq

X_train = np.array([[[ 0. , 0.4, 0. , 0.1, 1. ],[ 0. , 0.7, 0. , 0.7, 2. ],[ 0.8, 1. , 0.8, 0.9, 1. ],[ 0.8, 0.8, 0.1, 0.4, 2. ],[ 0.5, 0.5, -0.2, -0.2, 1. ],[ -0.1, -0.1, -0.2, -0.2, 1. ]], [[ 0. , 0.7, 0. , 0.7, 2. ],[ 0.8, 1. , 0.8, 0.9, 1. ],[ 0.8, 0.8, 0.1, 0.4, 2. ],[ 0.5, 0.5, -0.2, -0.2, 1. ],[ -0.1, -0.1, -0.2, -0.2, 1. ],[ 0. , 2.8, 0. , 2.5, 2. ]]]) y_train = np.array([[[ 0. , 0.2, 0. , 0.1, 10. ],[ 0. , 0. , -0.7, -0.4, 26. ],[ -0.3, -0.3, -1. , -1. , 16. ],[ -0.9, -0.9, -1. , -1. , 14. ],[ -0.8, 2. , -0.8, 1.7, 62. ],[ 1.8, 1.8, 1.7, 1.8, 12. ]], [[ 0.7, 0.7, 0. , 0.3, 2. ],[ 0.4, 0.4, -0.3, -0.3, 1. ],[ -0.2, -0.2, -0.3, -0.3, 1. ],[ -0.1, 2.7, -0.1, 2.4, 2. ],[ 2.5, 2.5, 2.4, 2.5, 1. ],[ 2.4, 3.5, 2.3, 3.3, 2. ]]]) X_train is a (2,6,5) y_train is (2,6,5) {For training I used (1400,6,5)
model = SimpleSeq2Seq(input_dim=5, hidden_dim=10, output_length=6, output_dim=5) model.compile(loss='mse', optimizer='rmsprop')

model.fit(X,Y,epochs=15)
I tried with

print(model.predict([[ 0.1, 1.2, 0. , 1. , 1. ], [ 0.9, 1.2, 0.5, 0.7, 3. ], [ 0.8, 0.8, -0.1, 0. , 3. ], [ -0.1, 0.1, -1. , -0.9, 0. ], [ -0.8, -0.5, -2.1, -1.3, 0. ], [ -1.2, -1. , -3.2, -3.1, 0. ]]))

I am getting this error "expected input_4 to have 3 dimensions, but got array with shape (6, 5)" please help.