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

Python array_ops.placeholder_v2函数代码示例

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

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



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

示例1: testTensorStr

  def testTensorStr(self):
    a = array_ops.placeholder_v2(tf.float32, shape=None, name="a")
    self.assertEqual("<tf.Tensor 'a:0' shape=<unknown> dtype=float32>", repr(a))

    b = array_ops.placeholder_v2(tf.int32, shape=(32, 40), name="b")
    self.assertEqual("<tf.Tensor 'b:0' shape=(32, 40) dtype=int32>", repr(b))

    c = array_ops.placeholder_v2(tf.qint32, shape=(32, None, 2), name="c")
    self.assertEqual("<tf.Tensor 'c:0' shape=(32, ?, 2) dtype=qint32>", repr(c))
开发者ID:821760408-sp,项目名称:tensorflow,代码行数:9,代码来源:constant_op_test.py


示例2: testControlDependency

 def testControlDependency(self):
   with self.test_session():
     p = array_ops.placeholder_v2(dtypes_lib.int32, shape=[], name="p")
     with ops.control_dependencies([p]):
       c = constant_op.constant(5, dtypes_lib.int32)
     d = math_ops.multiply(p, c)
     val = np.array(2).astype(np.int)
     self.assertEqual(10, d.eval(feed_dict={p: val}))
开发者ID:AliMiraftab,项目名称:tensorflow,代码行数:8,代码来源:constant_op_test.py


示例3: testControlDependency

 def testControlDependency(self):
   with self.test_session():
     p = array_ops.placeholder_v2(tf.int32, shape=[], name="p")
     with tf.control_dependencies([p]):
       c = tf.constant(5, tf.int32)
     d = tf.mul(p, c)
     val = np.array(2).astype(np.int)
     self.assertEqual(10, d.eval(feed_dict={p: val}))
开发者ID:821760408-sp,项目名称:tensorflow,代码行数:8,代码来源:constant_op_test.py


示例4: testPartialShape

    def testPartialShape(self):
        with self.test_session():
            p = array_ops.placeholder_v2(tf.float32, shape=[None, 3], name="p")
            p_identity = tf.identity(p)
            feed_array = np.random.rand(10, 3)
            self.assertAllClose(p_identity.eval(feed_dict={p: feed_array}), feed_array)

            with self.assertRaisesWithPredicateMatch(ValueError, lambda e: "Cannot feed value of shape" in str(e)):
                p_identity.eval(feed_dict={p: feed_array[:5, :2]})
开发者ID:brchiu,项目名称:tensorflow,代码行数:9,代码来源:constant_op_test.py


示例5: testUnknownShape

 def testUnknownShape(self):
     with self.test_session():
         p = array_ops.placeholder_v2(tf.float32, shape=None, name="p")
         p_identity = tf.identity(p)
         # can feed anything
         feed_array = np.random.rand(10, 3)
         self.assertAllClose(p_identity.eval(feed_dict={p: feed_array}), feed_array)
         feed_array = np.random.rand(4, 2, 5)
         self.assertAllClose(p_identity.eval(feed_dict={p: feed_array}), feed_array)
开发者ID:brchiu,项目名称:tensorflow,代码行数:9,代码来源:constant_op_test.py


示例6: testDtype

    def testDtype(self):
        with self.test_session():
            p = array_ops.placeholder_v2(tf.float32, shape=None, name="p")
            p_identity = tf.identity(p)
            feed_array = np.random.rand(10, 10)
            self.assertAllClose(p_identity.eval(feed_dict={p: feed_array}), feed_array)

            with self.assertRaisesOpError("must feed a value for placeholder tensor 'p' with dtype float"):
                p_identity.eval()
开发者ID:brchiu,项目名称:tensorflow,代码行数:9,代码来源:constant_op_test.py


示例7: testShape

    def testShape(self):
        with self.test_session():
            p = array_ops.placeholder_v2(tf.float32, shape=(10, 10), name="p")
            p_identity = tf.identity(p)
            feed_array = np.random.rand(10, 10)
            self.assertAllClose(p_identity.eval(feed_dict={p: feed_array}), feed_array)

            with self.assertRaisesOpError(
                "must feed a value for placeholder tensor 'p' with dtype float and " r"shape \[10,10\]"
            ):
                p_identity.eval()

            with self.assertRaisesWithPredicateMatch(ValueError, lambda e: "Cannot feed value of shape" in str(e)):
                p_identity.eval(feed_dict={p: feed_array[:5, :5]})
开发者ID:brchiu,项目名称:tensorflow,代码行数:14,代码来源:constant_op_test.py


示例8: testBadShape

 def testBadShape(self):
   with self.assertRaises(ValueError):
     array_ops.placeholder_v2(tf.float32, shape=(-1, 10))
开发者ID:821760408-sp,项目名称:tensorflow,代码行数:3,代码来源:constant_op_test.py


示例9: testScalarShape

 def testScalarShape(self):
   with self.test_session():
     p = array_ops.placeholder_v2(tf.float32, shape=[], name="p")
     p_identity = tf.identity(p)
     self.assertAllClose(p_identity.eval(feed_dict={p: 5}), 5)
开发者ID:821760408-sp,项目名称:tensorflow,代码行数:5,代码来源:constant_op_test.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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