提交 7ffcc89b authored 作者: Razvan Pascanu's avatar Razvan Pascanu

docstrings to format_as function

上级 161a3682
...@@ -25,6 +25,14 @@ _logger = logging.getLogger('theano.tensor.tensor_grad') ...@@ -25,6 +25,14 @@ _logger = logging.getLogger('theano.tensor.tensor_grad')
def format_as(use_list, use_tuple, outputs): def format_as(use_list, use_tuple, outputs):
"""
Formats the outputs according to the flags `use_list` and `use_tuple`.
If `use_list` is True, `outputs` is returned as a list (if `outputs`
is not a list or a tuple then it is converted in a one element list)
If `use_tuple` is True, `outputs` is returned as a tuple (if `outputs`
is not a list or a tuple then it is converted into a one element tuple)
Otherwise (if both flags are false), `outputs` is returned.
"""
if (use_list or use_tuple) and not isinstance(outputs, (list, tuple)): if (use_list or use_tuple) and not isinstance(outputs, (list, tuple)):
if use_list: if use_list:
return [outputs] return [outputs]
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论