torch之nn.utils.clip_grad_norm

nn.utils.clip_grad_norm(parameters, max_norm, norm_type=2)

这个函数是根据参数的范数来衡量的

Parameters:

    parameters (Iterable[Variable]) – 一个基于变量的迭代器,会进行归一化(原文:an iterable of Variables that will have gradients normalized)
    max_norm (float or int) – 梯度的最大范数(原文:max norm of the gradients)
    norm_type(float or int) – 规定范数的类型,默认为L2(原文:type of the used p-norm. Can be’inf’for infinity norm)
    Returns:参数的总体范数(作为单个向量来看)(原文:Total norm of the parameters (viewed as a single vector).)

承接Matlab、Python和C++的编程,机器学习、计算机视觉的理论实现及辅导,本科和硕士的均可,咸鱼交易,专业回答请走知乎,详谈请联系QQ号757160542,非诚勿扰。

猜你喜欢

转载自blog.csdn.net/weixin_36670529/article/details/115053625