torch.pow¶
- torch.pow(input, exponent, *, out=None) Tensor¶
- Takes the power of each element in - inputwith- exponentand returns a tensor with the result.- exponentcan be either a single- floatnumber or a Tensor with the same number of elements as- input.- When - exponentis a scalar value, the operation applied is:- When - exponentis a tensor, the operation applied is:- When - exponentis a tensor, the shapes of- inputand- exponentmust be broadcastable.- Parameters:
- Keyword Arguments:
- out (Tensor, optional) – the output tensor. 
 - Example: - >>> a = torch.randn(4) >>> a tensor([ 0.4331, 1.2475, 0.6834, -0.2791]) >>> torch.pow(a, 2) tensor([ 0.1875, 1.5561, 0.4670, 0.0779]) >>> exp = torch.arange(1., 5.) >>> a = torch.arange(1., 5.) >>> a tensor([ 1., 2., 3., 4.]) >>> exp tensor([ 1., 2., 3., 4.]) >>> torch.pow(a, exp) tensor([ 1., 4., 27., 256.]) - torch.pow(self, exponent, *, out=None) Tensor
 - selfis a scalar- floatvalue, and- exponentis a tensor. The returned tensor- outis of the same shape as- exponent- The operation applied is: - Parameters:
- Keyword Arguments:
- out (Tensor, optional) – the output tensor. 
 - Example: - >>> exp = torch.arange(1., 5.) >>> base = 2 >>> torch.pow(base, exp) tensor([ 2., 4., 8., 16.])