neural-network - unable to add layer in keras
问题描述
I am trying to following this suggestion.
outputs = Conv2DTranspose(3, (1, 1), activation='sigmoid') (c9)
model = Model(inputs=[inputs], outputs=[outputs])
model = multi_gpu_model(model, gpus=8)
model.compile(optimizer='adam', loss = bce, metrics = [mean_iou])
model.add(Lambda(lambda x: K.batch_flatten(x)))
But at that last line of code, I receive the following error:
'Model' object has no attribute 'add'
I understand that since I didn't instantiate model as sequential()
as in linked post, the function add()
might not be available to me. However, I'm not sure how to work around this.
解决方案
Corrected to reflect the working solution:
outputs = Conv2DTranspose(3, (1, 1), activation='sigmoid') (c9)
outputs = Lambda(lambda x: K.batch_flatten(x))(outputs)
model = Model(inputs=[inputs], outputs=[outputs])
model = multi_gpu_model(model, gpus=8)
model.compile(optimizer='adam', loss = bce, metrics = [mean_iou])
推荐阅读
- amazon-s3 - Camel Kafka S3 源连接器,具有用于同一存储桶的多个连接器
- node.js - UnhandledPromiseRejectionWarning: MongoParseError: 无效的连接字符串
- c++11 - 将带有捕获列表的 C++ lambda 函数映射到函数参数
- python - 没有这样的文件或目录?
- batch-file - 批处理文件启动后立即关闭
- javascript - 在本机反应中使用静态是否有任何内存问题?
- javascript - 根据选择更改页面
- fortran - 如何在运行开始期间在各种选项中为子程序选择所需的代码
- c - 如何让线程崩溃不会导致进程崩溃?
- qt - 替换 qhash 值 no operator found 采用右手操作数类型