Linear
接口功能
Pytorch的Linear用于创建全连接层,进行线性变换
。
函数原型
torch.nn.Linear(
in_features: int,
out_features: int,
bias: bool = True,
device=None,
dtype=None
)
参数说明
参数 |
类型 |
必填 |
说明 |
|---|---|---|---|
in_feature |
int |
是 |
输入特性维度。 |
out_feature |
int |
是 |
输出特征维度。 |
bias |
bool |
否 |
是否包含偏置(默认True)。 |
device |
torch.device |
否 |
计算设备(如“cpu”,“cuda”)。 |
dtype |
torch.dtype |
否 |
权重数据类型(如torch.float16、torch.float32)。 |
父主题: 算子接口