def _clip_dense(self, var):
with self._maybe_colocate_with(var):
updated_var_value = var._ref()
normalized_var = tf.clip_by_norm(
updated_var_value, self._max_norm, self._vars_to_clip_dims[var])
delta = updated_var_value - normalized_var
with tf.colocate_with(var):
return var.assign_sub(delta, use_locking=self._use_locking)
评论列表
文章目录