提交 65375619 authored 作者: Samira Shabanian's avatar Samira Shabanian

ones_like and zeros_like dtype parameter is documented

上级 e1b37ea4
......@@ -664,17 +664,22 @@ 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
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
Returns a tensor filled with 1s that has same shape as `x`.
:param x: tensor that has the same shape as output
:param dtype: data-type, optional
Returns a tensor the shape of x filled with ones of the type of dtype.
.. function:: fill(a,b)
......
......@@ -2260,7 +2260,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))
......@@ -2269,7 +2279,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 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论