torch.var — PyTorch 2.12 documentation
Calculates the variance over the dimensions specified by dim. dim can be a single dimension, list of dimensions, or None to reduce over all dimensions. The variance ( 𝜎 2 σ 2 ) is calculated as where 𝑥 x is the sample set of elements, 𝑥 ˉ x ˉ is the sample mean, 𝑁 N is the number of samples and 𝛿 𝑁 δN is the correction. If keepdim is True, the output tensor is of the same size as input except in the dimension(s) dim where it is of size 1. Otherwise, dim is squeezed (see torch.squeeze()), resulting in the output tensor having 1 (or len(dim)) fewer dimension(s). input (Tensor) – the input tensor. dim (int or tuple of ints, optional) – the dimension or dimensions to reduce. If None, all dimensions are reduced. correction (int) – difference between the sample size and sample degrees of freedom. Defaults to Bessel’s correction, correction=1. Changed in version 2.0: Previously this argument was called unbiased and was a boolean with True corresponding to correction=1 and False
torch.var # torch. var ( input , dim = None , * , correction = 1 , keepdim = False , out = None ) → Tensor # Calculates the variance over the dimensions specified by dim . dim can be a single dimension, list of dimensions, or None to reduce over all dimensions. The variance ( σ 2 \sigma^2 σ 2 ) is calculated as σ 2 = 1 max ( 0 , N − δ N ) ∑ i = 0 N − 1 ( x i − x ˉ ) 2 \sigma^2 = \frac{1}{\max(0,~N - \delta N)}\sum_{i=0}^{N-1}(x_i-\bar{x})^2 σ 2 = max ( 0 , N − δ N ) 1 i = 0 ∑ N − 1 ( x i − x ˉ ) 2 where x x x is the sample set of elements, x ˉ \bar{x} x ˉ is the sample mean, N N
Explore this link on the map →related reading
- PyTorch internals : ezyang's blogblog.ezyang.com
- Algorithms for calculating variance - Wikipediaen.wikipedia.org
- X explains Z% of the variance in Y — LessWronglesswrong.com
- torch.Tensor — PyTorch 2.12 documentationdocs.pytorch.org
- torch.reshape — PyTorch 2.12 documentationdocs.pytorch.org
- Law of total variance - Wikipediaen.wikipedia.org
- torch.normal — PyTorch 2.12 documentationdocs.pytorch.org
- torch.stack — PyTorch 2.12 documentationdocs.pytorch.org
- torch.randn — PyTorch 2.12 documentationdocs.pytorch.org
- torch.max — PyTorch 2.12 documentationdocs.pytorch.org
- Bessel's correction - Wikipediaen.wikipedia.org
- Plus 2: Luyện đọc điền và đọc hiểu chuyên sâu (2024)ngoaingu24h.vn