(x:Tensor, axis:int=-1, p:int=2)
| 947 | return (x - x.mean(axis, keepdim=True)) / (x.std(axis, keepdim=True, correction=0) + 1e-9) |
| 948 | |
| 949 | def LpNormalization(x:Tensor, axis:int=-1, p:int=2): |
| 950 | return x / (x.abs().sum(axis, keepdim=True) if p == 1 else x.square().sum(axis, keepdim=True).sqrt()) |
| 951 | |
| 952 | def OneHot(indices:Tensor, depth:float|int|list[int|float], values:Tensor, axis:int=-1): |
| 953 | # Scalar or Rank 1 tensor containing exactly one element |