ParameterLike

ParameterLike#

class penzai.nn.parameters.ParameterLike[source]#

Bases: Protocol, Generic[T]

Protocol for a parameter-like object.

ParameterLike defines the common API for parameters in penzai.nn. Any parameterized network layer should annotate its parameters as ParameterLike, and should not make assumptions about the exact implementation of ParameterLike used.

ParameterLike is a protocol, which means implementations of it do not have to explicitly subclass it. If you define value as a dataclass attribute rather than a property, you should avoid subclassing ParameterLike directly, since Python’s ABC system will not see that as an implementation of the method.

Methods

__init__(*args, **kwargs)

Attributes

value

The value of the parameter.

abstract property value: T#

The value of the parameter. May raise an error for some instances.