random_mask(base_layer: nn.Module, r: int, random_seed: int | None = None)A random sparse mask for base_layer's weight with ones.
Parameters
base_ layernn.ModuleThe module whose weight the mask is for.
rintThe rank the number of ones is sized after.
random_ seedint= NoneSeed of the permutation;
None is the reference's default seed.Returns
Tensor(d_out, d_in) float tensor of 0 and 1, on the weight's device.
Raises
ValueErrorr (d_out + d_in) exceeds the number of weight entries.