我有一个变量,比方说,a
,在之前的一些运算中,它有一些与之相关的梯度.然后我得到了整数b
和c
,它们没有梯度.我想计算最小的a
、b
和c
.MWe如下所示.
import torch
a = torch.tensor([4.], requires_grad=True) # As an example I have defined a leaf node here, in my program I have an actual variable with gradient
b = 5
c = 6
d = torch.min(torch.tensor([a, b, c])) # d does not have gradient associated
我怎么才能用不同的方式写这个,让从a
到d
的梯度流过呢?谢谢.