梯度截断的tensorflow实现


gradients = optimizer.compute_gradients(loss, var_list)
capped_gradients = [(tf.clip_by_value(grad, -5., 5.), var) for grad, var in gradients if grad is not None]
train_op = optimizer.apply_gradients(capped_gradients)

©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页