Category: Developer Guide

  • Writing a training loop from scratch in TensorFlow

    Setup Introduction Keras provides default training and evaluation loops, fit() and evaluate(). Their usage is covered in the guide Training & evaluation with the built-in methods. If you want to customize the learning algorithm of your model while still leveraging the convenience of fit() (for instance, to train a GAN using fit()), you can subclass the Model class and implement your own train_step() method, which is…

  • Writing a training loop from scratch in JAX

    Setup Introduction Keras provides default training and evaluation loops, fit() and evaluate(). Their usage is covered in the guide Training & evaluation with the built-in methods. If you want to customize the learning algorithm of your model while still leveraging the convenience of fit() (for instance, to train a GAN using fit()), you can subclass the Model class and implement your own train_step() method, which is…

  • Customizing what happens in fit() with PyTorch

    Introduction When you’re doing supervised learning, you can use fit() and everything works smoothly. When you need to take control of every little detail, you can write your own training loop entirely from scratch. But what if you need a custom training algorithm, but you still want to benefit from the convenient features of fit(), such as callbacks,…

  • Customizing what happens in fit() with TensorFlow

    Introduction When you’re doing supervised learning, you can use fit() and everything works smoothly. When you need to take control of every little detail, you can write your own training loop entirely from scratch. But what if you need a custom training algorithm, but you still want to benefit from the convenient features of fit(), such as callbacks,…

  • Customizing what happens in fit() with JAX

    Introduction When you’re doing supervised learning, you can use fit() and everything works smoothly. When you need to take control of every little detail, you can write your own training loop entirely from scratch. But what if you need a custom training algorithm, but you still want to benefit from the convenient features of fit(), such as callbacks,…

  • Training & evaluation with the built-in methods

    Setup Introduction This guide covers training, evaluation, and prediction (inference) models when using built-in APIs for training & validation (such as Model.fit(), Model.evaluate() and Model.predict()). If you are interested in leveraging fit() while specifying your own training step function, see the guides on customizing what happens in fit(): If you are interested in writing your own training & evaluation loops from scratch,…

  • Making new layers and models via subclassing

    Introduction This guide will cover everything you need to know to build your own subclassed layers and models. In particular, you’ll learn about the following features: Let’s dive in. Setup The Layer class: the combination of state (weights) and some computation One of the central abstractions in Keras is the Layer class. A layer encapsulates both a state (the…

  • The Sequential model

    Setup When to use a Sequential model A Sequential model is appropriate for a plain stack of layers where each layer has exactly one input tensor and one output tensor. Schematically, the following Sequential model: is equivalent to this function: A Sequential model is not appropriate when: Creating a Sequential model You can create a Sequential model by passing a list of layers to…

  • The Functional API

    Setup Introduction The Keras functional API is a way to create models that are more flexible than the keras.Sequential API. The functional API can handle models with non-linear topology, shared layers, and even multiple inputs or outputs. The main idea is that a deep learning model is usually a directed acyclic graph (DAG) of layers. So the functional API…