深入浅出PaddlePaddle函数——paddle.ones_like
分类目录:《深入浅出PaddlePaddle函数》总目录
相关文章:
· 深入浅出PaddlePaddle函数——paddle.Tensor
· 深入浅出PaddlePaddle函数——paddle.ones
· 深入浅出PaddlePaddle函数——paddle.zeros
· 深入浅出PaddlePaddle函数——paddle.full
· 深入浅出PaddlePaddle函数——paddle.ones_like
· 深入浅出PaddlePaddle函数——paddle.zeros_like
· 深入浅出PaddlePaddle函数——paddle.full_like
返回一个和输入参数x
具有相同形状的数值都为1
的Tensor,数据类型为dtype
或者和x
相同,如果dtype
为None
,则输出Tensor的数据类型与x
相同。
语法
paddle.ones_like(x, dtype=None, name=None)
参数
x
:[Tensor
] 输入的Tensor,数据类型可以是bool
、float16l
、float32l
、float64l
、int32l
、int64
。dtype
:[可选,np.dtype
/str
] 要创建的Tensor的数据类型,可以为bool
、float16
、float32
、float64
、int32
或int64
。如果dtype
为None
,那么数据类型为float32
。name
:[可选,str
] 具体用法请参见Name
,一般无需设置,默认值为None
。
返回值
和x
具有相同形状的数值都为1
的Tensor,数据类型为dtype
或者和x
相同。
实例
import paddlex = paddle.to_tensor([1,2,3])
out1 = paddle.ones_like(x) # [1., 1., 1.]
out2 = paddle.ones_like(x, dtype='int32') # [1, 1, 1]
函数实现
def ones_like(x, dtype=None, name=None):"""Returns a Tensor filled with the value 1, with the same shape anddata type (use ``dtype`` if ``dtype`` is not None) as ``x``.Args:x(Tensor): The input tensor which specifies shape and dtype. Thedtype of ``x`` can be bool, float16, float32, float64, int32, int64.dtype(str|np.dtype, optional): The data type of theoutput tensor. Supported data types: bool, float16, float32, float64,int32, int64. If ``dtype`` is None, the data type is the same as ``x``.Default is None.name(str, optional): For details, please refer to :ref:`api_guide_Name`. Generally, no setting is required. Default: None.Returns:Tensor: A Tensor filled with the value 1, with the same shape anddata type (use ``dtype`` if ``dtype`` is not None) as ``x``.Examples:.. code-block:: pythonimport paddlex = paddle.to_tensor([1,2,3])out1 = paddle.ones_like(x) # [1., 1., 1.]out2 = paddle.ones_like(x, dtype='int32') # [1, 1, 1]"""return full_like(x=x, fill_value=1, dtype=dtype, name=name)
深入浅出PaddlePaddle函数——paddle.ones_like相关推荐
- 深入浅出PaddlePaddle函数——paddle.Tensor
分类目录:<深入浅出PaddlePaddle函数>总目录 相关文章: · 深入浅出TensorFlow2函数--tf.Tensor · 深入浅出Pytorch函数--torch.Tenso ...
- 深入浅出PaddlePaddle函数——paddle.arange
分类目录:<深入浅出PaddlePaddle函数>总目录 相关文章: · 深入浅出TensorFlow2函数--tf.range · 深入浅出Pytorch函数--torch.arange ...
- 深入浅出PaddlePaddle函数——paddle.numel
分类目录:<深入浅出PaddlePaddle函数>总目录 相关文章: · 深入浅出TensorFlow2函数--tf.size · 深入浅出Pytorch函数--torch.numel · ...
- 深入浅出PaddlePaddle函数——paddle.shape
分类目录:<深入浅出PaddlePaddle函数>总目录 语法 paddle.shape(input) 参数 input:[Tensor] 输入的多维Tensor或SelectedRows ...
- 深入浅出Pytorch函数——torch.arange
分类目录:<深入浅出Pytorch函数>总目录 相关文章: · 深入浅出TensorFlow2函数--tf.range · 深入浅出Pytorch函数--torch.arange · 深入 ...
- 深入浅出Pytorch函数——torch.exp
分类目录:<深入浅出Pytorch函数>总目录 相关文章: · 深入浅出TensorFlow2函数--tf.exp · 深入浅出TensorFlow2函数--tf.math.exp · 深 ...
- 深入浅出TensorFlow2函数——tf.constant
分类目录:<深入浅出TensorFlow2函数>总目录 相关文章: · 深入浅出TensorFlow2函数--tf.constant · 深入浅出TensorFlow2函数--tf.Ten ...
- 深入浅出Pytorch函数——torch.numel
分类目录:<深入浅出Pytorch函数>总目录 相关文章: · 深入浅出TensorFlow2函数--tf.size · 深入浅出Pytorch函数--torch.numel · 深入浅出 ...
- 深入浅出Pytorch函数——torch.zeros
分类目录:<深入浅出Pytorch函数>总目录 相关文章: · 深入浅出Pytorch函数--torch.Tensor · 深入浅出Pytorch函数--torch.ones · 深入浅出 ...
最新文章
- Python3--自动化办公
- Semaphore同步
- CentOS 5.X用第三方源安装PHP MySQL Apache等
- 《黑客帝国》中的代码雨让人身临其境!利用Python轻松实现!
- java 延迟加载_hibernate延迟加载(懒加载)教程讲解
- ifdef的用法_chisel 高阶用法简介--rocket-chip generator
- 前缀表达式后缀表达式_你知道波兰表达式和逆波兰表达式吗
- 使用HttpSessionListener接口监听Session的创建和失效
- mongorepository查询条件_Java操作MongoDB采用MongoRepository仓库进行条件查询 | 学步园...
- hashmap储存有向图_HashMap的存储结构及原理
- SharePoint 2010 添加“我的链接”菜单
- C#实现请求服务器,类似于asp下的getHTTPPage(url)功能
- 儿童素描手绘创意设计字体 for mac
- 雷达信号处理基础 多普勒频移
- uwb定位管理系统的介绍
- #微信公众号互联登录-01#
- 新颖的自我介绍_新颖幽默的自我介绍
- 【开发必备】快来收藏!涵盖日常开发中所需要的60多个正则验证!!
- 根据UV风计算风速风向,根据风速与风向计算UV风
- 手机短信验证码发送(106短信验证码发送)