当前位置: 首页>>代码示例>>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;未经允许,请勿转载。