Keras LSTM input ValueError: Input 0 is incompatible with layer lstm_1: expected ndim=3, found ndim=4Understanding Keras LSTMsHow to change batch size of an intermediate layer in Keras?Keras LSTM ValueError: Input 0 is incompatible with layer lstm_24: expected ndim=3, found ndim=4Keras LSTM input incompatible with layer, expected ndim=3, found ndim=4Keras AttributeError: 'list' object has no attribute 'ndim'How to use Scikit Learn Wrapper around Keras Bi-directional LSTM ModelLSTM Nerual Network Input/Output dimensions errorIs it possible to train a CNN starting at an intermediate layer (in general and in Keras)?AttributeError: 'Sequential' object has no attribute '_feed_input_names' in Keras Theano'Sequential' object has no attribute 'loss' - When I used GridSearchCV to tuning my Keras model

Why is the Grievance Studies affair considered to be research requiring IRB approval?

What to do about my 1-month-old boy peeing through diapers?

How do Barton (Hawkeye/Ronin) and Romanov (Black Widow) end up on the Benatar on Morag in 2014?

Number of Fingers for a Math Oriented Race

Another "Ask One Question" Question

Which polygons can be turned inside out by a smooth deformation?

Spicing up a moment of peace

Why can't you say don't instead of won't?

Is there a way to tell what frequency I need a PWM to be?

What checks exist against overuse of presidential pardons in the USA?

Why does a sticker slowly peel off, but if it is pulled quickly it tears?

Defending Castle from Zombies

Is this position a forced win for Black after move 14?

Fantasy Macro Economics: What would Merfolk trade for?

Is it unusual for a math department not to have a mail/web server?

Why Can't A Name Be Written Literally In Japanese?

Why did Lucius make a deal out of Buckbeak hurting Draco but not about Draco being turned into a ferret?

Why did Starhopper's exhaust plume become brighter just before landing?

In how many ways we can distribute 7 distinct balls among 3 students such that everyone gets at least 2 balls?

Count the number of triangles

Are sweatpants frowned upon on flights?

Stolen MacBook should I worry about my data?

Find feasible point in polynomial time in linear programming

Did ancient peoples ever hide their treasure behind puzzles?



Keras LSTM input ValueError: Input 0 is incompatible with layer lstm_1: expected ndim=3, found ndim=4


Understanding Keras LSTMsHow to change batch size of an intermediate layer in Keras?Keras LSTM ValueError: Input 0 is incompatible with layer lstm_24: expected ndim=3, found ndim=4Keras LSTM input incompatible with layer, expected ndim=3, found ndim=4Keras AttributeError: 'list' object has no attribute 'ndim'How to use Scikit Learn Wrapper around Keras Bi-directional LSTM ModelLSTM Nerual Network Input/Output dimensions errorIs it possible to train a CNN starting at an intermediate layer (in general and in Keras)?AttributeError: 'Sequential' object has no attribute '_feed_input_names' in Keras Theano'Sequential' object has no attribute 'loss' - When I used GridSearchCV to tuning my Keras model






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








1















When I run my code I get this error:
ValueError: Input 0 is incompatible with layer lstm_1: expected ndim=3, found ndim=4



def keras_experiment(true_examples,true_labels):
# print len(true_examples[1])
x_train = np.array(true_examples[:700])
y_train = np.array(true_labels[:700])
x_test = np.array(true_examples[700:])
y_test = np.array(true_labels[700:])

from keras.models import Sequential
from keras.layers import LSTM, Dense
print x_train[0]
data_dim = 378
timesteps = 7
num_classes = 2

# expected input data shape: (batch_size, timesteps, data_dim)
model = Sequential()
model.add(LSTM(32, return_sequences=False,
input_shape=(timesteps, data_dim))) # returns a sequence of vectors of dimension 32
model.add(Dense(10, activation='softmax'))

model.compile(loss='categorical_crossentropy',
optimizer='rmsprop',
metrics=['accuracy'])

model.fit(x_train[0], y_train[0],
batch_size=64, epochs=5,
validation_data=(x_test, y_test))

score = model.evaluate(x_test, y_test, batch_size=16)
print score


Here is the result of print x_train[0]:



[[0.82183125 0.45548045 0.86122581 ... 3.16044199 1.43419966 0.45379718]
[0.84371381 0.47813553 0.83602898 ... 2.64684385 1.58629507 0.5993157 ]
[0.72253171 0.42504681 0.88999478 ... 2.09510967 1.87146875 0.89325575]
...
[0.79126543 0.45734966 0.85694022 ... 2.68172079 1.54250728 0.57519309]
[0.79846062 0.41452213 0.72903777 ... 2.492895 1.53964412 0.6176129 ]
[0.8246961 0.39966809 0.52778689 ... 2.02451504 1.42316496 0.70296586]]


