当前位置: 首页>>代码示例>>Python>>正文


Python check_ops.assert_rank_in函数代码示例

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


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

示例1: test_raises_if_rank_is_not_scalar_static

 def test_raises_if_rank_is_not_scalar_static(self):
   tensor = constant_op.constant((42, 43), name="my_tensor")
   desired_ranks = (
       np.array(1, dtype=np.int32),
       np.array((2, 1), dtype=np.int32))
   with self.assertRaisesRegexp(ValueError, "Rank must be a scalar"):
     check_ops.assert_rank_in(tensor, desired_ranks)
开发者ID:AbhinavJain13,项目名称:tensorflow,代码行数:7,代码来源:check_ops_test.py

示例2: test_rank_one_tensor_raises_if_rank_mismatches_static_rank

 def test_rank_one_tensor_raises_if_rank_mismatches_static_rank(self):
   with self.test_session():
     tensor_rank1 = constant_op.constant((42, 43), name="my_tensor")
     with self.assertRaisesRegexp(ValueError, "my_tensor.*rank"):
       with ops.control_dependencies([
           check_ops.assert_rank_in(tensor_rank1, (0, 2))]):
         array_ops.identity(tensor_rank1).eval()
开发者ID:1000sprites,项目名称:tensorflow,代码行数:7,代码来源:check_ops_test.py

示例3: test_rank_one_tensor_doesnt_raise_if_rank_matches_static_rank

 def test_rank_one_tensor_doesnt_raise_if_rank_matches_static_rank(self):
   with self.test_session():
     tensor_rank1 = constant_op.constant([42, 43], name="my_tensor")
     for desired_ranks in ((0, 1, 2), (1, 0, 2), (1, 2, 0)):
       with ops.control_dependencies([
           check_ops.assert_rank_in(tensor_rank1, desired_ranks)]):
         array_ops.identity(tensor_rank1).eval()
开发者ID:1000sprites,项目名称:tensorflow,代码行数:7,代码来源:check_ops_test.py

示例4: test_rank_zero_tensor_doesnt_raise_if_rank_matches_dynamic_rank

 def test_rank_zero_tensor_doesnt_raise_if_rank_matches_dynamic_rank(self):
   with self.test_session():
     tensor_rank0 = array_ops.placeholder(dtypes.float32, name="my_tensor")
     for desired_ranks in ((0, 1, 2), (1, 0, 2), (1, 2, 0)):
       with ops.control_dependencies([
           check_ops.assert_rank_in(tensor_rank0, desired_ranks)]):
         array_ops.identity(tensor_rank0).eval(feed_dict={tensor_rank0: 42.0})
开发者ID:1000sprites,项目名称:tensorflow,代码行数:7,代码来源:check_ops_test.py

示例5: test_rank_zero_tensor_raises_if_rank_mismatch_dynamic_rank

 def test_rank_zero_tensor_raises_if_rank_mismatch_dynamic_rank(self):
   with self.test_session():
     tensor_rank0 = array_ops.placeholder(dtypes.float32, name="my_tensor")
     with ops.control_dependencies([
         check_ops.assert_rank_in(tensor_rank0, (1, 2), message="fail")]):
       with self.assertRaisesOpError("fail.*my_tensor.*rank"):
         array_ops.identity(tensor_rank0).eval(feed_dict={tensor_rank0: 42.0})
开发者ID:1000sprites,项目名称:tensorflow,代码行数:7,代码来源:check_ops_test.py

示例6: test_rank_zero_tensor_raises_if_rank_mismatch_static_rank

 def test_rank_zero_tensor_raises_if_rank_mismatch_static_rank(self):
   tensor_rank0 = constant_op.constant(42, name="my_tensor")
   with self.assertRaisesRegexp(
       ValueError, "fail.*must have rank.*in.*1.*2"):
     with ops.control_dependencies([
         check_ops.assert_rank_in(tensor_rank0, (1, 2), message="fail")]):
       self.evaluate(array_ops.identity(tensor_rank0))
开发者ID:AbhinavJain13,项目名称:tensorflow,代码行数:7,代码来源:check_ops_test.py

示例7: test_rank_one_tensor_raises_if_rank_mismatches_dynamic_rank

 def test_rank_one_tensor_raises_if_rank_mismatches_dynamic_rank(self):
   with self.test_session():
     tensor_rank1 = array_ops.placeholder(dtypes.float32, name="my_tensor")
     with ops.control_dependencies([
         check_ops.assert_rank_in(tensor_rank1, (0, 2))]):
       with self.assertRaisesOpError("my_tensor.*rank"):
         array_ops.identity(tensor_rank1).eval(feed_dict={
             tensor_rank1: (42.0, 43.0)
         })
开发者ID:1000sprites,项目名称:tensorflow,代码行数:9,代码来源:check_ops_test.py

示例8: test_raises_if_rank_is_not_integer_dynamic

 def test_raises_if_rank_is_not_integer_dynamic(self):
   with self.test_session():
     tensor = constant_op.constant(
         (42, 43), dtype=dtypes.float32, name="my_tensor")
     rank_tensor = array_ops.placeholder(dtypes.float32, name="rank_tensor")
     with self.assertRaisesRegexp(TypeError,
                                  "must be of type <dtype: 'int32'>"):
       with ops.control_dependencies(
           [check_ops.assert_rank_in(tensor, (1, rank_tensor))]):
         array_ops.identity(tensor).eval(feed_dict={rank_tensor: .5})
开发者ID:1000sprites,项目名称:tensorflow,代码行数:10,代码来源:check_ops_test.py

示例9: test_raises_if_rank_is_not_scalar_dynamic

 def test_raises_if_rank_is_not_scalar_dynamic(self):
   with self.test_session():
     tensor = constant_op.constant(
         (42, 43), dtype=dtypes.float32, name="my_tensor")
     desired_ranks = (
         array_ops.placeholder(dtypes.int32, name="rank0_tensor"),
         array_ops.placeholder(dtypes.int32, name="rank1_tensor"))
     with self.assertRaisesOpError("Rank must be a scalar"):
       with ops.control_dependencies(
           (check_ops.assert_rank_in(tensor, desired_ranks),)):
         array_ops.identity(tensor).eval(feed_dict={
             desired_ranks[0]: 1,
             desired_ranks[1]: [2, 1],
         })
开发者ID:1000sprites,项目名称:tensorflow,代码行数:14,代码来源:check_ops_test.py

示例10: test_raises_if_rank_is_not_integer_static

 def test_raises_if_rank_is_not_integer_static(self):
   with self.test_session():
     tensor = constant_op.constant((42, 43), name="my_tensor")
     with self.assertRaisesRegexp(TypeError,
                                  "must be of type <dtype: 'int32'>"):
       check_ops.assert_rank_in(tensor, (1, .5,))
开发者ID:1000sprites,项目名称:tensorflow,代码行数:6,代码来源:check_ops_test.py

示例11: test_rank_zero_tensor_doesnt_raise_if_rank_matches_static_rank

 def test_rank_zero_tensor_doesnt_raise_if_rank_matches_static_rank(self):
   tensor_rank0 = constant_op.constant(42, name="my_tensor")
   for desired_ranks in ((0, 1, 2), (1, 0, 2), (1, 2, 0)):
     with ops.control_dependencies([
         check_ops.assert_rank_in(tensor_rank0, desired_ranks)]):
       self.evaluate(array_ops.identity(tensor_rank0))
开发者ID:AbhinavJain13,项目名称:tensorflow,代码行数:6,代码来源:check_ops_test.py


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