keras顺序模型中的多个输出 [英] Multiple outputs in keras Sequential models

查看:207
本文介绍了keras顺序模型中的多个输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在阅读序列模型的Keras代码我看到它只允许Sequential模型中任何已定义层的单个输出.我知道如何使用功能性API(Model类)执行此操作.

As I am reading the Keras Code for Sequential models I see that it only allows for a single output for any defined layer within the Sequential model. I am aware how to do this using the functional API (Model class).

但是,我不明白为什么Sequential模型仅限于具有单个输出的图层.强制执行此类约束是否存在设计限制?

However, I don't see why the Sequential model is limited to layers with a single output. Is there a design limitation for enforcing such constraint?

推荐答案

实际上不是.在设计更小巧而直接的神经网络时,顺序模型可以使事情变得更简单.如此处所述,它们对于大多数问题很有用.

Not actually. Sequential model is here to make things simpler, when designing smaller and straight-forward Neural Networks. As noted here, they can be useful for most problems.

顺序API 允许您为大多数情况逐层创建模型 问题.它的局限性在于它不允许您创建模型 共享图层或具有多个输入或输出.

The Sequential API allows you to create models layer-by-layer for most problems. It is limited in that it does not allow you to create models that share layers or have multiple inputs or outputs.

但是,如果您需要更复杂的设计,具有多个输入/输出以及共享图层的模型,则可以使用 Functional API 来实现您的目标.

But if you need more complex design, with multiple input/output as well as models that share layers, you can use the Functional API to achieve your goal.

这篇关于keras顺序模型中的多个输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