本文整理匯總了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)
示例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)
示例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)
示例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)