torch
torch.arange
time = torch.arange(start=1, end=10, step=2, dtype=torch.float32)
tensor([1., 3., 5., 7., 9.])
生成一个张量,起点,终点,步长
torch.normal
tmp = torch.normal(mean=0, std=0.2, size=(4, 2))
# 4行2列
tensor([[ 0.1186, 0.2120],
[-0.3588, 0.1388],
[ 0.0223, 0.1169],
[ 0.0418, -0.0490]])
nn
nn.Linear
nn.Linear定义一个神经网络的线性层
nn.Linear(
in_features=10, # 输入神经元个数
out_features=10, # 输出神经元个数
bias=True # 是否包含偏置
)