Paddle icon indicating copy to clipboard operation
Paddle copied to clipboard

如何获取训练过程中的所有梯度?

Open dashulu opened this issue 7 years ago • 9 comments

如何获取训练中的所有梯度,并且像模型一样保存下来?

dashulu avatar Apr 19 '19 08:04 dashulu

np.array(fluid.global_scope().find_var('embedding_name').get_tensor())

colourful-tree avatar Apr 19 '19 08:04 colourful-tree

@colourful-tree 有批量的接口吗?就像save model一样?

dashulu avatar Apr 19 '19 09:04 dashulu

好像没有哈

colourful-tree avatar Apr 19 '19 09:04 colourful-tree

按照np.array(fluid.global_scope().find_var('embedding_name').get_tensor())****方法,梯度无法获取,显示 image 请问是否有其他方式?

dashulu avatar Apr 22 '19 06:04 dashulu

fluid.default_main_program().list_vars()可以或者所有的Variable,其中name带@GRAD的都是梯度

heavengate avatar Apr 22 '19 06:04 heavengate

@heavengate 通过list_vars()是可以看到user.w@GRAD这个变量的,但是find_var时就是找不到 image

dashulu avatar Apr 22 '19 06:04 dashulu

@heavengate 通过list_vars()是可以看到user.w@GRAD这个变量的,但是find_var时就是找不到 image

list_vars()的时候把var.persistable 打出来看下这个梯度是不是persistable的

heavengate avatar Apr 23 '19 03:04 heavengate

可以将 user.w@GRAD 加到fetch_list中,通过exe.run fetch出来

heavengate avatar Apr 23 '19 12:04 heavengate

Since you haven't replied for more than a year, we have closed this issue/pr. If the problem is not solved or there is a follow-up one, please reopen it at any time and we will continue to follow up. 由于您超过一年未回复,我们将关闭这个issue/pr。 若问题未解决或有后续问题,请随时重新打开,我们会继续跟进。

paddle-bot-old avatar May 22 '20 10:05 paddle-bot-old