本文整理匯總了Python中tensorflow.python.training.training_ops.sparse_apply_adagrad_da方法的典型用法代碼示例。如果您正苦於以下問題:Python training_ops.sparse_apply_adagrad_da方法的具體用法?Python training_ops.sparse_apply_adagrad_da怎麽用?Python training_ops.sparse_apply_adagrad_da使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類tensorflow.python.training.training_ops
的用法示例。
在下文中一共展示了training_ops.sparse_apply_adagrad_da方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: _apply_sparse
# 需要導入模塊: from tensorflow.python.training import training_ops [as 別名]
# 或者: from tensorflow.python.training.training_ops import sparse_apply_adagrad_da [as 別名]
def _apply_sparse(self, grad, var):
g_acc = self.get_slot(var, "gradient_accumulator")
gg_acc = self.get_slot(var, "gradient_squared_accumulator")
# Performance optimization so that worker creates a copy of the global step
# to avoid overloading the parameter server holding the global step.
with ops.device(grad[0].device):
global_step = array_ops.identity(self._global_step) + 1
return training_ops.sparse_apply_adagrad_da(
var,
g_acc,
gg_acc,
grad.values,
grad.indices,
math_ops.cast(self._learning_rate_tensor, var.dtype.base_dtype),
math_ops.cast(self._l1_regularization_strength, var.dtype.base_dtype),
math_ops.cast(self._l2_regularization_strength, var.dtype.base_dtype),
global_step,
use_locking=self._use_locking)
示例2: _apply_sparse
# 需要導入模塊: from tensorflow.python.training import training_ops [as 別名]
# 或者: from tensorflow.python.training.training_ops import sparse_apply_adagrad_da [as 別名]
def _apply_sparse(self, grad, var):
g_acc = self.get_slot(var, "gradient_accumulator")
gg_acc = self.get_slot(var, "gradient_squared_accumulator")
with ops.device(var.device):
global_step = array_ops.identity(self._global_step_on_worker)
return training_ops.sparse_apply_adagrad_da(
var,
g_acc,
gg_acc,
grad.values,
grad.indices,
math_ops.cast(self._learning_rate_tensor, var.dtype.base_dtype),
math_ops.cast(self._l1_regularization_strength, var.dtype.base_dtype),
math_ops.cast(self._l2_regularization_strength, var.dtype.base_dtype),
global_step,
use_locking=self._use_locking)
開發者ID:PacktPublishing,項目名稱:Serverless-Deep-Learning-with-TensorFlow-and-AWS-Lambda,代碼行數:18,代碼來源:adagrad_da.py