Skip to content
Back to skills

Sonnet

ASecurity

"Use DeepMind Sonnet for TensorFlow 2 modules, layers, training

  • 247 stars
  • 0 votes
  • 0 copies
  • 4 views
  • Added September 9, 2026
developmentpythonbashapibackend

Works with

  • api

Security analysis

A96/100
  • mediumInstalls packages at runtime which could introduce malicious dependencies

Pro scans all 20 files and shows the line behind each finding

Scanned September 9, 2026

npx -y skills add VectorSpaceLab/AREX-Skill --skill sonnet --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Sonnet?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Sonnet
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/vectorspacelab-sonnet/badge)](https://www.skillsdirectory.com/skills/vectorspacelab-sonnet)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: sonnet
description: "Use DeepMind Sonnet for TensorFlow 2 modules, layers, training
  loops, functional transforms, serialization, and distribution workflows."
disable-model-invocation: true
metadata:
  disco-role: operating
license: Apache 2.0
---

# Sonnet Repo Skill

Use this repo skill when a task involves DeepMind Sonnet (`dm-sonnet`, imported
as `sonnet` or `snt`) for TensorFlow 2 neural-network research code: custom
modules, built-in layers and nets, manual training loops, RNNs, functional
transforms, checkpoints, SavedModel export, mixed precision, or TensorFlow
distribution helpers.

Sonnet is intentionally small and unopinionated. It provides composable
`Module` objects, built-in module families, and optimizers, but it does **not**
provide a full training framework, dataset pipeline, experiment runner, or
serving stack.

## Quick install and import check

```bash
python -m pip install tensorflow dm-sonnet
```

```python
import tensorflow as tf
import sonnet as snt
print("TensorFlow", tf.__version__)
print("Sonnet", snt.__version__)
print(snt.nets.MLP([16, 4])(tf.ones([2, 8])).shape)
```

Run [scripts/check_sonnet_install.py](scripts/check_sonnet_install.py) when you
need a no-download smoke check for importability, device visibility, lazy
variables, a tiny optimizer step, and basic RNN construction.

## Route by task

| If the task asks about... | Read this sub-skill | Why |
| --- | --- | --- |
| Custom `snt.Module` classes, `@snt.once`, lazy variables, names, `Sequential`, `Deferred`, `BatchApply`, or `snt.build` | [sub-skills/module-authoring/SKILL.md](sub-skills/module-authoring/SKILL.md) | Owns Sonnet's core module programming model and composition contracts. |
| Built-in layers, normalization, initializers, metrics, regularizers, `snt.nets.MLP`, ResNet, Cifar10ConvNet, or VQ-VAE modules | [sub-skills/layers-and-nets/SKILL.md](sub-skills/layers-and-nets/SKILL.md) | Owns constructor signatures, shape rules, state behavior, and layer/net smoke checks. |
| `tf.GradientTape` training loops, `snt.optimizers.*`, `optimizer.apply`, tiny local training checks, or metric accumulation | [sub-skills/training-and-optimization/SKILL.md](sub-skills/training-and-optimization/SKILL.md) | Owns object-oriented Sonnet optimization and safe training-loop recipes. |
| `RNNCore`, `LSTM`, `GRU`, `DeepRNN`, `dynamic_unroll`, `static_unroll`, trainable state, or ConvLSTM | [sub-skills/sequence-and-rnn/SKILL.md](sub-skills/sequence-and-rnn/SKILL.md) | Owns sequence shape/state conventions and recurrent troubleshooting. |
| `snt.functional.variables`, `transform`, `transform_with_state`, `grad`, `value_and_grad`, `jit`, `device_put/get`, or functional optimizers | [sub-skills/functional-transforms/SKILL.md](sub-skills/functional-transforms/SKILL.md) | Owns Sonnet's TensorFlow-based Haiku/JAX-like functional API. |
| TensorFlow checkpoints, SavedModel export/load, Keras/pickle caveats, XLA, mixed precision, `snt.distribute.Replicator`, TPU, or cross-replica BatchNorm | [sub-skills/serialization-and-distribution/SKILL.md](sub-skills/serialization-and-distribution/SKILL.md) | Owns persistence, export, distribution, and backend limitations. |

## Root references

- [references/package-overview.md](references/package-overview.md) summarizes
  Sonnet's public package mental model, dependencies, public imports, and common
  workflow boundaries.
- [references/troubleshooting.md](references/troubleshooting.md) covers
  cross-cutting install/import, TensorFlow backend, and public-API routing
  failures before you enter a sub-skill-specific troubleshooting file.
- [references/repo-provenance.md](references/repo-provenance.md) records the
  source snapshot used to build this skill.
- [references/repo-routing-metadata.json](references/repo-routing-metadata.json)
  is structured routing metadata consumed by the managed repo-skill importer.

## Operating checklist

1. Import public symbols from `sonnet` (`import sonnet as snt`), not private
   implementation modules.
2. Build modules once with representative inputs before inspecting variables,
   exporting, or passing parameters to optimizers.
3. Assert small shapes at module boundaries: final feature dimension for
   `Linear`, channel dimension for convolution/normalization, and time-major
   sequence layout for RNN unroll helpers.
4. Use `tf.GradientTape` plus `optimizer.apply(gradients, variables)` for
   object-oriented Sonnet training loops, or use `snt.functional` only when the
   task explicitly wants stateless-style `init`/`apply` workflows.
5. Treat CUDA, TPU, XLA, and distributed execution as environment-specific. Do
   not claim accelerator verification unless the current TensorFlow runtime has
   been probed and the sub-skill's backend guidance is satisfied.

## When not to use this skill

- The user is asking for general TensorFlow or Keras usage with no Sonnet API,
  module, optimizer, or distribution helper involved.
- The user wants to edit or maintain the Sonnet repository itself rather than
  use Sonnet as a package; route to a repository-maintenance workflow instead.
- The user needs a full experiment framework, trainer, data pipeline, model
  zoo, or serving platform that Sonnet does not provide.

Files in this skill

  • SKILL.md5.1 KB
  • references/package-overview.md3.2 KB
  • references/repo-provenance.md2 KB
  • references/repo-routing-metadata.json542 B
  • references/troubleshooting.md2.9 KB
  • scripts/check_sonnet_install.py2.2 KB
  • sub-skills/functional-transforms/SKILL.md1.7 KB
  • sub-skills/functional-transforms/references/api-reference.md1.5 KB
  • sub-skills/functional-transforms/references/troubleshooting.md1 KB
  • sub-skills/functional-transforms/references/workflows.md1.2 KB
  • sub-skills/functional-transforms/scripts/sonnet_functional_transform_smoke.py1.5 KB
  • sub-skills/layers-and-nets/SKILL.md1.8 KB
  • sub-skills/layers-and-nets/references/api-reference.md1.8 KB
  • sub-skills/layers-and-nets/references/troubleshooting.md1.2 KB
  • sub-skills/layers-and-nets/references/workflows.md1.2 KB
  • sub-skills/layers-and-nets/scripts/layers_and_nets_smoke.py1.3 KB
  • sub-skills/module-authoring/SKILL.md2 KB
  • sub-skills/module-authoring/references/api-reference.md2 KB
  • sub-skills/module-authoring/references/module-patterns.md1.4 KB
  • sub-skills/module-authoring/references/troubleshooting.md1.1 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.