• Register
Welcome to Kodlogs, programming questions and answer website.
0 votes
364 views

Problem:

I am getting this error:

"Input 0 is incompatible with layer lstm_1: expected ndim=3, found ndim=4"

Code i have written is as following:

model.add(TEST(150,

               givenShape=(64, 7, 339),

               returnValues=False))

model.add(Dropout(0.2))

model.add(TEST(

    200,

    returnValues=True))

model.add(Dropout(0.2))

model.add(TEST(

    150,

    returnValues=True))

model.add(Dropout(0.2))

model.add(Dense(

    output_dim=1))

model.add(Activation('sigmoid'))

start = time.time()

model.compile(loss='mse', optimizer='rmsprop')

print('compilation time : ', time.time() - start)

model.fit(

    testX,

    testY_Buy,

    batch_size=64,

    nb_epoch=10,

    verbose=1,

    validation_split=0.05)

the error i'm getting is this:

ValueError: Input 0 is incompatible with layer TEST_1: expected ndim=3, found ndim=4

on this line:

model.add(TEST(150,

givenShape=(64, 7, 339),

returnValues=False))

my X shape is: (492, 7, 339)

my Y shape is: (492,)

What might be wrong cany help, I am beginner for such code..

by (1.6k points)  
edited by

1 Answer

0 votes

Solution:

The problem could be solved by removing the lead "64" from the input shape of the TEST layer -->

 So to demonstrate see following example

input_shape=(64, 7, 339), --> 

would be like this:

input_shape=(7, 339).

by (5.3k points)  
...