python - “密集”对象没有属性“操作”
问题描述
我正在尝试使用 tensorflow.keras 制作一个完全连接的模型,这是我的代码
from tensorflow.keras.models import Model
from tensorflow.keras.layers import Input, Dense, Flatten
def load_model(input_shape):
input = Input(shape = input_shape)
dense_shape = input_shape[0]
x = Flatten()(input)
x = Dense(dense_shape, activation='relu')(x)
x = Dense(dense_shape, activation='relu')(x)
x = Dense(dense_shape, activation='relu')(x)
x = Dense(dense_shape, activation='relu')(x)
x = Dense(dense_shape, activation='relu')(x)
output = Dense(10, activation='softmax')
model = Model(input , output)
model.summary()
return model
但是当我调用模型时
model = load_model((120,))
我有这个错误
'Dense' object has no attribute 'op'
我怎样才能解决这个问题?
解决方案
您(x)
在输出层之后丢失了。尝试
output = Dense(10 , activation = 'softmax')(x)
推荐阅读
- sql - 使用 Excel VBA 将表从 SQL 导入 Access
- android - 你想终止进程'app' - Android Studio
- three.js - 导入到three.js时出现gltf问题
- java - 无法解决:android studio 中的 coordinatorlayout-1.0.0
- php - 为什么 Laravel 不让我创建一个新的应用程序?
- javascript - react-native 如何在文件上传时显示活动指示器
- php - 为什么mysql客户端在连接远程服务器时出现“无法通过套接字'/var/mysql/mysql.sock'连接到本地MySQL服务器”?
- python-3.x - 重新 - 负前瞻是否受先前空格数量的影响?
- r - 如何使用过滤功能为 geom_bar 设置动画以“添加数据”?
- python - 如何使用 Python 遍历 excel 中的列和行?