在 libtorch-C++ 中裁剪梯度的范数

Clip the norm of the gradient in libtorch-C++

有没有API来裁剪网络的梯度?或者,我需要发展自己?

最好的, 阿夫欣

我找到了一个: Tensorat::clamp(const Tensor &self, c10::optional<Scalar> min = c10::nullopt, c10::optional<Scalar> max = c10::nullopt),虽然我自己也实现了。