python - Keras 顺序模型在本地机器上工作,但 AWS 抛出关于层的错误
问题描述
我在 Keras 中设置了一个顺序模型
agent = keras.Sequential(
[
layers.Dense(100, activation="relu", name="layer1"),
layers.Dense(100, activation="relu", name="layer2"),
layers.Dense(22, name="output"),
]
)
尝试在 AWS 上运行它会给我以下错误:
Using TensorFlow backend.
Traceback (most recent call last):
File "single_player_keras_repeat_playthrough.py", line 30, in <module>
layers.Dense(22, name="output"),
File "/home/ubuntu/anaconda3/envs/tensorflow2_p36/lib/python3.6/site-packages/tensorflow_core/python/training/tracking/base.py", line 457, in _method_wrapper
result = method(self, *args, **kwargs)
File "/home/ubuntu/anaconda3/envs/tensorflow2_p36/lib/python3.6/site-packages/tensorflow_core/python/keras/engine/sequential.py", line 116, in __init__
self.add(layer)
File "/home/ubuntu/anaconda3/envs/tensorflow2_p36/lib/python3.6/site-packages/tensorflow_core/python/training/tracking/base.py", line 457, in _method_wrapper
result = method(self, *args, **kwargs)
File "/home/ubuntu/anaconda3/envs/tensorflow2_p36/lib/python3.6/site-packages/tensorflow_core/python/keras/engine/sequential.py", line 161, in add
'Found: ' + str(layer))
TypeError: The added layer must be an instance of class Layer. Found: <keras.layers.core.Dense object at 0x7fb3fac02518>
这段代码在我的本地机器上运行良好。我究竟做错了什么?
解决方案
推荐阅读
- powerbi - 在 Power BI 的矩阵表中用零替换空白
- android - Android Studio 中的 layout_marginTop
- python - 在 python 中训练测试拆分但考虑患者信息?
- mongodb - 使用 mongo 聚合查找两个间隔的最小/最大值
- excel - 从名称中查找具有多个值的excel
- go - Go 无法使用 go get 识别已安装的库
- python - 从python中的父文件夹导入
- java - 如何在 Spring Boot 中创建不可变和单例类?
- reactjs - InferableComponentEnhancerWithProps 类型缺少 Component 类型的以下属性
- asp.net - 文件的 ASP.NET 路由请求