Customizing Saving and Serialization

Author: Neel Kovelamudi

View on TensorFlow.org Run in Google Colab View source on GitHub View on keras.io

Introduction

This guide covers advanced methods that can be customized in Keras saving. For most users, the methods outlined in the primary Serialize, save, and export guide are sufficient.

APIs

We will cover the following APIs:

  • save_assets() and load_assets()
  • save_own_variables() and load_own_variables()
  • get_build_config() and build_from_config()
  • get_compile_config() and compile_from_config()

When restoring a model, these get executed in the following order:

  • build_from_config()
  • compile_from_config()
  • load_own_variables()
  • load_assets()

Setup

import os
import numpy as np
import tensorflow as tf
import keras

State saving customization

These methods determine how the state of your model's layers is saved when calling model.save(). You can override them to take full control of the state saving process.