Rename map in control_flow_ops to map_fn, to avoid name conflict with Python's native 'map' function. This also fixes the bug with control_flow_ops.case

Change: 115472163
This commit is contained in:
A. Unique TensorFlower 2016-02-24 11:12:13 -08:00 committed by TensorFlower Gardener
parent 6b2c0012d1
commit 57df84c47e
2 changed files with 4 additions and 4 deletions

View File

@ -1198,7 +1198,7 @@ class ControlFlowTest(tf.test.TestCase):
with self.test_session(): with self.test_session():
nums = [1, 2, 3, 4, 5, 6] nums = [1, 2, 3, 4, 5, 6]
elems = tf.constant(nums, name="data") elems = tf.constant(nums, name="data")
r = control_flow_ops.map( r = control_flow_ops.map_fn(
lambda x: tf.mul(tf.add(x, 3), 2), elems) lambda x: tf.mul(tf.add(x, 3), 2), elems)
self.assertAllEqual(np.array([(x + 3) * 2 for x in nums]), r.eval()) self.assertAllEqual(np.array([(x + 3) * 2 for x in nums]), r.eval())

View File

@ -1885,8 +1885,8 @@ def foldr(fn, elems, initializer=None, name=None):
return r_a return r_a
def map(fn, elems, dtype=None, name=None): def map_fn(fn, elems, dtype=None, name=None):
"""The map operator on on the unpacked tensors of a tensor. """The map operator on the unpacked tensors of a tensor.
This map operator applies the function `fn` to a sequence of elements This map operator applies the function `fn` to a sequence of elements
from right to left. The elements are made of the tensors unpacked from from right to left. The elements are made of the tensors unpacked from
@ -1908,7 +1908,7 @@ def map(fn, elems, dtype=None, name=None):
Example: Example:
```python ```python
elems = [1, 2, 3, 4, 5, 6] elems = [1, 2, 3, 4, 5, 6]
squares = map(lambda x: x * x, elems) squares = map_fn(lambda x: x * x, elems)
``` ```
""" """
with ops.op_scope([elems], name, "map") as name: with ops.op_scope([elems], name, "map") as name: