class
Linear
extends
TinyLoraLayerLinear(base_layer: nn.Module, adapter_name: str, config: C)Implementing kernel
C++ engine symbols that back this Python API.An nn.Linear with a TinyLoRA update: , .
Parameters
base_ layernn.LinearThe layer to adapt; the other parameters are those of
TinyLoraLayer.adapter_ namestrName of the adapter created at once.
configTinyLoraConfigThe adapter's config.
Examples
>>> import lucid
>>> import lucid.nn as nn
>>> from lucid.peft import TinyLoraConfig
>>> from lucid.peft.tuners.tinylora import Linear
>>> base = nn.Linear(8, 4)
>>> layer = Linear(base, "default", TinyLoraConfig(r=2, u=3, target_modules=["x"]))
>>> tuple(layer.tinylora_A["default"].shape), tuple(layer.tinylora_B["default"].shape)
((2, 8), (4, 2))
>>> x = lucid.randn(2, 8)
>>> bool((layer(x) == base(x)).all().item()) # v starts at zero
True