OpenViSTAI · Agents · Blockchain · Crypto
Menu
AI Developer Tools & SDKs

Sonnet

Sonnet is an Apache-2.0 Python library built on TensorFlow 2 that provides composable abstractions for constructing neural networks and machine-learning research models.

Independent OpenViST project profile, based on linked sources.

Sonnet — OpenViST project profile in AI Developer Tools & SDKs.
OpenViST project illustration. See the linked sources for product details.
Understand the project

Practical overview

When it fits

Use Sonnet when a TensorFlow 2 project needs modular neural-network components and flexibility over the training framework, rather than a prescriptive end-to-end training stack.

Who it is for

  • Python machine-learning researchers
  • TensorFlow developers building custom neural networks
  • Teams creating supervised, unsupervised or reinforcement-learning experiments

Documented uses

  • Compose neural networks from reusable built-in modules.
  • Define custom modules by subclassing `snt.Module`.
  • Prototype supervised and unsupervised learning models.
  • Assemble reinforcement-learning research models.
  • Access model variables for an externally selected optimizer or training system.
Before you choose

Requirements & limits

The repository is public, open source and licensed under Apache-2.0. The documented setup uses Python package installation with TensorFlow, TensorFlow Probability and dm-sonnet. Colab examples are provided for trying the library in a notebook environment.

  • Sonnet is centered on snt.Module, which supports nested modules, parameters and callable computations.
  • Built-in modules include linear, convolutional, batch-normalization and sequential components.
  • The library does not ship with a training framework, so the surrounding optimization and training workflow must come from the developer or another system.
  • Many parameters are created when a module is first called because their shapes depend on the input.
  • The repository includes examples for MNIST, GANs and distributed CIFAR-10 workflows.

Check current requirements in the official documentation. Source-based guidance does not mean OpenViST has run or independently tested this project.

Source-based practical guide

Install Sonnet and verify the Python environment

Set up the documented TensorFlow 2 and Sonnet dependencies, then check that both packages import and report versions.

Before you start

  • Python environment
  • TensorFlow 2
  • TensorFlow Probability
  • The dm-sonnet package

Steps

  1. Install TensorFlow and TensorFlow Probability with pip.

  2. Install the dm-sonnet package with pip.

  3. Import TensorFlow and Sonnet.

  4. Print the TensorFlow and Sonnet version values.

Expected outcome

The environment reports imported TensorFlow and Sonnet version values.

Guide limitations

  • This recipe verifies package installation and imports only; it does not train or deploy a model.
  • The source does not specify a supported Python version or hardware requirement.
Source-based practical guide

Compose an MLP from Sonnet modules

Define and call a simple multilayer perceptron using the documented Sonnet and TensorFlow pattern.

Before you start

  • Installed TensorFlow 2 and Sonnet
  • A Python program or notebook
  • An input tensor with the dimensions expected by the model

Steps

  1. Create an snt.Sequential containing snt.Linear(1024), tf.nn.relu and snt.Linear(10).

  2. Call the sequential module with a TensorFlow input tensor.

  3. Retrieve trainable_variables when the model parameters need to be passed to an optimizer.

Expected outcome

The composed module produces a logits tensor and exposes its trainable variables.

Guide limitations

  • Sonnet does not provide the training loop or optimizer workflow in this example.
  • Parameter creation commonly occurs on the first call, so input shape affects initialization.
Evidence and transparency

Sources & review

Source record details
Source availability
Active
Sources checked
2 October 2026
Original website title
google-deepmind/sonnet · Official homepage title · retained in its source language