IntRVFL
- class torchhd.models.IntRVFL(in_features: int, dimensions: int, out_features: int, kappa: int | None = None, device=None, dtype=None, requires_grad=False)[来源]
实现整数随机向量功能链接网络(intRVFL)模型的类,如Density Encoding Enables Resource-Efficient Randomly Connected Neural Networks中所述。
- Parameters:
in_features (int) – 每个输入样本的大小。
dimensions (int) – 使用的隐藏维度数量。
out_features (int) – 输出特征的数量,通常是类别的数量。
kappa (int, optional) – 限制值范围的剪切函数的参数;用于转换输入数据的一部分。
device (
torch.device, 可选) – 权重的期望设备。默认值:如果None,则使用当前设备作为默认张量类型(参见torch.set_default_tensor_type())。device对于 CPU 张量类型将是 CPU,对于 CUDA 张量类型将是当前的 CUDA 设备。dtype (
torch.dtype, 可选) – 权重的期望数据类型。默认值:如果None,则使用torch.get_default_dtype()。requires_grad (bool, 可选) – 如果自动求导应该记录返回张量上的操作。默认值:
False。
- Shape:
输入: \((*, d)\) 其中 \(*\) 表示任意数量的维度,包括无维度和
d = in_features。输出:\((*, n)\) 其中除了最后一个维度外,其他维度的形状与输入相同,且
n = out_features。
- weight
模块的可训练权重,或类原型,形状为 \((n, d)\)。值初始化为全零。
- Type:
torch.Tensor
- fit_ridge_regression(samples: Tensor, labels: Tensor, alpha: float | None = 1) None[来源]
使用
ridge_regression()计算权重(读出矩阵)。这是一种在随机神经网络中形成分类器的常见方法,参见,例如,Randomness in Neural Networks: An Overview。
- Parameters:
样本 (张量) – 特征向量。
labels (LongTensor) – 目标向量,通常是每个样本的类别。
alpha (float, optional) – 样本方差的标量。默认值为1。
- Shapes:
样本:\((n, f)\)
标签:\((n, c)\)