ParameterLike#
- class penzai.deprecated.v1.nn.parameters.ParameterLike[source]#
-
Protocol for a parameter-like object.
ParameterLike
defines 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 ofParameterLike
used.Rules for a
ParameterLike
implementation:.value_structure
should 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..value
should be the concrete value of the parameter if available. However, it is allowed for accessing.value
to 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.
ParameterLike
is a protocol, which means implementations of it do not have to explicitly subclass it. If you definevalue
as a dataclass attribute rather than a property, you should avoid subclassingParameterLike
directly, 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.