本文整理汇总了Python中tensorflow.contrib.metrics.python.ops.metric_ops.streaming_mean函数的典型用法代码示例。如果您正苦于以下问题:Python streaming_mean函数的具体用法?Python streaming_mean怎么用?Python streaming_mean使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了streaming_mean函数的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _sigmoid_entropy
def _sigmoid_entropy(probabilities, targets, weights=None):
return metric_ops.streaming_mean(
losses.sigmoid_cross_entropy(probabilities,
_squeeze_and_onehot(
targets,
array_ops.shape(probabilities)[1])),
weights=weights)
示例2: _r2
def _r2(probabilities, targets, weights=None):
targets = math_ops.to_float(targets)
y_mean = math_ops.reduce_mean(targets, 0)
squares_total = math_ops.reduce_sum(math_ops.square(targets - y_mean), 0)
squares_residuals = math_ops.reduce_sum(
math_ops.square(targets - probabilities), 0)
score = 1 - math_ops.reduce_sum(squares_residuals / squares_total)
return metric_ops.streaming_mean(score, weights=weights)
示例3: _r2
def _r2(probabilities, targets):
if targets.get_shape().ndims == 1:
targets = array_ops.expand_dims(targets, -1)
y_mean = math_ops.reduce_mean(targets, 0)
squares_total = math_ops.reduce_sum(math_ops.square(targets - y_mean), 0)
squares_residuals = math_ops.reduce_sum(math_ops.square(targets - probabilities), 0)
score = 1 - math_ops.reduce_sum(squares_residuals / squares_total)
return metric_ops.streaming_mean(score)
示例4: get_eval_ops
def get_eval_ops(self, features, logits, labels, metrics=None):
loss = self.loss(logits, labels, features)
result = {"loss": metric_ops.streaming_mean(loss)}
if metrics:
predictions = self.logits_to_predictions(logits, proba=False)
result.update(
_run_metrics(predictions, labels, metrics,
self.get_weight_tensor(features)))
return result
示例5: build_graph
def build_graph(self, data_paths, batch_size, is_training):
"""Builds generic graph for training or eval."""
tensors = GraphReferences()
_, tensors.examples = util.read_examples(
data_paths,
batch_size,
shuffle=is_training,
num_epochs=None if is_training else 2)
parsed = parse_examples(tensors.examples)
# Build a Graph that computes predictions from the inference model.
logits = inference(parsed['images'], self.hidden1, self.hidden2)
# Add to the Graph the Ops for loss calculation.
loss_value = loss(logits, parsed['labels'])
# Add to the Graph the Ops for accuracy calculation.
accuracy_value = evaluation(logits, parsed['labels'])
# Add to the Graph the Ops that calculate and apply gradients.
if is_training:
tensors.train, tensors.global_step = training(loss_value,
self.learning_rate)
else:
tensors.global_step = tf.Variable(0, name='global_step', trainable=False)
# Add streaming means.
loss_op, loss_update = metric_ops.streaming_mean(loss_value)
accuracy_op, accuracy_update = metric_ops.streaming_mean(accuracy_value)
tf.scalar_summary('accuracy', accuracy_op)
tf.scalar_summary('loss', loss_op)
# HYPERPARAMETER TUNING: Write the objective value.
if not is_training:
tf.scalar_summary('training/hptuning/metric', accuracy_op)
tensors.metric_updates = [loss_update, accuracy_update]
tensors.metric_values = [loss_op, accuracy_op]
return tensors
示例6: _predictions_streaming_mean
def _predictions_streaming_mean(predictions, unused_labels, weights=None):
return metric_ops.streaming_mean(predictions, weights=weights)
示例7: _class_log_loss
def _class_log_loss(probabilities, targets, weights=None):
return metric_ops.streaming_mean(
losses.log_loss(probabilities,
_squeeze_and_onehot(targets,
array_ops.shape(probabilities)[1])),
weights=weights)
示例8: _softmax_entropy
def _softmax_entropy(probabilities, targets, weights=None):
return metric_ops.streaming_mean(losses.sparse_softmax_cross_entropy(
probabilities, math_ops.to_int32(targets)),
weights=weights)
示例9: _top_k
def _top_k(probabilities, targets):
targets = math_ops.to_int32(targets)
if targets.get_shape().ndims > 1:
targets = array_ops.squeeze(targets, squeeze_dims=[1])
return metric_ops.streaming_mean(nn.in_top_k(probabilities, targets, k))
示例10: _softmax_entropy
def _softmax_entropy(probabilities, targets):
return metric_ops.streaming_mean(losses.softmax_cross_entropy(
probabilities, targets))
示例11: _sigmoid_entropy
def _sigmoid_entropy(probabilities, targets):
return metric_ops.streaming_mean(losses.sigmoid_cross_entropy(
probabilities, targets))
示例12: _top_k
def _top_k(probabilities, targets):
return metric_ops.streaming_mean(nn.in_top_k(probabilities,
math_ops.to_int32(targets), k))
示例13: _log_loss
def _log_loss(probabilities, targets):
# targets doesn't have a shape coming in, log_loss isn't too happy about it.
targets = array_ops.reshape(targets, array_ops.shape(probabilities))
return metric_ops.streaming_mean(losses.log_loss(probabilities, targets))