提交 d9028c7b authored 作者: Frédéric Bastien's avatar Frédéric Bastien 提交者: GitHub

Merge pull request #4632 from shabanian/dtype

ones_like and zeros_like dtype parameter is documented
......@@ -664,17 +664,24 @@ Creating Tensor
===============
.. function:: zeros_like(x)
.. function:: zeros_like(x, dtype=None)
:param x: tensor that has same shape as output
:param x: tensor that has the same shape as output
:param dtype: data-type, optional
By default, it will be x.dtype.
Returns a tensor filled with 0s that has same shape as `x`.
Returns a tensor the shape of x filled with zeros of the type of dtype.
.. function:: ones_like(x)
:param x: tensor that has same shape as output
:param x: tensor that has the same shape as output
:param dtype: data-type, optional
By default, it will be x.dtype.
Returns a tensor filled with 1s that has same shape as `x`.
Returns a tensor the shape of x filled with ones of the type of dtype.
.. function:: zeros(shape, dtype=None)
......
......@@ -2265,7 +2265,17 @@ pprint.assign(fill, printing.FunctionPrinter('fill'))
@constructor
def ones_like(model, dtype=None):
"""equivalent of numpy.ones_like"""
"""equivalent of numpy.ones_like
Parameters
----------
model : tensor
dtype : data-type, optional
Returns
-------
tensor
tensor the shape of model containing ones of the type of dtype.
"""
if dtype is None:
dtype = model.type.dtype
ret = fill(model, constant(1.0, dtype=dtype))
......@@ -2274,7 +2284,18 @@ def ones_like(model, dtype=None):
@constructor
def zeros_like(model, dtype=None):
"""equivalent of numpy.zeros_like"""
"""equivalent of numpy.zeros_like
Parameters
----------
model : tensor
dtype : data-type, optional
Returns
-------
tensor
tensor the shape of model containing zeros of the type of dtype.
"""
if dtype is None:
dtype = model.type.dtype
return fill(model, constant(0.0, dtype=dtype))
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论