分类目录:《深入浅出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相同,如果dtypeNone,则输出Tensor的数据类型与x相同。

语法

paddle.ones_like(x, dtype=None, name=None)

参数

  • x:[Tensor] 输入的Tensor,数据类型可以是boolfloat16lfloat32lfloat64lint32lint64
  • dtype:[可选,np.dtype/str] 要创建的Tensor的数据类型,可以为boolfloat16float32float64int32int64。如果dtypeNone,那么数据类型为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相关推荐

  1. 深入浅出PaddlePaddle函数——paddle.Tensor

    分类目录:<深入浅出PaddlePaddle函数>总目录 相关文章: · 深入浅出TensorFlow2函数--tf.Tensor · 深入浅出Pytorch函数--torch.Tenso ...

  2. 深入浅出PaddlePaddle函数——paddle.arange

    分类目录:<深入浅出PaddlePaddle函数>总目录 相关文章: · 深入浅出TensorFlow2函数--tf.range · 深入浅出Pytorch函数--torch.arange ...

  3. 深入浅出PaddlePaddle函数——paddle.numel

    分类目录:<深入浅出PaddlePaddle函数>总目录 相关文章: · 深入浅出TensorFlow2函数--tf.size · 深入浅出Pytorch函数--torch.numel · ...

  4. 深入浅出PaddlePaddle函数——paddle.shape

    分类目录:<深入浅出PaddlePaddle函数>总目录 语法 paddle.shape(input) 参数 input:[Tensor] 输入的多维Tensor或SelectedRows ...

  5. 深入浅出Pytorch函数——torch.arange

    分类目录:<深入浅出Pytorch函数>总目录 相关文章: · 深入浅出TensorFlow2函数--tf.range · 深入浅出Pytorch函数--torch.arange · 深入 ...

  6. 深入浅出Pytorch函数——torch.exp

    分类目录:<深入浅出Pytorch函数>总目录 相关文章: · 深入浅出TensorFlow2函数--tf.exp · 深入浅出TensorFlow2函数--tf.math.exp · 深 ...

  7. 深入浅出TensorFlow2函数——tf.constant

    分类目录:<深入浅出TensorFlow2函数>总目录 相关文章: · 深入浅出TensorFlow2函数--tf.constant · 深入浅出TensorFlow2函数--tf.Ten ...

  8. 深入浅出Pytorch函数——torch.numel

    分类目录:<深入浅出Pytorch函数>总目录 相关文章: · 深入浅出TensorFlow2函数--tf.size · 深入浅出Pytorch函数--torch.numel · 深入浅出 ...

  9. 深入浅出Pytorch函数——torch.zeros

    分类目录:<深入浅出Pytorch函数>总目录 相关文章: · 深入浅出Pytorch函数--torch.Tensor · 深入浅出Pytorch函数--torch.ones · 深入浅出 ...

最新文章

  1. Python3--自动化办公
  2. Semaphore同步
  3. CentOS 5.X用第三方源安装PHP MySQL Apache等
  4. 《黑客帝国》中的代码雨让人身临其境!利用Python轻松实现!
  5. java 延迟加载_hibernate延迟加载(懒加载)教程讲解
  6. ifdef的用法_chisel 高阶用法简介--rocket-chip generator
  7. 前缀表达式后缀表达式_你知道波兰表达式和逆波兰表达式吗
  8. 使用HttpSessionListener接口监听Session的创建和失效
  9. mongorepository查询条件_Java操作MongoDB采用MongoRepository仓库进行条件查询 | 学步园...
  10. hashmap储存有向图_HashMap的存储结构及原理
  11. SharePoint 2010 添加“我的链接”菜单
  12. C#实现请求服务器,类似于asp下的getHTTPPage(url)功能
  13. 儿童素描手绘创意设计字体 for mac
  14. 雷达信号处理基础 多普勒频移
  15. uwb定位管理系统的介绍
  16. #微信公众号互联登录-01#
  17. 新颖的自我介绍_新颖幽默的自我介绍
  18. 【开发必备】快来收藏!涵盖日常开发中所需要的60多个正则验证!!
  19. 根据UV风计算风速风向,根据风速与风向计算UV风
  20. 手机短信验证码发送(106短信验证码发送)

热门文章

  1. 数据仓库、数据集市和数据湖有什么区别?
  2. kml文件转成cvs_KML 转图层 (转换)
  3. 2022非常火过postman的一款技术人必备的接口测试神器:Apifox
  4. TensorFlow-神经网络初体验
  5. 【Web 基础】Cookie
  6. Linux_计划任务
  7. 务实的思维与学习–如何有意识地思考思维与学习
  8. GetKeyState和GetAsyncKeyState的区别
  9. ADI实验室电路:带抗混叠滤波器的宽带接收机
  10. gsoc 任务_我在GSoC'20中进行编码的第三周