本文整理汇总了Python中tensorflow.contrib.learn.python.learn.estimators.head._multi_label_head函数的典型用法代码示例。如果您正苦于以下问题:Python _multi_label_head函数的具体用法?Python _multi_label_head怎么用?Python _multi_label_head使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了_multi_label_head函数的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: testMultiLabel
def testMultiLabel(self):
head = head_lib._multi_label_head(n_classes=3)
with tf.Graph().as_default(), tf.Session() as sess:
logits = tf.constant([[1.0, 0.0, 0.0]])
labels = tf.constant([[0, 0, 1]])
model_fn_ops = head.head_ops({}, labels, tf.contrib.learn.ModeKeys.TRAIN, _noop_train_op, logits=logits)
self.assertAlmostEqual(0.89985204, sess.run(model_fn_ops.loss))
开发者ID:yuikns,项目名称:tensorflow,代码行数:7,代码来源:head_test.py
示例2: testMultiLabelWithCenteredBias
def testMultiLabelWithCenteredBias(self):
n_classes = 3
head = head_lib._multi_label_head(
n_classes=n_classes, enable_centered_bias=True,
metric_class_ids=range(n_classes))
with tf.Graph().as_default(), tf.Session():
logits = tf.constant([[1., 0., 0.]])
labels = tf.constant([[0, 0, 1]])
model_fn_ops = head.head_ops({}, labels,
tf.contrib.learn.ModeKeys.TRAIN,
_noop_train_op, logits=logits)
_assert_variables(self, expected_global=(
"centered_bias_weight:0",
"centered_bias_weight/Adagrad:0",
), expected_trainable=(
"centered_bias_weight:0",
))
tf.global_variables_initializer().run()
_assert_summary_tags(self, ["loss",
"centered_bias/bias_0",
"centered_bias/bias_1",
"centered_bias/bias_2"])
expected_loss = .89985204
_assert_metrics(
self, expected_loss, self._expected_eval_metrics(expected_loss),
model_fn_ops)
开发者ID:kdavis-mozilla,项目名称:tensorflow,代码行数:26,代码来源:head_test.py
示例3: testMultiLabelTwoClasses
def testMultiLabelTwoClasses(self):
n_classes = 2
labels = ((0, 1),)
logits = ((1., 0.),)
head = head_lib._multi_label_head(
n_classes=n_classes, metric_class_ids=range(n_classes))
with ops.Graph().as_default(), session.Session():
model_fn_ops = head.create_model_fn_ops(
{}, model_fn.ModeKeys.TRAIN, labels=labels,
train_op_fn=_noop_train_op, logits=logits)
self._assert_output_alternatives(model_fn_ops)
_assert_no_variables(self)
_assert_summary_tags(self, ["loss"])
expected_loss = 1.00320443
_assert_metrics(self, expected_loss, {
"accuracy": 0.,
"auc": 0.,
"loss": expected_loss,
"auc/class0": 1.,
"auc/class1": 0.,
"labels/actual_label_mean/class0": labels[0][0],
"labels/actual_label_mean/class1": labels[0][1],
"labels/logits_mean/class0": logits[0][0],
"labels/logits_mean/class1": logits[0][1],
"labels/prediction_mean/class0": logits[0][0],
"labels/prediction_mean/class1": logits[0][1],
"labels/probability_mean/class0": _sigmoid(logits[0][0]),
"labels/probability_mean/class1": _sigmoid(logits[0][1]),
}, model_fn_ops)
开发者ID:arnonhongklay,项目名称:tensorflow,代码行数:29,代码来源:head_test.py
示例4: testMultiLabelWithLogitsInput
def testMultiLabelWithLogitsInput(self):
n_classes = 3
head = head_lib._multi_label_head(
n_classes=n_classes, metric_class_ids=range(n_classes))
with ops.Graph().as_default(), session.Session():
model_fn_ops = head.create_model_fn_ops(
{}, self._labels, model_fn.ModeKeys.TRAIN, _noop_train_op,
logits_input=((0., 0.),))
w = ("logits/weights:0", "logits/biases:0")
_assert_variables(
self, expected_global=w, expected_model=w, expected_trainable=w)
variables.global_variables_initializer().run()
_assert_summary_tags(self, ["loss"])
expected_loss = .69314718
_assert_metrics(self, expected_loss, {
"accuracy": 2. / 3,
"auc": 2. / 4,
"loss": expected_loss,
"auc/class0": 1.,
"auc/class1": 1.,
"auc/class2": 0.,
"labels/actual_label_mean/class0": self._labels[0][0],
"labels/actual_label_mean/class1": self._labels[0][1],
"labels/actual_label_mean/class2": self._labels[0][2],
"labels/logits_mean/class0": 0.,
"labels/logits_mean/class1": 0.,
"labels/logits_mean/class2": 0.,
"labels/prediction_mean/class0": 0.,
"labels/prediction_mean/class1": 0.,
"labels/prediction_mean/class2": 0.,
"labels/probability_mean/class0": .5,
"labels/probability_mean/class1": .5,
"labels/probability_mean/class2": .5,
}, model_fn_ops)
开发者ID:ivankreso,项目名称:tensorflow,代码行数:34,代码来源:head_test.py
示例5: testMultiLabelWithWeight
def testMultiLabelWithWeight(self):
head = head_lib._multi_label_head(n_classes=3, weight_column_name="label_weight")
with tf.Graph().as_default(), tf.Session() as sess:
features = {"label_weight": tf.constant([0.1])}
logits = tf.constant([[1.0, 0.0, 0.0]])
labels = tf.constant([[0, 0, 1]])
model_fn_ops = head.head_ops(
features, labels, tf.contrib.learn.ModeKeys.TRAIN, _noop_train_op, logits=logits
)
self.assertAlmostEqual(0.089985214, sess.run(model_fn_ops.loss))
开发者ID:yuikns,项目名称:tensorflow,代码行数:10,代码来源:head_test.py
示例6: testMultiLabelWithLogits
def testMultiLabelWithLogits(self):
n_classes = 3
head = head_lib._multi_label_head(
n_classes=n_classes, metric_class_ids=range(n_classes))
with ops.Graph().as_default(), session.Session():
model_fn_ops = head.create_model_fn_ops(
{}, self._labels, model_fn.ModeKeys.TRAIN, _noop_train_op,
logits=self._logits)
_assert_no_variables(self)
_assert_summary_tags(self, ["loss"])
expected_loss = .89985204
_assert_metrics(self, expected_loss,
self._expected_eval_metrics(expected_loss), model_fn_ops)
开发者ID:ivankreso,项目名称:tensorflow,代码行数:13,代码来源:head_test.py
示例7: testMultiLabel
def testMultiLabel(self):
n_classes = 3
head = head_lib._multi_label_head(
n_classes=n_classes, metric_class_ids=range(n_classes))
with tf.Graph().as_default(), tf.Session():
logits = tf.constant(self._logits)
labels = tf.constant(self._labels)
model_fn_ops = head.head_ops({}, labels,
tf.contrib.learn.ModeKeys.TRAIN,
_noop_train_op, logits=logits)
_assert_no_variables(self)
expected_loss = .89985204
_assert_metrics(
self, expected_loss, self._expected_eval_metrics(expected_loss),
model_fn_ops)
开发者ID:Hwhitetooth,项目名称:tensorflow,代码行数:15,代码来源:head_test.py
示例8: testMultiLabelEvalMode
def testMultiLabelEvalMode(self):
n_classes = 3
head = head_lib._multi_label_head(
n_classes=n_classes, metric_class_ids=range(n_classes))
with ops.Graph().as_default(), session.Session():
logits = constant_op.constant([[1., 0., 0.]])
labels = constant_op.constant([[0, 0, 1]])
model_fn_ops = head.head_ops(
{}, labels, model_fn.ModeKeys.EVAL, _noop_train_op, logits=logits)
self.assertIsNone(model_fn_ops.train_op)
_assert_no_variables(self)
_assert_summary_tags(self, ["loss"])
expected_loss = .89985204
_assert_metrics(self, expected_loss,
self._expected_eval_metrics(expected_loss), model_fn_ops)
开发者ID:kadeng,项目名称:tensorflow,代码行数:15,代码来源:head_test.py
示例9: testMultiLabelWithWeight
def testMultiLabelWithWeight(self):
n_classes = 3
head = head_lib._multi_label_head(
n_classes=n_classes, weight_column_name="label_weight",
metric_class_ids=range(n_classes))
with tf.Graph().as_default(), tf.Session():
features = {"label_weight": tf.constant([.1])}
logits = tf.constant([[1., 0., 0.]])
labels = tf.constant([[0, 0, 1]])
model_fn_ops = head.head_ops(features, labels,
tf.contrib.learn.ModeKeys.TRAIN,
_noop_train_op, logits=logits)
_assert_no_variables(self)
_assert_metrics(
self, .089985214, self._expected_eval_metrics(2.69956),
model_fn_ops)
开发者ID:Hwhitetooth,项目名称:tensorflow,代码行数:16,代码来源:head_test.py
示例10: testMultiLabelWithWeight
def testMultiLabelWithWeight(self):
n_classes = 3
head = head_lib._multi_label_head(
n_classes=n_classes,
weight_column_name="label_weight",
metric_class_ids=range(n_classes))
with ops.Graph().as_default(), session.Session():
model_fn_ops = head.create_model_fn_ops(
features={"label_weight": .1},
labels=self._labels,
mode=model_fn.ModeKeys.TRAIN,
train_op_fn=_noop_train_op,
logits=self._logits)
_assert_no_variables(self)
_assert_summary_tags(self, ["loss"])
_assert_metrics(self, .089985214,
self._expected_eval_metrics(2.69956), model_fn_ops)
开发者ID:ivankreso,项目名称:tensorflow,代码行数:17,代码来源:head_test.py
示例11: testMultiLabelWithCenteredBias
def testMultiLabelWithCenteredBias(self):
head = head_lib._multi_label_head(n_classes=3, enable_centered_bias=True)
with tf.Graph().as_default(), tf.Session() as sess:
logits = tf.constant([[1., 0., 0.]])
labels = tf.constant([[0, 0, 1]])
model_fn_ops = head.head_ops({}, labels,
tf.contrib.learn.ModeKeys.TRAIN,
_noop_train_op, logits=logits)
self._assert_metrics(model_fn_ops)
_assert_variables(self, expected_global=(
"centered_bias_weight:0",
"centered_bias_weight/Adagrad:0",
), expected_trainable=(
"centered_bias_weight:0",
))
tf.global_variables_initializer().run()
self.assertAlmostEqual(0.89985204, sess.run(model_fn_ops.loss))
开发者ID:RapidApplicationDevelopment,项目名称:tensorflow,代码行数:17,代码来源:head_test.py
示例12: testMultiLabelWithLabelName
def testMultiLabelWithLabelName(self):
n_classes = 3
label_name = "my_label"
head = head_lib._multi_label_head(
n_classes=n_classes,
label_name=label_name,
metric_class_ids=range(n_classes))
with ops.Graph().as_default(), session.Session():
logits = constant_op.constant([[1., 0., 0.]])
labels = {label_name: constant_op.constant([[0, 0, 1]])}
model_fn_ops = head.head_ops(
{}, labels, model_fn.ModeKeys.TRAIN, _noop_train_op, logits=logits)
_assert_no_variables(self)
_assert_summary_tags(self, ["loss"])
expected_loss = .89985204
_assert_metrics(self, expected_loss,
self._expected_eval_metrics(expected_loss), model_fn_ops)
开发者ID:kadeng,项目名称:tensorflow,代码行数:17,代码来源:head_test.py
注:本文中的tensorflow.contrib.learn.python.learn.estimators.head._multi_label_head函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论