A high-level deep learning API abstracts parts of model construction, data pipelines, and training while leaving a lower-level framework underneath. Keras sits above TensorFlow, and fastai sits above PyTorch; both support more than tabular data. section 8.1 section 8.2.2
Choose the abstraction level according to the problem and the trade-offs you can accept:
- Keras keeps model details transparent but requires custom pipeline and layer code for tabular data. section 8.2.2
- fastai provides explicit tabular support, compact code, an automatically defined pipeline, and dataset-inspection conveniences. section 8.2.2
- Higher abstraction can speed development, but framework assumptions may create debugging problems; community size also affects production support. section 8.2.2
Airbnb NYC price classification
A tabular model can accept separate categorical, continuous, and text inputs and produce one prediction: whether an Airbnb listing price exceeds the median. A custom Keras model defines layers for each input type; the reported Keras accuracy is 70–74%, compared with about 81% for fastai. section 8.1 section 8.2.2
Table 8.1 Summary of the pros and cons of the Keras and fastai solutions (view table figure)
| Keras |
fastai |
|
|---|---|---|
| Pro |
Model details are transparent. Large community using the framework means that it’s easy to find solutions to common problems |
Framework includes explicit support for tabular data models, which means the code is much more compact. Framework automatically defines pipeline. Framework includes convenience functions that make it easy to examine the dataset. |
| Con |
No built-in support for tabular data, which means we need to define custom code to define the pipeline and layers for the model. |
Assumptions made by the framework can lead to tricky problems that are hard to debug. User community is smaller and less involved in deploying production applications than the Keras community, which means it can be harder to find solutions to problems. |
Compare Keras and fastai by transparency, tabular support, pipeline automation, debugging, and production-community support. section 8.2.2
