Skip to content
class

Linear

extendsUniLoraLayer
Linear(base_layer: nn.Module, adapter_name: str, config: C)

Implementing kernel

C++ engine symbols that back this Python API.

An nn.Linear with a Uni-LoRA update: y=Wx+b+BA drop(x)y = W x + b + B A\,\mathrm{drop}(x), A,BA, B read out of one vector.

Parameters

base_layernn.Linear
The layer to adapt; the other parameters are those of UniLoraLayer.
adapter_namestr
Name of the adapter created at once.
The adapter's config.

Examples

>>> import lucid
>>> import lucid.nn as nn
>>> from lucid.peft import UniLoraConfig
>>> from lucid.peft.tuners.unilora import Linear
>>> base = nn.Linear(8, 4)
>>> layer = Linear(base, "default", UniLoraConfig(r=2, theta_d_length=16, target_modules=["x"]))
>>> tuple(layer.unilora_theta_d["default"].shape)
(16,)
>>> tuple(layer.get_delta_weight("default").shape)
(4, 8)

Used by 1