So it looks like what I think it should, a list of 700 examples, which are lists of 7 timesteps, which are lists of 378 features










share|improve this question


























  • Hello and welcome to Stack Overflow. What is your question exactly? Please take a moment to review the following how-to resources: How to Ask and Complete Examples

    – Pedro Rodrigues
    Mar 27 at 21:22











  • I think it's pretty clearly stated: running the function gets the following error -- ValueError: Input 0 is incompatible with layer lstm_1: expected ndim=3, found ndim=4 but I don't understand why. Can anyone help me understand the error?

    – Ethan Hartzell
    Mar 28 at 13:56


















1















When I run my code I get this error:
ValueError: Input 0 is incompatible with layer lstm_1: expected ndim=3, found ndim=4



def keras_experiment(true_examples,true_labels):
# print len(true_examples[1])
x_train = np.array(true_examples[:700])
y_train = np.array(true_labels[:700])
x_test = np.array(true_examples[700:])
y_test = np.array(true_labels[700:])

from keras.models import Sequential
from keras.layers import LSTM, Dense
print x_train[0]
data_dim = 378
timesteps = 7
num_classes = 2

# expected input data shape: (batch_size, timesteps, data_dim)
model = Sequential()
model.add(LSTM(32, return_sequences=False,
input_shape=(timesteps, data_dim))) # returns a sequence of vectors of dimension 32
model.add(Dense(10, activation='softmax'))

model.compile(loss='categorical_crossentropy',
optimizer='rmsprop',
metrics=['accuracy'])

model.fit(x_train[0], y_train[0],
batch_size=64, epochs=5,
validation_data=(x_test, y_test))

score = model.evaluate(x_test, y_test, batch_size=16)
print score


Here is the result of print x_train[0]:



[[0.82183125 0.45548045 0.86122581 ... 3.16044199 1.43419966 0.45379718]
[0.84371381 0.47813553 0.83602898 ... 2.64684385 1.58629507 0.5993157 ]
[0.72253171 0.42504681 0.88999478 ... 2.09510967 1.87146875 0.89325575]
...
[0.79126543 0.45734966 0.85694022 ... 2.68172079 1.54250728 0.57519309]
[0.79846062 0.41452213 0.72903777 ... 2.492895 1.53964412 0.6176129 ]
[0.8246961 0.39966809 0.52778689 ... 2.02451504 1.42316496 0.70296586]]


So it looks like what I think it should, a list of 700 examples, which are lists of 7 timesteps, which are lists of 378 features










share|improve this question


























  • Hello and welcome to Stack Overflow. What is your question exactly? Please take a moment to review the following how-to resources: How to Ask and Complete Examples

    – Pedro Rodrigues
    Mar 27 at 21:22











  • I think it's pretty clearly stated: running the function gets the following error -- ValueError: Input 0 is incompatible with layer lstm_1: expected ndim=3, found ndim=4 but I don't understand why. Can anyone help me understand the error?

    – Ethan Hartzell
    Mar 28 at 13:56














1












1








1


1






When I run my code I get this error:
ValueError: Input 0 is incompatible with layer lstm_1: expected ndim=3, found ndim=4



def keras_experiment(true_examples,true_labels):
# print len(true_examples[1])
x_train = np.array(true_examples[:700])
y_train = np.array(true_labels[:700])
x_test = np.array(true_examples[700:])
y_test = np.array(true_labels[700:])

from keras.models import Sequential
from keras.layers import LSTM, Dense
print x_train[0]
data_dim = 378
timesteps = 7
num_classes = 2

# expected input data shape: (batch_size, timesteps, data_dim)
model = Sequential()
model.add(LSTM(32, return_sequences=False,
input_shape=(timesteps, data_dim))) # returns a sequence of vectors of dimension 32
model.add(Dense(10, activation='softmax'))

model.compile(loss='categorical_crossentropy',
optimizer='rmsprop',
metrics=['accuracy'])

model.fit(x_train[0], y_train[0],
batch_size=64, epochs=5,
validation_data=(x_test, y_test))

score = model.evaluate(x_test, y_test, batch_size=16)
print score


Here is the result of print x_train[0]:



[[0.82183125 0.45548045 0.86122581 ... 3.16044199 1.43419966 0.45379718]
[0.84371381 0.47813553 0.83602898 ... 2.64684385 1.58629507 0.5993157 ]
[0.72253171 0.42504681 0.88999478 ... 2.09510967 1.87146875 0.89325575]
...
[0.79126543 0.45734966 0.85694022 ... 2.68172079 1.54250728 0.57519309]
[0.79846062 0.41452213 0.72903777 ... 2.492895 1.53964412 0.6176129 ]
[0.8246961 0.39966809 0.52778689 ... 2.02451504 1.42316496 0.70296586]]


