python - 为什么我会收到此“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。
我想解决这个问题,但我自己做不到..请有人帮助我。让我知道我错过了什么。
解决方案
推荐阅读
- scala - Gatling - 在一个场景中动态创建和添加键值对,并将该映射传递给下一个场景
- java - 如何从地图内带有if条件的流中获取计数?
- wso2 - 如何将证书附加给用户,以便在 wso2 5.11.0 中使用多因素身份验证没有问题?
- julia - 无法在 Rmarkdown 中执行 julia 块
- rust - 如何使用标签从严格的 serde_json 反序列化访问字段
- javascript - 如何在 if 语句中使用函数?
- mysql - Hibernate 中的 NullPointerException
- visual-studio - 打开 VS 2019 时出现错误“System.ArgumentException:值不在预期范围内”
- javascript - 错误:重新渲染过多。React 限制了渲染的数量以防止无限循环。- 反应
- python - 通过从文件中读取 sql 语句来执行 python 脚本 - Teradata