當前位置: 首頁>>代碼示例>>Python>>正文


Python training_ops.apply_gradient_descent方法代碼示例

本文整理匯總了Python中tensorflow.python.training.training_ops.apply_gradient_descent方法的典型用法代碼示例。如果您正苦於以下問題:Python training_ops.apply_gradient_descent方法的具體用法?Python training_ops.apply_gradient_descent怎麽用?Python training_ops.apply_gradient_descent使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在tensorflow.python.training.training_ops的用法示例。


在下文中一共展示了training_ops.apply_gradient_descent方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: _apply_dense

# 需要導入模塊: from tensorflow.python.training import training_ops [as 別名]
# 或者: from tensorflow.python.training.training_ops import apply_gradient_descent [as 別名]
def _apply_dense(self, grad, var):
        momentum_buffer = self.get_slot(var, "momentum")
        learning_rate = math_ops.cast(self._learning_rate_tensor, var.dtype.base_dtype)
        momentum = math_ops.cast(self._momentum_tensor, var.dtype.base_dtype)
        nu = math_ops.cast(self._nu_tensor, var.dtype.base_dtype)

        momentum_op = training_ops.apply_momentum(
            var,
            momentum_buffer,
            nu * (1.0 - momentum) * learning_rate,
            grad,
            momentum,
            use_locking=self._use_locking,
            use_nesterov=False,
        ).op

        with ops.control_dependencies([momentum_op]):
            gd_op = training_ops.apply_gradient_descent(
                var, (1.0 - nu) * learning_rate, grad, use_locking=self._use_locking
            ).op

        return control_flow_ops.group(momentum_op, gd_op) 
開發者ID:facebookresearch,項目名稱:qhoptim,代碼行數:24,代碼來源:qhm.py

示例2: _apply_dense

# 需要導入模塊: from tensorflow.python.training import training_ops [as 別名]
# 或者: from tensorflow.python.training.training_ops import apply_gradient_descent [as 別名]
def _apply_dense(self, grad, var):
    return training_ops.apply_gradient_descent(
        var,
        math_ops.cast(self._learning_rate_tensor, var.dtype.base_dtype),
        grad,
        use_locking=self._use_locking).op 
開發者ID:ryfeus,項目名稱:lambda-packs,代碼行數:8,代碼來源:gradient_descent.py

示例3: _testTypes

# 需要導入模塊: from tensorflow.python.training import training_ops [as 別名]
# 或者: from tensorflow.python.training.training_ops import apply_gradient_descent [as 別名]
def _testTypes(self, x, alpha, delta, use_gpu=None):
    self.setUp()
    with self.test_session(use_gpu=use_gpu):
      var = variables.Variable(x)
      variables.global_variables_initializer().run()
      self.assertAllCloseAccordingToType(x, var.eval())
      apply_sgd = training_ops.apply_gradient_descent(var, alpha, delta)
      out = apply_sgd.eval()
      self.assertShapeEqual(out, apply_sgd)
      self.assertAllCloseAccordingToType(x - alpha * delta, out) 
開發者ID:tobegit3hub,項目名稱:deep_image_model,代碼行數:12,代碼來源:training_ops_test.py


注:本文中的tensorflow.python.training.training_ops.apply_gradient_descent方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。