首页 > 解决方案 > 为什么我会收到此“input_shape 错误”?(蟒蛇喀拉斯)

问题描述

Using TensorFlow backend.

WARNING:tensorflow:From /home/hjkim/.conda/envs/hjkim/lib/python3.7/site-packages/keras/backend/tensorflow_backend.py:64: The name tf.get_default_graph is deprecated. Please use tf.compat.v1.get_default_graph instead.

Traceback (most recent call last):
  File "lstm.py", line 51, in <module>
    model = lstm()
  File "lstm.py", line 22, in lstm
    model.add(Bidirectional(LSTM(400, input_shape = (None, ), return_sequences = True)))
  File "/home/hjkim/.conda/envs/hjkim/lib/python3.7/site-packages/keras/models.py", line 451, in add
    raise ValueError('The first layer in a '
ValueError: The first layer in a Sequential model must get an `input_shape` or `batch_input_shape` argument.

这是我得到的脚本,我知道最后一句话是错误的。但是,我认为我已经正确设置了我的 input_shape。

实际上,它在 keras 版本 2.3.1 上运行良好,但由于其他一些 ValueError 问题,我将其降级为 2.1.2。

我想解决这个问题,但我自己做不到..请有人帮助我。让我知道我错过了什么。

标签: pythonkeras

解决方案


推荐阅读