输入0与lstm_16层不兼容:预期ndim = 3,找到ndim = 2?

时间:2019-11-07 03:41:36

标签: python tensorflow keras lstm recurrent-neural-network

我收到错误std::getline并显示以下代码:

std::string line_of_code;
std::getline(std::cin, line_of_code);

X_train的尺寸为int number1; int number2; char op; std::istringstream input_stream(line_of_code); // Read in first number; input_stream >> number1; // Read in operator input_stream >> op; // Read in second number; input_stream >> number2; // Decide how to process the operator: int answer; switch (op) { case '*': answer = number1 * number2; break; case '/': answer = number1 / number2; break; case '+': answer = number1 + number2; break; case '-': answer = number1 - number1; break; } std::cout << "Result: " << answer << "\n"; (在我计算机Input 0 is incompatible with layer lstm_16: expected ndim=3, found ndim=2时产生)。为什么会出现此错误?

1 个答案:

答案 0 :(得分:0)

这里您要在第一个LSTM层的input_shape中传递两个值。

Keras LSTM的输入形状为(samples, time_steps, nfeatures),您的图层输入必须具有此形状。