Pytorch函数调用

2024-04-18 01:42:56 发布

您现在位置:Python中文网/ 问答频道 /正文

我试图使用pytorch计算三角函数,但在通过函数调用它时遇到问题,下面是我的代码:-

def func(x,y):
  return torch.exp(torch.sin(x)/x-y)

func(torch.tensor[2,3])



Error:-
TypeError - Traceback (most recent call last)
<ipython-input-16-beb818f912f5> in <module>()
----> 1 func(torch.tensor([2, 3]))

TypeError: newf() missing 1 required positional argument: 'y'

调用函数时,此代码中有什么错误