gvs = optimizer.compute_gradients(loss) # 计算出梯度和变量值 capped_gvs = [(tf.clip_by_value(grad, -5e+10, 5e+10), var) for grad, var in gvs] # 梯度裁剪 train_op = optimizer.apply_gradients(capped_gvs, global_step=global_step) # 梯度下降
原文地址:https://www.cnblogs.com/callyblog/p/10819276.html
时间: 2024-10-08 09:27:37