本文整理汇总了Python中tensorflow.python.ops.gen_data_flow_ops._stack函数的典型用法代码示例。如果您正苦于以下问题:Python _stack函数的具体用法?Python _stack怎么用?Python _stack使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了_stack函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: _testSameNameStacks
def _testSameNameStacks(self, use_gpu):
with self.test_session(use_gpu=use_gpu):
h1 = gen_data_flow_ops._stack(dtypes.float32, stack_name="foo")
c1 = gen_data_flow_ops._stack_push(h1, 4.0)
h2 = gen_data_flow_ops._stack(dtypes.float32, stack_name="foo")
c2 = gen_data_flow_ops._stack_push(h2, 5.0)
r = c1 + c2
self.assertNotEqual(h1.eval()[1], h2.eval()[1])
开发者ID:AlbertXiebnu,项目名称:tensorflow,代码行数:8,代码来源:stack_ops_test.py
示例2: _testDuplicateStack
def _testDuplicateStack(self, use_gpu):
with self.test_session(use_gpu=use_gpu):
h1 = gen_data_flow_ops._stack(tf.float32, stack_name="foo")
c1 = gen_data_flow_ops._stack_push(h1, 4.0)
h2 = gen_data_flow_ops._stack(tf.float32, stack_name="foo")
c2 = gen_data_flow_ops._stack_push(h2, 5.0)
r = c1 + c2
with self.assertRaises(errors.AlreadyExistsError):
r.eval()
开发者ID:CdricGmd,项目名称:tensorflow,代码行数:9,代码来源:stack_ops_test.py
示例3: _testMultiStack
def _testMultiStack(self, use_gpu):
with self.test_session(use_gpu=use_gpu):
h1 = gen_data_flow_ops._stack(dtypes.float32, stack_name="foo")
c1 = gen_data_flow_ops._stack_push(h1, 4.0)
with ops.control_dependencies([c1]):
c1 = gen_data_flow_ops._stack_pop(h1, dtypes.float32)
h2 = gen_data_flow_ops._stack(dtypes.float32, stack_name="bar")
c2 = gen_data_flow_ops._stack_push(h2, 5.0)
with ops.control_dependencies([c2]):
c2 = gen_data_flow_ops._stack_pop(h2, dtypes.float32)
r = c1 + c2
self.assertAllClose(9.0, r.eval())
开发者ID:AlbertXiebnu,项目名称:tensorflow,代码行数:12,代码来源:stack_ops_test.py
示例4: _testStackWhileSwap
def _testStackWhileSwap(self, use_gpu):
with self.test_session(use_gpu=use_gpu):
n = constant_op.constant(0)
h = gen_data_flow_ops._stack(dtypes.float32, stack_name="foo")
def c(x):
return math_ops.less(x, 10)
def b(x):
with ops.control_dependencies([x]):
a = constant_op.constant(np.ones(2000), dtype=dtypes.float32)
v = gen_data_flow_ops._stack_push(h, a, swap_memory=True)
with ops.control_dependencies([v]):
return math_ops.add(x, 1)
r = control_flow_ops.while_loop(c, b, [n])
v = constant_op.constant(np.zeros(2000), dtype=dtypes.float32)
def c1(x, y):
return math_ops.greater(x, 0)
def b1(x, y):
nx = math_ops.subtract(x, 1)
ny = y + gen_data_flow_ops._stack_pop(h, dtypes.float32)
return [nx, ny]
rx, ry = control_flow_ops.while_loop(
c1, b1, [r, v], [r.get_shape(), tensor_shape.unknown_shape()])
self.assertAllClose(np.ones(2000) * 10.0, ry.eval())
开发者ID:AlbertXiebnu,项目名称:tensorflow,代码行数:30,代码来源:stack_ops_test.py
示例5: _testStackPushPop
def _testStackPushPop(self, use_gpu):
with self.test_session(use_gpu=use_gpu):
h = gen_data_flow_ops._stack(dtypes.float32, stack_name="foo")
c = gen_data_flow_ops._stack_push(h, [[4.0, 5.0]])
with ops.control_dependencies([c]):
c1 = gen_data_flow_ops._stack_pop(h, dtypes.float32)
self.assertAllClose([[4.0, 5.0]], c1.eval())
开发者ID:AlbertXiebnu,项目名称:tensorflow,代码行数:7,代码来源:stack_ops_test.py
示例6: _testPushCloseStack
def _testPushCloseStack(self, use_gpu):
with self.test_session(use_gpu=use_gpu) as sess:
h = gen_data_flow_ops._stack(dtypes.float32, stack_name="foo")
c = gen_data_flow_ops._stack_push(h, [[4.0, 5.0]])
with ops.control_dependencies([c]):
c1 = gen_data_flow_ops._stack_close(h)
sess.run(c1)
开发者ID:AlbertXiebnu,项目名称:tensorflow,代码行数:7,代码来源:stack_ops_test.py
示例7: testWhileStack_1
def testWhileStack_1(self):
with self.test_session():
s = gen_data_flow_ops._stack(tf.int32, stack_name="foo")
i = tf.constant(0)
def c(i):
return tf.less(i, 10)
def b(i):
ni = tf.add(i, 1)
ni = control_flow_ops.with_dependencies([gen_data_flow_ops._stack_push(s, i)], ni)
return ni
r = control_flow_ops.While(c, b, [i], parallel_iterations=1)
x = tf.constant(0)
def c1(i, _):
return tf.greater(i, 0)
def b1(i, x):
ni = tf.sub(i, 1)
nx = x + gen_data_flow_ops._stack_pop(s, tf.int32)
return [ni, nx]
_, rx = control_flow_ops.While(c1, b1, [r, x], parallel_iterations=1)
self.assertEqual(45, rx.eval())
开发者ID:peace195,项目名称:tensorflow,代码行数:27,代码来源:control_flow_ops_py_test.py
示例8: _testStackPushPopSwap
def _testStackPushPopSwap(self, use_gpu):
with self.test_session(use_gpu=use_gpu):
a = np.arange(2000)
x = constant_op.constant(a, dtype=dtypes.float32)
h = gen_data_flow_ops._stack(dtypes.float32, stack_name="foo")
c = gen_data_flow_ops._stack_push(h, x, swap_memory=True)
with ops.control_dependencies([c]):
c1 = gen_data_flow_ops._stack_pop(h, dtypes.float32)
self.assertAllClose(a, c1.eval())
开发者ID:AlbertXiebnu,项目名称:tensorflow,代码行数:9,代码来源:stack_ops_test.py
示例9: _testStackWhileSwap
def _testStackWhileSwap(self, use_gpu):
with self.test_session(use_gpu=use_gpu):
n = tf.constant(0)
h = gen_data_flow_ops._stack(tf.float32, stack_name="foo")
def c(x):
return tf.less(x, 10)
def b(x):
with tf.control_dependencies([x]):
a = tf.constant(np.ones(2000), dtype=tf.float32)
v = gen_data_flow_ops._stack_push(h, a, swap_memory=True)
with tf.control_dependencies([v]):
return tf.add(x, 1)
r = control_flow_ops.While(c, b, [n])
v = tf.constant(np.zeros(2000), dtype=tf.float32)
def c1(x, y):
return tf.greater(x, 0)
def b1(x, y):
nx = tf.sub(x, 1)
ny = y + gen_data_flow_ops._stack_pop(h, tf.float32)
return [nx, ny]
rx, ry = control_flow_ops.While(c1, b1, [r, v])
self.assertAllClose(np.ones(2000) * 10.0, ry.eval())
开发者ID:13683116633,项目名称:tensorflow,代码行数:24,代码来源:stack_ops_test.py
示例10: _testCloseStack
def _testCloseStack(self, use_gpu):
with self.test_session(use_gpu=use_gpu) as sess:
h = gen_data_flow_ops._stack(dtypes.float32, stack_name="foo")
c1 = gen_data_flow_ops._stack_close(h)
sess.run(c1)
开发者ID:AlbertXiebnu,项目名称:tensorflow,代码行数:5,代码来源:stack_ops_test.py
注:本文中的tensorflow.python.ops.gen_data_flow_ops._stack函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论