• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python head._multi_label_head函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python head._regression_head函数代码示例发布时间:2022-05-27
下一篇:
Python head._multi_class_head函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap