class
Linear
extends
FourierFTLayerLinear(base_layer: nn.Module, adapter_name: str, config: C)Implementing kernel
C++ engine symbols that back this Python API.An nn.Linear with a FourierFT update: .
Parameters
base_ layernn.LinearThe layer to adapt; the other parameters are those of
FourierFTLayer.adapter_ namestrName of the adapter created at once.
configFourierFTConfigThe adapter's config (its
n_frequency is this layer's).Examples
>>> import lucid
>>> import lucid.nn as nn
>>> from lucid.peft import FourierFTConfig
>>> from lucid.peft.tuners.fourierft import Linear
>>> base = nn.Linear(8, 4)
>>> config = FourierFTConfig(n_frequency=5, init_weights=True, target_modules=["x"])
>>> layer = Linear(base, "default", config)
>>> tuple(layer.fourierft_spectrum["default"].shape)
(5,)
>>> x = lucid.randn(3, 8)
>>> bool((layer(x) == base(x)).all().item()) # the coefficients start at zero
True