So it looks like what I think it should, a list of 700 examples, which are lists of 7 timesteps, which are lists of 378 features










share|improve this question
















When I run my code I get this error:
ValueError: Input 0 is incompatible with layer lstm_1: expected ndim=3, found ndim=4



def keras_experiment(true_examples,true_labels):
# print len(true_examples[1])
x_train = np.array(true_examples[:700])
y_train = np.array(true_labels[:700])
x_test = np.array(true_examples[700:])
y_test = np.array(true_labels[700:])

from keras.models import Sequential
from keras.layers import LSTM, Dense
print x_train[0]
data_dim = 378
timesteps = 7
num_classes = 2

# expected input data shape: (batch_size, timesteps, data_dim)
model = Sequential()
model.add(LSTM(32, return_sequences=False,
input_shape=(timesteps, data_dim))) # returns a sequence of vectors of dimension 32
model.add(Dense(10, activation='softmax'))

model.compile(loss='categorical_crossentropy',
optimizer='rmsprop',
metrics=['accuracy'])

model.fit(x_train[0], y_train[0],
batch_size=64, epochs=5,
validation_data=(x_test, y_test))

score = model.evaluate(x_test, y_test, batch_size=16)
print score


Here is the result of print x_train[0]:



[[0.82183125 0.45548045 0.86122581 ... 3.16044199 1.43419966 0.45379718]
[0.84371381 0.47813553 0.83602898 ... 2.64684385 1.58629507 0.5993157 ]
[0.72253171 0.42504681 0.88999478 ... 2.09510967 1.87146875 0.89325575]
...
[0.79126543 0.45734966 0.85694022 ... 2.68172079 1.54250728 0.57519309]
[0.79846062 0.41452213 0.72903777 ... 2.492895 1.53964412 0.6176129 ]
[0.8246961 0.39966809 0.52778689 ... 2.02451504 1.42316496 0.70296586]]


So it looks like what I think it should, a list of 700 examples, which are lists of 7 timesteps, which are lists of 378 features







python input keras lstm






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 28 at 19:17







Ethan Hartzell

















asked Mar 27 at 21:16









Ethan HartzellEthan Hartzell

62 bronze badges




62 bronze badges















  • Hello and welcome to Stack Overflow. What is your question exactly? Please take a moment to review the following how-to resources: How to Ask and Complete Examples

    – Pedro Rodrigues
    Mar 27 at 21:22











  • I think it's pretty clearly stated: running the function gets the following error -- ValueError: Input 0 is incompatible with layer lstm_1: expected ndim=3, found ndim=4 but I don't understand why. Can anyone help me understand the error?

    – Ethan Hartzell
    Mar 28 at 13:56


















  • Hello and welcome to Stack Overflow. What is your question exactly? Please take a moment to review the following how-to resources: How to Ask and Complete Examples

    – Pedro Rodrigues
    Mar 27 at 21:22











  • I think it's pretty clearly stated: running the function gets the following error -- ValueError: Input 0 is incompatible with layer lstm_1: expected ndim=3, found ndim=4 but I don't understand why. Can anyone help me understand the error?

    – Ethan Hartzell
    Mar 28 at 13:56

















Hello and welcome to Stack Overflow. What is your question exactly? Please take a moment to review the following how-to resources: How to Ask and Complete Examples

– Pedro Rodrigues
Mar 27 at 21:22





Hello and welcome to Stack Overflow. What is your question exactly? Please take a moment to review the following how-to resources: How to Ask and Complete Examples

– Pedro Rodrigues
Mar 27 at 21:22













I think it's pretty clearly stated: running the function gets the following error -- ValueError: Input 0 is incompatible with layer lstm_1: expected ndim=3, found ndim=4 but I don't understand why. Can anyone help me understand the error?

– Ethan Hartzell
Mar 28 at 13:56






I think it's pretty clearly stated: running the function gets the following error -- ValueError: Input 0 is incompatible with layer lstm_1: expected ndim=3, found ndim=4 but I don't understand why. Can anyone help me understand the error?

– Ethan Hartzell
Mar 28 at 13:56













0






active

oldest

votes










Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55386580%2fkeras-lstm-input-valueerror-input-0-is-incompatible-with-layer-lstm-1-expected%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes




Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.







Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.



















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55386580%2fkeras-lstm-input-valueerror-input-0-is-incompatible-with-layer-lstm-1-expected%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현