提交 606b8ce7 authored 作者: Razvan Pascanu's avatar Razvan Pascanu

[scan][coding-style][doc] revamped the map function

上级 aac6cc30
...@@ -81,32 +81,46 @@ def hash_listsDictsTuples(x): ...@@ -81,32 +81,46 @@ def hash_listsDictsTuples(x):
return hash_value return hash_value
def map(fn, sequences, non_sequences = [], # The ``map`` view of Scan Op.
truncate_gradient = -1, go_backwards = False, def map( fn
mode = None, name = None): , sequences
""" Similar behaviour as python map , non_sequences = None
, truncate_gradient = -1
, go_backwards = False
, mode = None
, name = None ):
"""
Similar behaviour as python's map.
:param fn: the function to be applied over the elements in :param fn: The function that ``map`` applies at each iteration step
sequences ( see scan `fn` for more info) (see ``scan`` for more info).
:param sequences: list of arrays over which map should :param sequences: List of sequences over which ``map`` iterates
iterate (see scan for more info) (see ``scan`` for more info).
:param non_sequences: list of other arguments of `fn` over which :param non_sequences: List of arguments passed to ``fn``. ``map`` will
map shouldn't iterate (see scan for more info) not iterate over these arguments (see ``scan`` for
more info).
:param truncate_gradient: see scan for more info :param truncate_gradient: See ``scan``.
:param go_backwards: set to true if you want map to start at the end of the :param go_backwards: Boolean value that decides the direction of
provided arrays in ``sequences`` going towards 0 (back in time) iteration. True means that sequences are parsed
from the end towards the begining, while False
is the other way around.
:param mode: see scan :param mode: See ``scan``.
:param name: see scan :param name: See ``scan``.
""" """
return scan(fn, sequences= sequences, outputs_info = [],non_sequences= non_sequences, return scan( fn = fn
truncate_gradient= truncate_gradient, , sequences = sequences
go_backwards= go_backwards, mode = mode, name = name) , outputs_info = []
, non_sequences = non_sequences
, truncate_gradient = truncate_gradient
, go_backwards = go_backwards
, mode = mode
, name = name )
def reduce(fn, sequences, outputs_info, non_sequences = [], go_backwards = False, def reduce(fn, sequences, outputs_info, non_sequences = [], go_backwards = False,
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论