
Then we print this variable to see the value.Īll right, now that we have our result, let’s double check it manually to make sure we’re comfortable with what was calculated.įirst, let’s reacquaint ourselves with how we calculate the biased standard deviation.įirst, we calculate the mean, then we subtract the mean from each element, then we square the result, and we do a summation over all of the elements, and then we divide the summation result by N, then we take the square root. We’re assigning that value that’s going to be returned to the Python variable pt_biased_std_ex. That means we’re going to be calculating the biased standard deviation. We’re passing in our pt_tensor_ex Python variable and we’re going to set the parameter unbiased as False. Pt_biased_std_ex = torch.std(pt_tensor_ex, unbiased=False) Next, let’s calculate the biased standard deviation of all the elements in the PyTorch tensor by using the torch.std. The first matrix is full of 36s, and the second matrix is full of 72s, just like we defined it. We see that we have one tensor that’s sized 2x3x3 and it’s a PyTorch FloatTensor.

Then we print the pt_tensor_ex Python variable to see what we have. We construct this tensor in this way so that it will be straightforward to calculate the biased standard deviation of the tensor. We use torch.FloatTensor, we pass in the data structure, and we assign it to the Python variable pt_tensor_ex. Now, let’s manually create the PyTorch tensor we’re going to use in this example. We print the PyTorch version we are using.
