Skip to content
TensorFlow-based neural network library
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.
docs Remove experimental references from documentation. Apr 11, 2019
sonnet Bump version to 1.32 and add final changes to changelog. Apr 12, 2019
.gitignore Initial commit. Apr 6, 2017
BUILD Internal refactor Mar 27, 2019 Bump version to 1.32 and add final changes to changelog. Apr 12, 2019
LICENSE Initial commit. Apr 6, 2017 Initial commit. Apr 6, 2017 Add hyperlinks to documentation. Jan 29, 2019
WORKSPACE Update protobuf dependency. Feb 4, 2019 Bump version to 1.32 and add final changes to changelog. Apr 12, 2019


Sonnet is a library built on top of TensorFlow for building complex neural networks.


Sonnet can be installed from pip, with or without GPU support.

This installation is compatible with Linux/Mac OS X and Python 2.7 and 3.{4,5,6}. The version of TensorFlow installed must be >= 1.5. Installing Sonnet supports the virtualenv installation mode of TensorFlow, as well as the native pip install.

To install sonnet, run:

$ pip install dm-sonnet

Sonnet will work with both the CPU and GPU version of tensorflow, but to allow for that it does not list Tensorflow as a requirement, so you need to install Tensorflow separately if you haven't already done so.

Usage Example

The following code constructs a Linear module and connects it to multiple inputs. The variables (i.e., the weights and biases of the linear transformation) are automatically shared.

import sonnet as snt

# Provide your own functions to generate data Tensors.
train_data = get_training_data()
test_data = get_test_data()

# Construct the module, providing any configuration necessary.
linear_regression_module = snt.Linear(output_size=FLAGS.output_size)

# Connect the module to some inputs, any number of times.
train_predictions = linear_regression_module(train_data)
test_predictions = linear_regression_module(test_data)


Check out the full documentation page here.

You can’t perform that action at this time.