正如我正在阅读 Keras Code for Sequential models我看到它只允许对 Sequential
中的任何定义层进行单个输出。模型。我知道如何使用功能 API( Model
类)来做到这一点。
但是,我不明白为什么 Sequential
模型仅限于具有单个输出的层。强制执行此类约束是否存在设计限制?
最佳答案
实际上不。在设计更小、更直接的神经网络时,序列模型可以让事情变得更简单。如前所述 here ,它们对大多数问题都有用。
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.
但如果您需要更复杂的设计,具有多个输入/输出以及共享层的模型,您可以使用 函数式API 以实现您的目标。
关于python - keras 序列模型中的多个输出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53679643/