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

Python distribution_util.assert_close函数代码示例

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

本文整理汇总了Python中tensorflow.contrib.distributions.python.ops.distribution_util.assert_close函数的典型用法代码示例。如果您正苦于以下问题:Python assert_close函数的具体用法?Python assert_close怎么用?Python assert_close使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了assert_close函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: _assert_valid_sample

 def _assert_valid_sample(self, x):
   if not self.validate_args: return x
   return control_flow_ops.with_dependencies([
       check_ops.assert_positive(x),
       distribution_util.assert_close(
           array_ops.ones((), dtype=self.dtype),
           math_ops.reduce_sum(x, reduction_indices=[-1])),
   ], x)
开发者ID:curtiszimmerman,项目名称:tensorflow,代码行数:8,代码来源:dirichlet.py


示例2: testAssertCloseEpsilon

  def testAssertCloseEpsilon(self):
    x = [0., 5, 10, 15, 20]
    # x != y
    y = [0.1, 5, 10, 15, 20]
    # x = z
    z = [1e-8, 5, 10, 15, 20]
    with self.test_session():
      with ops.control_dependencies([distribution_util.assert_close(x, z)]):
        array_ops.identity(x).eval()

      with self.assertRaisesOpError("Condition x ~= y"):
        with ops.control_dependencies([distribution_util.assert_close(x, y)]):
          array_ops.identity(x).eval()

      with self.assertRaisesOpError("Condition x ~= y"):
        with ops.control_dependencies([distribution_util.assert_close(y, z)]):
          array_ops.identity(y).eval()
开发者ID:AlbertXiebnu,项目名称:tensorflow,代码行数:17,代码来源:distribution_util_test.py


示例3: testAssertCloseNonIntegerDtype

  def testAssertCloseNonIntegerDtype(self):
    x = np.array([1., 5, 10, 15, 20], dtype=np.float32)
    y = x + 1e-8
    z = [2., 5, 10, 15, 20]
    with self.test_session():
      with tf.control_dependencies([distribution_util.assert_close(x, y)]):
        tf.identity(x).eval()

      with tf.control_dependencies([distribution_util.assert_close(y, x)]):
        tf.identity(x).eval()

      with self.assertRaisesOpError("Condition x ~= y"):
        with tf.control_dependencies([distribution_util.assert_close(x, z)]):
          tf.identity(x).eval()

      with self.assertRaisesOpError("Condition x ~= y"):
        with tf.control_dependencies([distribution_util.assert_close(y, z)]):
          tf.identity(y).eval()
开发者ID:KalraA,项目名称:tensorflow,代码行数:18,代码来源:distribution_util_test.py


示例4: testAssertCloseIntegerDtype

  def testAssertCloseIntegerDtype(self):
    x = [1, 5, 10, 15, 20]
    y = x
    z = [2, 5, 10, 15, 20]
    with self.test_session():
      with tf.control_dependencies([distribution_util.assert_close(x, y)]):
        tf.identity(x).eval()

      with tf.control_dependencies([distribution_util.assert_close(y, x)]):
        tf.identity(x).eval()

      with self.assertRaisesOpError("Condition x ~= y"):
        with tf.control_dependencies([distribution_util.assert_close(x, z)]):
          tf.identity(x).eval()

      with self.assertRaisesOpError("Condition x ~= y"):
        with tf.control_dependencies([distribution_util.assert_close(y, z)]):
          tf.identity(y).eval()
开发者ID:KalraA,项目名称:tensorflow,代码行数:18,代码来源:distribution_util_test.py


示例5: _assert_valid_sample

 def _assert_valid_sample(self, x):
   if not self.validate_args:
     return x
   return control_flow_ops.with_dependencies([
       check_ops.assert_non_positive(x),
       distribution_util.assert_close(
           array_ops.zeros([], dtype=self.dtype),
           math_ops.reduce_logsumexp(x, axis=[-1])),
   ], x)
开发者ID:arnonhongklay,项目名称:tensorflow,代码行数:9,代码来源:relaxed_onehot_categorical.py


示例6: _check_x

 def _check_x(self, x):
   """Check x for proper shape, values, then return tensor version."""
   x = ops.convert_to_tensor(x, name="x_before_deps")
   candidate_one = math_ops.reduce_sum(x, reduction_indices=[-1])
   one = constant_op.constant(1., self.dtype)
   dependencies = [check_ops.assert_positive(x), check_ops.assert_less(
       x, one, message="x has components greater than or equal to 1"),
                   distribution_util.assert_close(one, candidate_one)
                  ] if self.validate_args else []
   return control_flow_ops.with_dependencies(dependencies, x)
开发者ID:10imaging,项目名称:tensorflow,代码行数:10,代码来源:dirichlet.py


示例7: testAssertCloseNonIntegerDtype

  def testAssertCloseNonIntegerDtype(self):
    x = array_ops.placeholder(dtypes.float32)
    y = x + 1e-8
    z = array_ops.placeholder(dtypes.float32)
    feed_dict = {x: [1., 5, 10, 15, 20], z: [2., 5, 10, 15, 20]}
    with self.test_session():
      with ops.control_dependencies([distribution_util.assert_close(x, y)]):
        array_ops.identity(x).eval(feed_dict=feed_dict)

      with ops.control_dependencies([distribution_util.assert_close(y, x)]):
        array_ops.identity(x).eval(feed_dict=feed_dict)

      with self.assertRaisesOpError("Condition x ~= y"):
        with ops.control_dependencies([distribution_util.assert_close(x, z)]):
          array_ops.identity(x).eval(feed_dict=feed_dict)

      with self.assertRaisesOpError("Condition x ~= y"):
        with ops.control_dependencies([distribution_util.assert_close(y, z)]):
          array_ops.identity(y).eval(feed_dict=feed_dict)
开发者ID:AlbertXiebnu,项目名称:tensorflow,代码行数:19,代码来源:distribution_util_test.py


示例8: _maybe_assert_valid_sample

 def _maybe_assert_valid_sample(self, x):
   """Checks the validity of a sample."""
   if not self.validate_args:
     return x
   return control_flow_ops.with_dependencies([
       check_ops.assert_positive(
           x,
           message="samples must be positive"),
       distribution_util.assert_close(
           array_ops.ones((), dtype=self.dtype),
           math_ops.reduce_sum(x, -1),
           message="sample last-dimension must sum to `1`"),
   ], x)
开发者ID:Jackhuang945,项目名称:tensorflow,代码行数:13,代码来源:dirichlet.py



注:本文中的tensorflow.contrib.distributions.python.ops.distribution_util.assert_close函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python distribution_util.assert_integer_form函数代码示例发布时间:2022-05-27
下一篇:
Python reshape.Reshape类代码示例发布时间: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