问题描述
我正在阅读序列模型的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.
但是,如果您需要更复杂的设计,具有多个输入/输出以及共享图层的模型,则可以使用 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顺序模型中的多个输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!