add_parameter_prefix#
- penzai.deprecated.v1.nn.parameters.add_parameter_prefix(prefix: str, tree: Any, delimiter: str = '.') Any [source]#
Prepends a prefix to all parameter names inside the tree.
This function can be used to avoid name conflicts when combining sublayers into a larger model layer. For instance, composite layers (subclasses of Sequential) can call
add_parameter_prefix
from theirfrom_config
, to ensure that none of their sublayers have conflicting names.- Parameters:
prefix – Prefix to append to all parameters in
tree
.tree – Tree containing
Parameter
,FrozenParameter
, orUninitializedParameter
instances.delimiter – Delimiter to add between the prefix and the original name.
- Returns:
A version of
tree
where allParameter
,FrozenParameter
, andUninitializedParameter
instances, and any other subclass ofSupportsParameterRenaming
, have their names updated to new names with the format"{prefix}{delimiter}{original_name}"
.