Learn what the Functional API is, and how to build complex keras models using it

Towards Data Science
Photo by Hunter Harritt on Unsplash

TensorFlow’s Sequential API helps the user to stack layers one on top of another, easily creating linear models, where the input of each layer is always the output of the previous one. But what happens when your model needs to handle multiple inputs or outputs, shared layers, or non-linear connections? In those scenarios, TensorFlow’s Functional API allows to build more advanced, flexible, and customizable models, giving the user the power to design the complex architectures mentioned above with ease.

This article will explain:

  • What the Functional API is
  • How to build a simple model with the Functional API

TensorFlow’s Functional API is a way to create models where layers are connected like a network graph, not just stacked linearly like in the Sequential API. Imagine building with LEGO bricks: while the Sequential API would just allow us to stack blocks one on top of another, the Functional API allows us to construct bridges, towers, and paths connecting different areas.