-0.9955 ** 0.0448
Out[11]: -0.9997979654463205
torch.Tensor([-0.9955]) ** torch.Tensor([0.0448])
Out[16]: tensor([nan])
I want to use pytorch
get the number -0.9997979654463205
. Thanks.
-0.9955 ** 0.0448
Out[11]: -0.9997979654463205
torch.Tensor([-0.9955]) ** torch.Tensor([0.0448])
Out[16]: tensor([nan])
I want to use pytorch
get the number -0.9997979654463205
. Thanks.
The plain Python code calculates:
-(0.9955 ** 0.0448)
> -0.9997979654463205
While you are trying to calculate
(-0.9955) ** 0.0448
> (0.989911956308302+0.14025081271947198j)
in PyTorch, which is a complex number.
If you want the first output in PyTorch, just use:
-1.0 * torch.tensor([0.9955]) ** torch.tensor([0.0448])
> tensor([-0.9998])
Oh, thanks.
It’s my problem that I didn’t notice the priorities of -
and **
when writing the demo, but your second demo is really what I’m trying to say, thank you very much!
If I write demo correctly, I guess I would understand the problem.