In this tutorial, I show how to share neural network layer weights and define custom loss functions. The example code assumes beginner knowledge of Tensorflow 2 and the Keras API.

Motivating Problem

For a recent project, I wanted to use Tensorflow 2 / Keras to re-implement DeepKoopman, an autoencoder-based neural network architecture described in “Deep learning for universal linear embeddings of nonlinear dynamics”. My end goal was to create a user-friendly version that I could eventually extend

DeepKoopman embeds time series x onto data into a low-dimensional coordinate system y in which the dynamics are linear.

The DeepKoopman schematic shows that there are three main components:

  1. The encoder φ, which maps the input to the latent code
  2. The decoder φ-inverse, which reconstructs the input from the latent code
  3. The linear dynamics K, which describe how the latent code evolves over time

#tensorflow #machine-learning #python #neural-networks #keras

Shared Models and Custom Losses in Tensorflow 2 / Keras
1.40 GEEK