ParameterLike#
- class penzai.deprecated.v1.nn.parameters.ParameterLike[source]#
-
Protocol for a parameter-like object.
ParameterLikedefines the common API for parameters inpenzai.deprecated.v1.nn. Any parameterized network layer should annotate its parameters asParameterLike, and should not make assumptions about the exact implementation ofParameterLikeused.Rules for a
ParameterLikeimplementation:.value_structureshould always be a concrete structure defining the structure of the parameter’s value, usually an instance ofshapecheck.ArraySpec(with no dimension variables). Accessing this should never raise an exception..valueshould be the concrete value of the parameter if available. However, it is allowed for accessing.valueto raise an exception if this type is a placeholder for a concrete runtime parameter. In particular, this can raise an exception if this parameter is uninitialized or if it is a reference to a shared parameter that has not been provided yet.
ParameterLikeis a protocol, which means implementations of it do not have to explicitly subclass it. If you definevalueas a dataclass attribute rather than a property, you should avoid subclassingParameterLikedirectly, since Python’s ABC system will not see that as an implementation of the method.Methods
__init__(*args, **kwargs)Attributes
The value of the parameter.
The structure of the parameter.
- abstract property value: T#
The value of the parameter. May raise an error for some instances.
- abstract property value_structure: shapecheck.StructureAnnotation#
The structure of the parameter.