torch.frac¶ torch.frac(input, *, out=None) → Tensor¶ 计算 input 中每个元素的小数部分。 outi=inputi−⌊∣inputi∣⌋∗sgn(inputi)\text{out}_{i} = \text{input}_{i} - \left\lfloor |\text{input}_{i}| \right\rfloor * \operatorname{sgn}(\text{input}_{i}) outi=inputi−⌊∣inputi∣⌋∗sgn(inputi)示例 >>> torch.frac(torch.tensor([1, 2.5, -3.2])) tensor([ 0.0000, 0.5000, -0.2000])