class
OrthLayer
extends
ModuleOrthLayer(size: int, orth: bool = True, mag_b: bool = True, mag_a: bool = True, use_cayley_neumann: bool = False, num_cayley_neumann_terms: int = 5, cayley_neumann_eps: float | None = None, init_weights: bool = True, device: DeviceLike = None, dtype: DTypeLike = None)The matrix , the parameters that make it, and how to apply it.
Parameters
sizeintThe rank of the principal subspace.
orthbool= TrueKeep orthogonal with the Cayley transform of a skew-symmetric matrix whose
upper entries are trained;
False trains itself.mag_ bbool= TrueWhether the vector left of (
mag_b) or right of (mag_a) is trained.mag_ abool= TrueWhether the vector left of (
mag_b) or right of (mag_a) is trained.use_ cayley_ neumannbool= FalseBuild from a truncated Neumann series instead of an exact solve.
num_ cayley_ neumann_ termsint= 5Terms of the series.
cayley_ neumann_ epsfloat= NoneWith the series, rescale the generator whenever its Frobenius norm exceeds this.
init_ weightsbool= TrueStart at the identity (the generator at zero, the vectors at one);
False perturbs
by a normal of standard deviation 0.1.deviceDeviceLike= NoneWhere and in what dtype the parameters are made.
dtypeDeviceLike= NoneWhere and in what dtype the parameters are made.
Used by 2
Constructors
1dunder
__init__
→None__init__(size: int, orth: bool = True, mag_b: bool = True, mag_a: bool = True, use_cayley_neumann: bool = False, num_cayley_neumann_terms: int = 5, cayley_neumann_eps: float | None = None, init_weights: bool = True, device: DeviceLike = None, dtype: DTypeLike = None)Make the generator (or the free matrix) and the two vectors, on device in dtype.
Instance methods
3The size and the options that shape the matrix.
, with input of width r on its last axis.
Return , the (r, r) matrix the layer applies between its factors.
: exact, or the Neumann series
with its last term halved, built from
weight as . The vectors then scale its rows (vector_b) and columns
(vector_a).