# TensorFlow and Keras

> The Keras high-level API for fast model building with fit/evaluate, and the TensorFlow ecosystem for mobile and production deployment. Free notes, key...

Canonical: https://www.internhack.in/roadmaps/tracks/machine-learning/tensorflow-keras
Last updated: 2026-11-28

The Keras high-level API for fast model building with fit/evaluate, and the TensorFlow ecosystem for mobile and production deployment.

Intermediate · about 18 hours · difficulty 3/5

Learn first: [Debugging and Running Training Experiments](https://www.internhack.in/roadmaps/tracks/machine-learning/training-debugging)

Keras offers a concise, high-level way to build models: stack layers, `compile` with an optimizer and loss, call `fit`. It is a valid alternative if your team or target platform uses it. Keras 3 can also run on PyTorch or JAX backends.

### What to learn

- **Sequential and Functional APIs** for building models; subclassing for custom logic.
- `compile`, `fit`, `evaluate`, `predict`, and **callbacks** (early stopping, checkpoints, learning rate schedules).
- **tf.data** pipelines for efficient input loading.
- **GradientTape** for custom training loops.
- Saving in the `.keras` format; exporting for serving.

### Ecosystem

TensorFlow Lite (LiteRT) for mobile and edge devices, TensorFlow Serving and TFX for production pipelines, and TensorFlow.js in the browser.

### Trade-offs

Very quick to get started and strong deployment tooling, but most new research code and Hugging Face examples are PyTorch first.

**Good enough to move on** when you can build, train with callbacks and save a Keras model, and write one custom training step with GradientTape.

## Key concepts

- **Sequential and Functional APIs**
- **compile and fit**
- **Callbacks**
- **tf.data pipelines**
- **GradientTape custom loops**
- **TensorFlow Lite deployment**

## Other options for this step

- [PyTorch](https://www.internhack.in/roadmaps/tracks/machine-learning/pytorch): Tensors, autograd, nn.Module, Dataset/DataLoader and the explicit training loop, the most widely used framework in research and much of industry.
- [JAX](https://www.internhack.in/roadmaps/tracks/machine-learning/jax): Composable function transformations (grad, jit, vmap) over NumPy-style code, popular for research and large-scale training on TPUs and GPUs.

## Mini project

Build a Keras image classifier for Fashion-MNIST with a tf.data pipeline, early stopping and checkpoint callbacks, then convert it to TensorFlow Lite and check the file size and accuracy.

## Check yourself

What does model.compile() configure, and why must it happen before fit()?

## Free resources

- [TensorFlow tutorials](https://www.tensorflow.org/tutorials) (TensorFlow)
- [Keras developer guides](https://keras.io/guides/) (Keras)

Previous: [PyTorch](https://www.internhack.in/roadmaps/tracks/machine-learning/pytorch) · Next: [JAX](https://www.internhack.in/roadmaps/tracks/machine-learning/jax)

## More in Deep Learning Frameworks and Hardware

- [PyTorch](https://www.internhack.in/roadmaps/tracks/machine-learning/pytorch)
- [TensorFlow and Keras](https://www.internhack.in/roadmaps/tracks/machine-learning/tensorflow-keras)
- [JAX](https://www.internhack.in/roadmaps/tracks/machine-learning/jax)
- [GPUs and Efficient Training](https://www.internhack.in/roadmaps/tracks/machine-learning/gpu-training)

## Related

- [Roadmaps](https://www.internhack.in/roadmaps)
- [Machine Learning Engineer Roadmap](https://www.internhack.in/roadmaps/tracks/machine-learning)
