Both Sequential APIs and Functional APIs are declarative
It means you start it by declaring which layers you want to use and how they should be connected, and only then can you start feeding the model some data for training or inference.
So advantages of having this:
- The model can easily be saved, cloned, and shared.
- Its structure can be displayed and analyzed.
- The framework can infer shapes and check types, so errors can be caught easily (i.e. before any data ever goes through the model).
- It's also fairly easy to debug since the whole model is a static graph of layers.
But the flip side is just that: it's static.
Some models involve loops, varying shapes, conditional branches, and other dynamic behavior.
For such cases, the Subclassing API is for you.
Source: Hands-On Machine Learning with Scikit-Learn, Keras & TensorFlow
No comments:
Post a Comment