pytorch中有张量的幂函数吗?

Lig*_*ght -1 numpy neural-network deep-learning pytorch

numpy.powerpytorch 中有类似的吗?

该函数基本上将第一个张量中的每个元素计算为第二个张量中每个对应元素所表示的幂。

Sha*_*hai 5

您正在寻找torch.pow.

正如@Szymon Maszke提到的,您还可以使用**运算符:

y = torch.pow(x, y)
# the same as
y = x ** y
# and also the same as
y = x.pow(y)
Run Code Online (Sandbox Code Playgroud)

其中y可以是标量或张量,其形状可广播到 的x形状。