本文整理汇总了Python中tensorflow.python.ops.control_flow_ops.enter函数的典型用法代码示例。如果您正苦于以下问题:Python enter函数的具体用法?Python enter怎么用?Python enter使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了enter函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: testLoop_2
def testLoop_2(self):
with self.test_session():
zero = tf.constant(0)
one = tf.constant(1)
n = tf.constant(10)
enter_i = control_flow_ops.enter(zero, "foo", False)
enter_one = control_flow_ops.enter(one, "foo", True)
enter_n = control_flow_ops.enter(n, "foo", True)
merge_i = control_flow_ops.merge([enter_i, enter_i])[0]
less_op = tf.less(merge_i, enter_n)
cond_op = control_flow_ops.loop_cond(less_op)
switch_i = control_flow_ops.switch(merge_i, cond_op)
add_i = tf.add(switch_i[1], enter_one)
with tf.device("/gpu:0"):
next_i = control_flow_ops.next_iteration(add_i)
merge_i.op._update_input(1, next_i)
exit_i = control_flow_ops.exit(switch_i[0])
result = exit_i.eval()
self.assertAllEqual(10, result)
开发者ID:hypatiad,项目名称:tensorflow,代码行数:25,代码来源:control_flow_ops_py_test.py
示例2: testLoop_1
def testLoop_1(self):
with self.test_session():
zero = tf.convert_to_tensor(0)
one = tf.convert_to_tensor(1)
n = tf.constant(10)
enter_zero = control_flow_ops.enter(zero, "foo_1", False)
enter_one = control_flow_ops.enter(one, "foo_1", False)
enter_n = control_flow_ops.enter(n, "foo_1", False)
merge_zero = control_flow_ops.merge([enter_zero, enter_zero], name="merge_zero")[0]
merge_one = control_flow_ops.merge([enter_one, enter_one], name="merge_one")[0]
merge_n = control_flow_ops.merge([enter_n, enter_n], name="merge_n")[0]
less_op = tf.less(merge_n, merge_n)
cond_op = control_flow_ops.loop_cond(less_op)
switch_zero = control_flow_ops.switch(merge_zero, cond_op)
switch_one = control_flow_ops.switch(merge_one, cond_op)
switch_n = control_flow_ops.switch(merge_n, cond_op)
next_zero = control_flow_ops.next_iteration(switch_zero[1])
next_one = control_flow_ops.next_iteration(switch_one[1])
next_n = control_flow_ops.next_iteration(switch_n[1])
merge_zero.op._update_input(1, next_zero)
merge_one.op._update_input(1, next_one)
merge_n.op._update_input(1, next_n)
exit_n = control_flow_ops.exit(switch_n[0])
result = exit_n.eval()
self.assertAllEqual(10, result)
开发者ID:peace195,项目名称:tensorflow,代码行数:27,代码来源:control_flow_ops_py_test.py
示例3: testEnterMulExit_1
def testEnterMulExit_1(self):
with self.test_session():
data = tf.constant([1, 2, 3, 4, 5, 6], name="data")
enter_data = control_flow_ops.enter(data, "foo_1", False)
five = tf.constant(5)
enter_five = control_flow_ops.enter(five, "foo_1", False)
mul_op = tf.mul(enter_data, enter_five)
exit_op = control_flow_ops.exit(mul_op)
result = exit_op.eval()
self.assertAllEqual(np.array([x * 5 for x in [1, 2, 3, 4, 5, 6]]), result)
开发者ID:hypatiad,项目名称:tensorflow,代码行数:11,代码来源:control_flow_ops_py_test.py
示例4: testLoop_false
def testLoop_false(self):
with self.test_session():
false = tf.convert_to_tensor(False)
n = tf.constant(10)
enter_false = control_flow_ops.enter(false, "foo_1", False)
enter_n = control_flow_ops.enter(n, "foo_1", False)
merge_n = control_flow_ops.merge([enter_n], name="merge_n")[0]
switch_n = control_flow_ops.switch(merge_n, enter_false)
exit_n = control_flow_ops.exit(switch_n[0])
result = exit_n.eval()
self.assertAllEqual(10, result)
开发者ID:peace195,项目名称:tensorflow,代码行数:14,代码来源:control_flow_ops_py_test.py
示例5: testEnterExit_1
def testEnterExit_1(self):
with self.test_session():
data = tf.constant([1, 2, 3, 4, 5, 6], name="data")
enter_op = control_flow_ops.enter(data, "foo_1", False)
exit_op = control_flow_ops.exit(enter_op)
result = exit_op.eval()
self.assertAllEqual(np.array([1, 2, 3, 4, 5, 6]), result)
开发者ID:hypatiad,项目名称:tensorflow,代码行数:8,代码来源:control_flow_ops_py_test.py
示例6: testRefEnter
def testRefEnter(self):
with self.test_session():
v = tf.Variable(7)
enter_v = control_flow_ops._Enter(v, "foo_1", is_constant=True)
nine = tf.constant(9)
enter_nine = control_flow_ops.enter(nine, "foo_1")
op = tf.assign(enter_v, enter_nine)
v2 = control_flow_ops.with_dependencies([op], enter_v)
v3 = control_flow_ops.exit(v2)
tf.initialize_all_variables().run()
self.assertEqual(9, v3.eval())
开发者ID:hypatiad,项目名称:tensorflow,代码行数:12,代码来源:control_flow_ops_py_test.py
注:本文中的tensorflow.python.ops.control_flow_ops.enter函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论