What is the Functional API?
The Keras Functional API is a more flexible way to build models compared to the Sequential API. It allows you to create complex architectures with multiple inputs, outputs, and non-linear topologies.
Why use Functional API?
• Complex architectures - Multi-input/output models
• Shared layers - Reuse layers across different paths
• Non-linear topologies - Skip connections, branches
• Model subclassing - Custom training loops
💡 Key Insight:
Think of Sequential as a simple chain, and Functional API as a flexible graph where layers can connect in any way!
Sequential vs Functional
-
🔗 Simplicity
Sequential: Simple linear stack vs Functional: Flexible graph
-
🌊 Flexibility
Sequential: One input/output vs Functional: Multiple I/O
-
🏗️ Architecture
Sequential: Linear only vs Functional: Any topology
-
🔄 Layer Sharing
Sequential: No sharing vs Functional: Full sharing
🎯 When to Use Each:
Sequential: Simple feedforward networks
Functional: ResNet, Inception, multi-task learning