torch.autograd.Function.jvp#
- static Function.jvp(ctx, *grad_inputs)[source]#
定义使用前向模式自动微分来区分操作的公式。
此函数将由所有子类覆盖。它必须接受一个上下文
ctx
作为第一个参数,后面跟着forward()
接收的输入数量(对于 forward 函数的非 tensor 输入将传入 None),并且它应该返回与forward()
的输出数量相同的张量。每个参数是相对于给定输入的梯度,每个返回值应是相对于相应输出的梯度。如果某个输出不是 Tensor,或者函数相对于该输出不可微,您可以仅为该输入传递 None 作为梯度。You can use the
ctx
object to pass any value from the forward to this functions.- 返回类型