Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
Index your code
hub
/
github.com/google-deepmind/penzai
/ functions
Functions
1,092 in github.com/google-deepmind/penzai
⨍
Functions
1,092
◇
Types & classes
360
↳
Endpoints
3
↓ 2 callers
Method
_partition_dict_index
Helper to partition the indices of a dict-style index.
penzai/core/named_axes.py:497
↓ 2 callers
Function
_shift_axis
(other_axis)
penzai/core/named_axes.py:264
↓ 2 callers
Method
_state_structure
(self, desc)
penzai/deprecated/v1/data_effects/local_state.py:297
↓ 2 callers
Function
add_intercept_shapes_inside
Inserts `_InterceptShapes` layers around all sublayers of a layer.
penzai/deprecated/v1/toolshed/annotate_shapes.py:91
↓ 2 callers
Function
add_intercept_values_around
Inserts inserted_cls layers around a layer and inside sublayers.
penzai/toolshed/save_intermediates.py:116
↓ 2 callers
Method
apply_with_selected_index
Applies a function, passing both the selected nodes and their indices. Indices are taken relative to the linearized sequence of currently selecte
penzai/core/selectors.py:1371
↓ 2 callers
Method
at_keypaths
Selects nodes by their keypaths (relative to the current selection). Args: keypaths: A collection of keypaths. Returns: A new se
penzai/core/selectors.py:1034
↓ 2 callers
Method
broadcast_like
Broadcasts a named array to be compatible with another. Args: other: Another named array. Returns: A named array that has the sa
penzai/core/named_axes.py:994
↓ 2 callers
Function
check_unique_axis_names_for_initializer
Checks that indices appear exactly once in the given axis specs.
penzai/nn/linear_and_affine.py:82
↓ 2 callers
Function
check_unique_axis_names_for_initializer
Checks that indices appear exactly once in the axis specifications.
penzai/deprecated/v1/nn/linear_and_affine.py:87
↓ 2 callers
Method
effect_protocol
Returns the protocol that this effect request handles.
penzai/deprecated/v1/data_effects/effect_base.py:356
↓ 2 callers
Method
extract_vars
(self)
penzai/core/shapecheck.py:238
↓ 2 callers
Method
floating_named
Returns an `ArraySpec` with this named shape and `np.floating` dtype.
penzai/core/shapecheck.py:314
↓ 2 callers
Function
freeze_variables
Replaces each variable in a pytree with a frozen copy. The resulting tree will contain frozen variable instances instead of mutable variable inst
penzai/core/variables.py:344
↓ 2 callers
Method
from_attributes
Directly instantiates a struct given all of its fields. Structs can override ``__init__`` to have arbitrary custom behavior, but this may mak
penzai/core/struct.py:496
↓ 2 callers
Method
from_config
Constructs a ``Linear`` layer from a configuration. This can be used when building a new linear operator at the start of training. Note:
penzai/nn/linear_and_affine.py:451
↓ 2 callers
Method
from_config
Constructs an ``ApplyRoPE`` layer for a given axis and side input tag. Args: positions_tag: Side input tag for the position side input. Thi
penzai/deprecated/v1/nn/embeddings.py:266
↓ 2 callers
Method
from_config
Constructs a ``Linear`` layer from a configuration. This can be used when building a new linear operator at the start of training. The return
penzai/deprecated/v1/nn/linear_and_affine.py:453
↓ 2 callers
Method
get
Get values from the array.
penzai/core/named_axes.py:540
↓ 2 callers
Method
get_array_summary
( self, array: named_axes.NamedArrayBase, fast: bool )
penzai/core/_treescope_handlers/named_axes_handlers.py:228
↓ 2 callers
Method
initial_state
Constructs the initial training state. Args: model: The model being optimized. optimizer_def: The optax optimizer to use. root_
penzai/deprecated/v1/toolshed/basic_training.py:73
↓ 2 callers
Function
is_pytree_node_field
Returns True if this field is treated as a PyTree child node by Struct. Fields are treated as PyTree nodes by default unless they contain a metadat
penzai/core/struct.py:425
↓ 2 callers
Function
is_sequential_or_named
Checks if a tree is a subclass of `Sequential` or a `NamedGroup`.
penzai/nn/grouping.py:257
↓ 2 callers
Function
is_sequential_or_named
Checks if a tree is a subclass of `Sequential` or a `NamedGroup`.
penzai/deprecated/v1/nn/grouping.py:253
↓ 2 callers
Function
named_array_and_contained_type_summary
Summarizes a (validly constructed) named array.
penzai/core/_treescope_handlers/named_axes_handlers.py:35
↓ 2 callers
Method
next_key
Gets the next key from this stream, mutating the stream in place.
penzai/deprecated/v1/core/random_stream.py:50
↓ 2 callers
Method
num_multi_dim_vars
(self)
penzai/core/shapecheck.py:248
↓ 2 callers
Method
partition
Partitions the tree into ``(selected_tree, remainder_tree)`` parts. This function can be used to separate out the selected components of a tree
penzai/core/selectors.py:964
↓ 2 callers
Method
pick_nth_selected
Filters a selection to only the nth selected node. ``n`` is taken relative to the linearized sequence of currently selected nodes, in the sen
penzai/core/selectors.py:1336
↓ 2 callers
Method
step
Runs one step of training.
penzai/toolshed/basic_training.py:221
↓ 2 callers
Method
treescope_color
Computes a CSS color to display for this object in treescope. This function can be overridden to change the color for a particular object in
penzai/core/struct.py:671
↓ 2 callers
Method
treescope_color
(self)
penzai/deprecated/v1/data_effects/effect_base.py:184
↓ 2 callers
Method
unsafe_mark_active
Activates the random stream, returning itself for convenience.
penzai/deprecated/v1/core/random_stream.py:78
↓ 2 callers
Method
with_positional_prefix
Converts a view into a proper `NamedArray` by moving positional axes. The resulting `NamedArray` has the same named and positional shapes as this
penzai/core/named_axes.py:1664
↓ 1 callers
Method
IsControl
Identifies whether a token is a control token.
penzai/toolshed/token_visualization.py:44
↓ 1 callers
Method
__get_state_as_jax_pytree__
Mutable variable protocol method, for JAX ecosystem interoperability.
penzai/core/variables.py:125
↓ 1 callers
Method
__jax_pytree_state_to_new_variable__
Mutable variable protocol method, for JAX ecosystem interoperability.
penzai/core/variables.py:156
↓ 1 callers
Method
__set_state_from_jax_pytree__
Mutable variable protocol method, for JAX ecosystem interoperability.
penzai/core/variables.py:130
↓ 1 callers
Method
__treescope_root_repr__
Renders this selection as the root object in a treescope rendering.
penzai/core/selectors.py:1405
↓ 1 callers
Function
_abstract_leaf
Helper function to get an `ArraySpec` view of a leaf.
penzai/core/shapecheck.py:368
↓ 1 callers
Function
_arraystructure_summary
Creates a summary line for an array structure.
penzai/core/_treescope_handlers/shapecheck_handlers.py:35
↓ 1 callers
Function
_common_prefix
(parts: Sequence[tuple[Any, ...]])
penzai/deprecated/v1/toolshed/unflaxify.py:210
↓ 1 callers
Function
_flat_jit_call_layer
Helper to call a callable pytree with an argument.
penzai/toolshed/jit_wrapper.py:32
↓ 1 callers
Function
_flat_jit_call_layer
Helper to call a callable pytree with an argument.
penzai/deprecated/v1/toolshed/jit_wrapper.py:35
↓ 1 callers
Function
_generate_primes
()
penzai/deprecated/v1/toolshed/check_layers_by_tracing.py:36
↓ 1 callers
Method
_input_structure
(self)
penzai/nn/linear_and_affine.py:362
↓ 1 callers
Method
_input_structure
(self)
penzai/nn/linear_and_affine.py:581
↓ 1 callers
Function
_is_hole_or_quote
Checks if we need special handling for this subtree.
penzai/core/selectors.py:158
↓ 1 callers
Function
_jitted_nmapped_getitem
JIT-compiled helper for getitem.
penzai/core/named_axes.py:428
↓ 1 callers
Function
_jitted_nmapped_update
JIT-compiled helper for in-place updates.
penzai/core/named_axes.py:452
↓ 1 callers
Function
_match_leaf
Helper function to match a leaf value against an `ArraySpec`. Args: array_structure: Expected structure to match agains. value: Value to ma
penzai/core/shapecheck.py:392
↓ 1 callers
Function
_named_inline_multidimvars
Simplifies a named constraint by inlining multivars.
penzai/core/shapecheck.py:602
↓ 1 callers
Function
_next_auto_variable_label
Generates a unique label for a Variable.
penzai/core/variables.py:677
↓ 1 callers
Method
_output_structure
(self)
penzai/nn/linear_and_affine.py:381
↓ 1 callers
Method
_output_structure
(self)
penzai/nn/linear_and_affine.py:592
↓ 1 callers
Function
_positional_inline_multidimvars
Simplifies a positional constraint by inlining multivars.
penzai/core/shapecheck.py:575
↓ 1 callers
Function
_prepare
(subtree, keypath_prefix)
penzai/deprecated/v1/data_effects/side_input.py:344
↓ 1 callers
Function
_rename_parameters
Helper function to rename all `SupportsParameterRenaming` subtrees.
penzai/deprecated/v1/nn/parameters.py:565
↓ 1 callers
Function
_step
(subtree)
penzai/nn/grouping.py:300
↓ 1 callers
Function
_step
(subtree)
penzai/deprecated/v1/nn/grouping.py:296
↓ 1 callers
Function
add_intercept_shapes_around
Inserts `_InterceptShapes` layers around a layer.
penzai/deprecated/v1/toolshed/annotate_shapes.py:110
↓ 1 callers
Function
add_intercept_values_around
Inserts _InterceptValues layers around a layer.
penzai/deprecated/v1/toolshed/interleave_intermediates.py:115
↓ 1 callers
Function
advance_one_token
Advances a sampling state by one token. This can be used to feed new sampled tokens one-at-a-time through the model, producing new log-probs that
penzai/deprecated/v1/example_models/gemma/simple_decoding_loop.py:121
↓ 1 callers
Function
all_handler_ids
Collects the set of all handler IDs inside a model or submodel. Args: model_tree: A pytree for a model or submodel. Returns: A list of a
penzai/deprecated/v1/data_effects/effect_base.py:243
↓ 1 callers
Method
as_empty_parameter
Creates a placeholder parameter containing `jax.ShapeDtypeStruct` leaves. This can be used to create a model with the right PyTree structure with
penzai/deprecated/v1/nn/parameters.py:309
↓ 1 callers
Method
as_namedarrayview
Converts into a `NamedArrayView`, keeping positional axes. This function is usually not necessary for ordinary named-array manipulation, sinc
penzai/core/named_axes.py:746
↓ 1 callers
Method
at_childless
Selects all PyTree nodes with no children, including PyTree leaves. This is different than `at_pytree_leaves` in that it additionally selects
penzai/core/selectors.py:1089
↓ 1 callers
Method
attributes_dict
Constructs a dictionary with all of the fields in the class. The result of this should be passable back to `from_attributes` to rebuild (a co
penzai/core/struct.py:534
↓ 1 callers
Function
bind_params
( intercepted: InterceptedFlaxModuleMethod, path: tuple[str, ...] )
penzai/deprecated/v1/toolshed/unflaxify.py:431
↓ 1 callers
Function
bind_variables
Binds variables (mutable or frozen) into the variable slots in a pytree. This function re-inserts variable instances into a tree in place of their
penzai/core/variables.py:275
↓ 1 callers
Function
build_gpt_neox_attention
Builds an attention block from a configuration. Args: name: Name of the attention block. init_base_rng: Base RNG for initializing the param
penzai/models/transformer/variants/gpt_neox.py:122
↓ 1 callers
Function
build_gpt_neox_block
Builds a GPT-NeoX "parallel" transformer block from a configuration. GPT-NeoX uses a parallel formulation of transformer blocks, where the input of
penzai/models/transformer/variants/gpt_neox.py:220
↓ 1 callers
Function
build_gpt_neox_feedforward
Creates a feedforward block. The GPT-NeoX model uses a standard MLP configuration. Args: name: Name of the feedforward block. init_base_
penzai/models/transformer/variants/gpt_neox.py:82
↓ 1 callers
Function
build_gpt_neox_transformer
Builds a Llama-like transformer model from a configuration. Args: config: The configuration of the model. init_base_rng: Base RNG for initi
penzai/models/transformer/variants/gpt_neox.py:274
↓ 1 callers
Function
build_llamalike_attention
Builds an attention block from a configuration. Args: name: Name of the attention block. init_base_rng: Base RNG for initializing the param
penzai/models/transformer/variants/llamalike_common.py:214
↓ 1 callers
Function
build_llamalike_block
Builds a transformer block from a configuration. Args: name: Name of the block. init_base_rng: Base RNG for initializing the parameters.
penzai/models/transformer/variants/llamalike_common.py:362
↓ 1 callers
Function
build_llamalike_feedforward
Creates a feedforward block. This family of models use gated linear units, as proposed by Shazeer (2020). We represent this computation as a comp
penzai/models/transformer/variants/llamalike_common.py:131
↓ 1 callers
Function
build_llamalike_transformer
Builds a Llama-like transformer model from a configuration. Args: config: The configuration of the model. init_base_rng: Base RNG for initi
penzai/models/transformer/variants/llamalike_common.py:433
↓ 1 callers
Function
check_no_duplicated_parameters
Checks that there are no duplicated parameters in a model. Args: model: An arbitrary model. Raises: ValueError: If two concrete paramete
penzai/deprecated/v1/nn/parameters.py:610
↓ 1 callers
Function
constant_initializer
Returns an initializer that uses a constant value.
penzai/nn/linear_and_affine.py:179
↓ 1 callers
Function
constant_initializer
Returns an initializer that uses a constant value.
penzai/deprecated/v1/nn/linear_and_affine.py:184
↓ 1 callers
Function
contract
Contracts two named arrays along the given axis names. Args: names: The axis names to contract. Can also be a single string axis name. left
penzai/nn/linear_and_affine.py:250
↓ 1 callers
Function
contract
Contracts two named arrays along the given axis names. Args: names: The axis names to contract. Can also be a single string axis name. left
penzai/deprecated/v1/nn/linear_and_affine.py:280
↓ 1 callers
Function
derive_param_key
Derives a PRNG key for a parameter from a base key and a name. Args: base_rng: The base PRNG key. name: The name of the parameter. Retur
penzai/nn/parameters.py:65
↓ 1 callers
Method
effect_protocol
Returns the protocol that this effect request handles.
penzai/deprecated/v1/data_effects/effect_base.py:430
↓ 1 callers
Method
effect_protocol
Returns the effect protocol(s) that this handler handles. Advanced handlers are allowed to handle multiple effects, and the specific effect i
penzai/deprecated/v1/data_effects/effect_base.py:495
↓ 1 callers
Function
flat_array_fun
(batch_tracers)
penzai/core/named_axes.py:223
↓ 1 callers
Method
flatten_selected_selections
Flattens a selection whose selected values are all selections. This function takes a selection for which all of the selected values are alrea
penzai/core/selectors.py:435
↓ 1 callers
Method
freeze
Returns a frozen copy of this variable.
penzai/core/variables.py:107
↓ 1 callers
Method
from_basic_segments
Constructs a simple input structure for a batch of single segments. This can be used to process inputs that do not need advanced position or
penzai/deprecated/v1/example_models/gemma/model_core.py:380
↓ 1 callers
Method
from_basic_subsegments
Constructs a simple input structure for a batch of unpadded samples. This can be used to process inputs that do not need advanced position or
penzai/deprecated/v1/example_models/gemma/sampling_mode.py:131
↓ 1 callers
Method
from_config
Constructs a layer normalization layer. Args: name: The name of the layer. init_base_rng: The base RNG to use for initializing model
penzai/nn/standardization.py:75
↓ 1 callers
Method
from_config
( cls, feature_sizes: list[int], activation_fn: Callable[[jax.Array], jax.Array] = jax.nn.re
penzai/deprecated/v1/example_models/simple_mlp.py:30
↓ 1 callers
Method
from_config
Constructs a layer normalization layer. Args: across_axes: Names and lengths of the axes to normalize over. epsilon: Epsilon paramete
penzai/deprecated/v1/nn/standardization.py:94
↓ 1 callers
Method
from_linear
Builds a LoRA layer from a `pz.nn.Linear` layer. Args: linear: The linear layer to adapt. name: Name for this layer's parameters. Mus
penzai/toolshed/lora.py:43
↓ 1 callers
Method
from_linear
Builds a LoRA layer from a `pz.nn.Linear` layer. Args: linear: The linear layer to adapt. rank: The rank of the low-rank adapter.
penzai/deprecated/v1/toolshed/lora.py:42
↓ 1 callers
Method
from_uncached
Builds a caching attention from an uncached attention. Args: original: The original attention layer that this block should replace. c
penzai/deprecated/v1/example_models/gemma/sampling_mode.py:48
↓ 1 callers
Function
func
(array, *args, **kwargs)
penzai/core/named_axes.py:371
↓ 1 callers
Function
go
(handled, arg)
penzai/deprecated/v1/toolshed/interleave_intermediates.py:150
↓ 1 callers
Method
handler_id
(self)
penzai/deprecated/v1/data_effects/random.py:86
← previous
next →
101–200 of 1,092, ranked by callers