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:
parent
6b2c0012d1
commit
57df84c47e
@ -1198,7 +1198,7 @@ class ControlFlowTest(tf.test.TestCase):
|
||||
with self.test_session():
|
||||
nums = [1, 2, 3, 4, 5, 6]
|
||||
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)
|
||||
self.assertAllEqual(np.array([(x + 3) * 2 for x in nums]), r.eval())
|
||||
|
||||
|
@ -1885,8 +1885,8 @@ def foldr(fn, elems, initializer=None, name=None):
|
||||
return r_a
|
||||
|
||||
|
||||
def map(fn, elems, dtype=None, name=None):
|
||||
"""The map operator on on the unpacked tensors of a tensor.
|
||||
def map_fn(fn, elems, dtype=None, name=None):
|
||||
"""The map operator on the unpacked tensors of a tensor.
|
||||
|
||||
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
|
||||
@ -1908,7 +1908,7 @@ def map(fn, elems, dtype=None, name=None):
|
||||
Example:
|
||||
```python
|
||||
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:
|
||||
|
Loading…
Reference in New Issue
Block a user