本文整理匯總了Python中tf_metrics.precision方法的典型用法代碼示例。如果您正苦於以下問題:Python tf_metrics.precision方法的具體用法?Python tf_metrics.precision怎麽用?Python tf_metrics.precision使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類tf_metrics
的用法示例。
在下文中一共展示了tf_metrics.precision方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_precision_op
# 需要導入模塊: import tf_metrics [as 別名]
# 或者: from tf_metrics import precision [as 別名]
def test_precision_op(generator_fn, y_true_all, y_pred_all, pos_indices,
average):
# Precision on the whole dataset
pr_sk = precision_score(
y_true_all, y_pred_all, pos_indices, average=average)
# Create Tensorflow graph
ds = tf.data.Dataset.from_generator(
generator_fn, (tf.int32, tf.int32), ([None], [None]))
y_true, y_pred = ds.make_one_shot_iterator().get_next()
pr_tf = tf_metrics.precision(y_true, y_pred, 4, pos_indices,
average=average)
with tf.Session() as sess:
# Initialize and run the update op on each batch
sess.run(tf.local_variables_initializer())
while True:
try:
sess.run(pr_tf[1])
except OutOfRangeError as e:
break
# Check final value
assert np.allclose(sess.run(pr_tf[0]), pr_sk)
示例2: test_precision
# 需要導入模塊: import tf_metrics [as 別名]
# 或者: from tf_metrics import precision [as 別名]
def test_precision(generator_fn, pos_indices, average):
for y_true, y_pred in generator_fn():
pr_tf = tf_metrics.precision(
y_true, y_pred, 4, pos_indices, average=average)
pr_sk = precision_score(
y_true, y_pred, pos_indices, average=average)
with tf.Session() as sess:
sess.run(tf.local_variables_initializer())
assert np.allclose(sess.run(pr_tf[1]), pr_sk)