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


Python training.AdagradOptimizer方法代碼示例

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


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

示例1: _centered_bias_step

# 需要導入模塊: from tensorflow.python.training import training [as 別名]
# 或者: from tensorflow.python.training.training import AdagradOptimizer [as 別名]
def _centered_bias_step(centered_bias, logits_dimension, labels, loss_fn):
  """Creates and returns training op for centered bias."""
  if (logits_dimension is None) or (logits_dimension < 1):
    raise ValueError("Invalid logits_dimension %s." % logits_dimension)
  with ops.name_scope(None, "centered_bias_step", (labels,)) as name:
    batch_size = array_ops.shape(labels)[0]
    logits = array_ops.reshape(
        array_ops.tile(centered_bias, (batch_size,)),
        (batch_size, logits_dimension))
    with ops.name_scope(None, "centered_bias", (labels, logits)):
      centered_bias_loss = math_ops.reduce_mean(
          loss_fn(logits, labels), name="training_loss")
  # Learn central bias by an optimizer. 0.1 is a convervative lr for a
  # single variable.
  return training.AdagradOptimizer(0.1).minimize(
      centered_bias_loss, var_list=(centered_bias,), name=name) 
開發者ID:abhisuri97,項目名稱:auto-alt-text-lambda-api,代碼行數:18,代碼來源:head.py

示例2: _centered_bias_step

# 需要導入模塊: from tensorflow.python.training import training [as 別名]
# 或者: from tensorflow.python.training.training import AdagradOptimizer [as 別名]
def _centered_bias_step(centered_bias, batch_size, labels, loss_fn, weights):
  """Creates and returns training op for centered bias."""
  with ops.name_scope(None, "centered_bias_step", (labels,)) as name:
    logits_dimension = array_ops.shape(centered_bias)[0]
    logits = array_ops.reshape(
        array_ops.tile(centered_bias, (batch_size,)),
        (batch_size, logits_dimension))
    with ops.name_scope(None, "centered_bias", (labels, logits)):
      centered_bias_loss = math_ops.reduce_mean(
          loss_fn(labels, logits, weights), name="training_loss")
  # Learn central bias by an optimizer. 0.1 is a convervative lr for a
  # single variable.
  return training.AdagradOptimizer(0.1).minimize(
      centered_bias_loss, var_list=(centered_bias,), name=name) 
開發者ID:ryfeus,項目名稱:lambda-packs,代碼行數:16,代碼來源:head.py

示例3: _centered_bias_step

# 需要導入模塊: from tensorflow.python.training import training [as 別名]
# 或者: from tensorflow.python.training.training import AdagradOptimizer [as 別名]
def _centered_bias_step(labels, loss_fn, num_label_columns):
  centered_bias = ops.get_collection(_CENTERED_BIAS)
  batch_size = array_ops.shape(labels)[0]
  logits = array_ops.reshape(
      array_ops.tile(centered_bias[0], [batch_size]),
      [batch_size, num_label_columns])
  loss = loss_fn(logits, labels)
  return train.AdagradOptimizer(0.1).minimize(loss, var_list=centered_bias) 
開發者ID:tobegit3hub,項目名稱:deep_image_model,代碼行數:10,代碼來源:dnn.py

示例4: _centered_bias_step

# 需要導入模塊: from tensorflow.python.training import training [as 別名]
# 或者: from tensorflow.python.training.training import AdagradOptimizer [as 別名]
def _centered_bias_step(logits_dimension, weight_collection, labels,
                        train_loss_fn):
  """Creates and returns training op for centered bias."""
  centered_bias = ops.get_collection(weight_collection)
  batch_size = array_ops.shape(labels)[0]
  logits = array_ops.reshape(
      array_ops.tile(centered_bias[0], [batch_size]),
      [batch_size, logits_dimension])
  with ops.name_scope(None, "centered_bias", (labels, logits)):
    centered_bias_loss = math_ops.reduce_mean(
        train_loss_fn(logits, labels), name="training_loss")
  # Learn central bias by an optimizer. 0.1 is a convervative lr for a
  # single variable.
  return training.AdagradOptimizer(0.1).minimize(
      centered_bias_loss, var_list=centered_bias) 
開發者ID:tobegit3hub,項目名稱:deep_image_model,代碼行數:17,代碼來源:head.py


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