1.

    if opt.precision:
        scaler = torch.cuda.amp.GradScaler()

2.

        if opt.precision:
            with torch.cuda.amp.autocast():

                        (循环体)训练的函数

3.

        if  opt.precision:

            scaler.scale(loss).backward()
            scaler.step(optimizer)
            scaler.update()

Logo

一站式 AI 云服务平台

更多推荐