SuMarsss

Results 5 comments of SuMarsss

> special_vocab_list When I tried the label.vocal as you said , another error occured. > InvalidArgumentError (see above for traceback): Found Inf or NaN global norm. : Tensor had NaN...

I have fiix the buged, but I want do output f1_score and precison

Sorry, I thought I have fixed the gradient exploding issue but it occured again. `2019-07-11 10:06:26.659641: E tensorflow/core/kernels/check_numerics_op.cc:185] abnormal_detected_host @0x7f65eb46c500 = {1, 0} Found Inf or NaN global norm.` I...

我的意思是detach就可以截断grad反向传播到上个序列,即使hidden的requires_grad=False。这里为什么要指定requires_grad=True?

我认为这里的参数requires_grad=True是多余的,hidden不需要grad。 1. requires_grad=True 不能起到阻止back prop的作用,detach才能起到阻止back prop的作用。训练时,将hidden的requires_grad设置为False,代码依然可以正确运行。 2. 从整段代码上来看,hidden不是权重,应该不需要grad,torch里应该只有权重tensor才需要设置requires_grad=True。 3. 如果需要back prop追踪到第一个seq的初始hidden,也只需要loss.backward(retain_graph=True),并不需要设置hidden的requires_grad=True