class
Linear
extends
FrodLayerLinear(base_layer: nn.Module, adapter_name: str, config: FrodConfig, deferred: bool = False)Implementing kernel
C++ engine symbols that back this Python API.An nn.Linear whose weight is re-expressed as : .
Parameters
base_ layernn.LinearThe layer to adapt; the other parameters are those of
FrodLayer.adapter_ namestrName of the first adapter.
configFrodConfigsparse_rate, projection_prng_key, regularization_alpha, frod_dropout, init_weights.deferredbool= FalseThe tuner will bind the layer to its tables and start the adapter; nothing is derived yet.
Examples
>>> import lucid
>>> import lucid.nn as nn
>>> from lucid.peft import FrodConfig
>>> from lucid.peft.tuners.frod import Linear
>>> base = nn.Linear(6, 4)
>>> layer = Linear(base, "default", FrodConfig(sparse_rate=0.5, target_modules=["x"]))
>>> tuple(layer.frod_lambda_l["default"].shape), tuple(layer.frod_lambda_s_values["default"].shape)
((6,), (18,))
>>> x = lucid.randn(3, 6)
>>> bool(lucid.allclose(layer(x), base(x), atol=1e-5)) # S starts at zero: W' = W up to rounding
True