未验证 提交 ea937c1b 编写于 作者: W whs 提交者: GitHub

Change GradientClipByValue to GradientClipByGlobalNorm in ocr attention model. (#3879)

上级 ade6ea8e
...@@ -188,7 +188,7 @@ def attention_train_net(args, data_shape, num_classes): ...@@ -188,7 +188,7 @@ def attention_train_net(args, data_shape, num_classes):
prediction = gru_decoder_with_attention(trg_embedding, encoded_vector, prediction = gru_decoder_with_attention(trg_embedding, encoded_vector,
encoded_proj, decoder_boot, encoded_proj, decoder_boot,
decoder_size, num_classes) decoder_size, num_classes)
fluid.clip.set_gradient_clip(fluid.clip.GradientClipByValue(args.gradient_clip)) fluid.clip.set_gradient_clip(fluid.clip.GradientClipByGlobalNorm(args.gradient_clip))
label_out = fluid.layers.cast(x=label_out, dtype='int64') label_out = fluid.layers.cast(x=label_out, dtype='int64')
_, maxid = fluid.layers.topk(input=prediction, k=1) _, maxid = fluid.layers.topk(input=prediction, k=1)
......
export CUDA_VISIBLE_DEVICES=0 export CUDA_VISIBLE_DEVICES=0
nohup python train.py \ nohup python train.py \
--lr=1.0 \ --lr=1.0 \
--gradient_clip=10 \ --gradient_clip=5.0 \
--model="attention" \ --model="attention" \
--log_period=10 \ --log_period=10 \
> attention.log 2>&1 & > attention.log 2>&1 &
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册