Skip to content

  • 体验新版
    • 正在加载...
  • 登录
  • PaddlePaddle
  • Paddle
  • Issue
  • #24670

P
Paddle
  • 项目概览

PaddlePaddle / Paddle
大约 2 年 前同步成功

通知 2325
Star 20933
Fork 5424
  • 代码
    • 文件
    • 提交
    • 分支
    • Tags
    • 贡献者
    • 分支图
    • Diff
  • Issue 1423
    • 列表
    • 看板
    • 标记
    • 里程碑
  • 合并请求 543
  • Wiki 0
    • Wiki
  • 分析
    • 仓库
    • DevOps
  • 项目成员
  • Pages
P
Paddle
  • 项目概览
    • 项目概览
    • 详情
    • 发布
  • 仓库
    • 仓库
    • 文件
    • 提交
    • 分支
    • 标签
    • 贡献者
    • 分支图
    • 比较
  • Issue 1,423
    • Issue 1,423
    • 列表
    • 看板
    • 标记
    • 里程碑
  • 合并请求 543
    • 合并请求 543
  • Pages
  • 分析
    • 分析
    • 仓库分析
    • DevOps
  • Wiki 0
    • Wiki
  • 成员
    • 成员
  • 收起侧边栏
  • 动态
  • 分支图
  • 创建新Issue
  • 提交
  • Issue看板
已关闭
开放中
Opened 5月 20, 2020 by saxon_zh@saxon_zhGuest

How to do mixed precision training in dygraph mode?

Created by: sbl1996

PaddlePaddle: 1.8.1

I have tried to use optimizer = fluid.contrib.mixed_precision.decorate(optimizer, init_loss_scaling=128.0, use_dynamic_loss_scaling=True) directly, but got the following error while calling model.fit.

I can't find any documentation, examples, or issues of that.

Code to reproduce is here.

Epoch 1/200
---------------------------------------------------------------------------AttributeError                            Traceback (most recent call last)<ipython-input-7-b712d38173b4> in <module>
----> 1 model.fit(train_loader, test_loader, epochs=epochs, save_dir="./checkpoint", save_freq=100, eval_freq=10)
~/work/hapi/hapi/model.py in fit(self, train_data, eval_data, batch_size, epochs, eval_freq, log_freq, save_dir, save_freq, verbose, drop_last, shuffle, num_workers, callbacks)
   1305 
   1306             cbks.on_epoch_begin(epoch)
-> 1307             logs = self._run_one_epoch(train_loader, cbks, 'train')
   1308             cbks.on_epoch_end(epoch, logs)
   1309 
~/work/hapi/hapi/model.py in _run_one_epoch(self, data_loader, callbacks, mode, logs)
   1609             if mode != 'test':
   1610                 outs = getattr(self, mode + '_batch')(data[:len(self._inputs)],
-> 1611                                                       data[len(self._inputs):])
   1612                 # losses
   1613                 loss = outs[0] if self._metrics else outs
~/work/hapi/hapi/model.py in train_batch(self, inputs, labels)
    752               print(loss)
    753         """
--> 754         return self._adapter.train_batch(inputs, labels)
    755 
    756     def eval_batch(self, inputs, labels=None):
~/work/hapi/hapi/model.py in train_batch(self, inputs, labels)
    507             final_loss.backward()
    508 
--> 509         self.model._optimizer.minimize(final_loss)
    510         self.model.clear_gradients()
    511         metrics = []
/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/fluid/contrib/mixed_precision/decorator.py in minimize(self, loss, startup_program, parameter_list, no_grad_set)
    209             startup_program=startup_program,
    210             parameter_list=parameter_list,
--> 211             no_grad_set=no_grad_set)
    212 
    213         optimize_ops = self.apply_gradients(scaled_params_grads)
/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/fluid/contrib/mixed_precision/decorator.py in backward(self, loss, startup_program, parameter_list, no_grad_set, callbacks)
    139         # Change the op_role_var attr for some ops, so that gradients
    140         # transferred across GPUs can be FP16.
--> 141         update_role_var_grad(self._train_program, self._params_grads)
    142         scaled_params_grads = []
    143         for p, g in self._params_grads:
/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/fluid/contrib/mixed_precision/fp16_utils.py in update_role_var_grad(main_prog, params_grads)
    292     OPTIMIZE = core.op_proto_and_checker_maker.OpRole.Optimize
    293     for p, g in params_grads:
--> 294         op = g.op
    295         if g.dtype == core.VarDesc.VarType.FP32 and op.type == 'cast':
    296             role = op.attr('op_role')
AttributeError: 'paddle.fluid.core_avx.VarBase' object has no attribute 'op'
指派人
分配到
无
里程碑
无
分配里程碑
工时统计
无
截止日期
无
标识: paddlepaddle/Paddle#24670
渝ICP备2023009037号

京公网安备11010502055752号

网络110报警服务 Powered by GitLab CE v13.7
开源知识
Git 入门 Pro Git 电子书 在线学 Git
Markdown 基础入门 IT 技术知识开源图谱
帮助
使用手册 反馈建议 博客
《GitCode 隐私声明》 《GitCode 服务条款》 关于GitCode
Powered by GitLab CE v13.7