pz
: Penzai’s alias namespace#
Structs and Layers#
Most objects in Penzai models are subclasses of pz.Struct
and
decorated with pz.pytree_dataclass
, which makes them into frozen Python
dataclasses that are also JAX PyTrees. Most models and layers are
subclasses of pz.Layer
, which means they can be called with a single
argument.
|
Alias of |
|
Alias of |
|
Alias of |
|
PyTree Manipulation#
Penzai provides a number of utilities to make targeted modifications to PyTrees. Since Penzai models are PyTrees, you can use them to insert new layers into models, or modify the configuration of existing layers.
|
Alias of |
|
Alias of |
|
Alias of |
|
Alias of |
|
Alias of |
Named Axes#
pz.nx
is an alias for penzai.core.named_axes
, which contains
Penzai’s named axis system. Some commonly-used attributes on pz.nx
:
|
Alias of |
|
Alias of |
|
Alias of |
See penzai.core.named_axes
for documentation of all of the methods and
classes accessible through the pz.nx
alias.
To simplify slicing named axes, Penzai also provides a helper object:
|
Builds a slice when sliced (e.g. |
Visualization#
pz.ts
is an alias namespace for Penzai’s interactive pretty printer
Treescope. Some commonly-used attributes on pz.ts
:
|
Alias of |
|
Alias of |
|
Alias of |
See the documentation for pz.ts
to view all of the methods and
classes accessible through this alias namespace.
Penzai also provides a utility for quickly showing a value with Treescope in an
IPython notebook, using syntax similar to ordinary print
:
|
Alias of |
Neural Networks#
pz.nn
is an alias namespace for Penzai’s declarative neural network
system, which uses a combinator-based design to expose all of your model’s
operations as nodes in your model PyTree. pz.nn
re-exports layers from
submodules of penzai.nn
in a single convenient namespace.
See the documentation for pz.nn
to view all of the
methods and classes accessible through this alias namespace.
Data Effects#
pz.de
is an alias namespace for Penzai’s “data effect” system, which
represents side inputs, side outputs, randomness, and mutable state as typed
attributes inside your model PyTree, and allows handling them using functional
effect handlers. pz.de
re-exports effect requests and effect handlers
from submodules of penzai.data_effects
in a single convenient namespace.
See the documentation for pz.de
to view all of the
methods and classes accessible through this alias namespace.
Shape-Checking#
pz.chk
is an alias for penzai.core.shapecheck
, which contains
utilities for checking the shapes of PyTrees of positional and named arrays.
Some commonly-used attributes on pz.chk
:
|
Alias of |
|
Alias of |
|
Alias of |
See penzai.core.shapecheck
for documentation of all of the methods and
classes accessible through the pz.chk
alias.
The following decorators can be used to enable runtime shape-checking on
penzai.core.layer.Layer
(pz.Layer
) subclasses:
|
Alias of |
|
Alias of |
Context Management#
|
Alias of |
|
Alias of |
|
Alias of |
Dataclass and Struct Utilities#
|
Alias of |
|
Alias of |
|
Alias of |
|
Alias of |
|
Alias of |
|
Alias of |
Context and State Management#
|
Alias of |
|
Alias of |
|
Alias of |
|
Alias of |
Formatting Utilities#
|
Alias of |
|
Alias of |