Python模块NumPy中的tile(A,rep) 函数
from NumPy import *
函数形式: tile(A,rep)
功能:重复A的各个维度
参数类型:
- A: Array类的都可以
- rep:A沿着各个维度重复的次数
这个英文单词的本意是:贴瓷砖,还挺形象的。
举例:
tile([17,29],2),如果rep参数是一个整数,则表示重复A中的元素rep次,即行数(即维度)只有1维,所以2的意思是在“列”这个维度上重复2次
输出[17,29,17,29]
tile([29,17],(3,5))
此时的(3,5)和[3,5]是相同的效果。
结果是3组,每组重复5次,也可以理解为二维表,3行,5列。先分3组(重复3次),每组重复5次。
array([[29, 17, 29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17, 29, 17]])
tile([29,17],[3,5,7])
结果是3组,每组一个二维表,每个二维表5行,7列,可以理解为三维表
array([[[29, 17, 29, 17, 29, 17, 29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17, 29, 17, 29, 17, 29, 17]],
[[29, 17, 29, 17, 29, 17, 29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17, 29, 17, 29, 17, 29, 17]],
[[29, 17, 29, 17, 29, 17, 29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17, 29, 17, 29, 17, 29, 17]]])
tile([29,17],[3,5,7,4])
结果是4组,怎样理解?我也不知道,这已经超过了人类空间的认知。
依次分组,先分3组重复,然后分5组重复,然后分7组,最后重复4次。
如果5维会怎样?也是继续按组重复下去。先分5组,用中括号分隔。
array([[[[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17]],
[[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17]],
[[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17]],
[[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17]],
[[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17]]],
[[[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17]],
[[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17]],
[[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17]],
[[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17]],
[[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17]]],
[[[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17]],
[[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17]],
[[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17]],
[[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17]],
[[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17]]]])
Python模块NumPy中的tile(A,rep) 函数的更多相关文章
- Python:numpy中的tile函数
在学习机器学习实教程时,实现KNN算法的代码中用到了numpy的tile函数,因此对该函数进行了一番学习: tile函数位于python模块 numpy.lib.shape_base中,他的功能是重复 ...
- Mathab和Python的numpy中的数组维度
Matlab和Python的numpy在维度索引方面的不同点: 1.索引的起始点不同:Matlab起始位置的索引为1,Python为0. 2.索引的括号不同:Matlab中元素可以通过小括号表示索引, ...
- python和numpy中sum()函数的异同
转载:https://blog.csdn.net/amuchena/article/details/89060798和https://www.runoob.com/python/python-func ...
- numpy中的tile函数
tile()函数可以很方便的生成多维数组.它有两个参数,第一个数是原始数组;第二个表示如何来生成,第一个数字表示生成几行,第二个表示每行有多少个原始数组(如果只写一个数字,那么就默认是一行). fro ...
- python模块collections中namedtuple()的理解
Python中存储系列数据,比较常见的数据类型有list,除此之外,还有tuple数据类型.相比与list,tuple中的元素不可修改,在映射中可以当键使用.tuple元组的item只能通过index ...
- python模块win32com中的early-bind与lazy-bind(以Autocad为例)
1.什么是Lazy-bind模式,Early-bind模式? win32com中,Lazy-bind 模式指的是程序事先不知道对象的任何方法和属性,当对象属性,方法被调用时,程序才向对象发出一个询问( ...
- Python模块包中__init__.py文件的作用
转载自:http://hi.baidu.com/tjuer/item/ba37ac4ce7482a0f6dc2f08b 模块包: 包通常总是一个目录,目录下为首的一个文件便是 __init__.py. ...
- python类库numpy中常见函数的用法
1. numpy.reshape 重塑 reshape是一种函数,函数可以重新调整矩阵的行数.列数.维数. B = reshape(A,m,n) 返回一个m*n的矩阵B, B中元素是按列从A中得到的 ...
- 【python】Numpy中stack(),hstack(),vstack()函数详解
转自 https://blog.csdn.net/csdn15698845876/article/details/73380803 这三个函数有些相似性,都是堆叠数组,里面最难理解的应该就是stack ...
随机推荐
- Connect to a ROS Network---2
原创博文:转载请标明出处(周学伟):http://www.cnblogs.com/zxouxuewei/tag/ 一.Introduction ROS网络由单个ROS主机和多个ROS节点组成. ROS ...
- Eclipse------maven使用Maven build编译web项目显示" javax.servlet.http 不存在"
缺少javax.servlet包 解决方法: 引入下面代码即可 <project> <dependencies> <dependency> <groupId& ...
- flexbox父盒子flex-wrap属性
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- js实现点击评论进行显示回复框
有人在群里问如何在留言评论那里点击回复按钮,下面就自动显示一个回复框,他想要的效果如图: 于是我随意的写了一段HTML,代码如下: <!DOCTYPE HTML> <html lan ...
- 第四篇:MapReduce计算模型
前言 本文讲解Hadoop中的编程及计算模型MapReduce,并将给出在MapReduce模型下编程的基本套路. 模型架构 在Hadoop中,用于执行计算任务(MapReduce任务)的机器有两个角 ...
- N76E003之IAP
修改FLASH数据通常需要很长时间,不像RAM那样可以实时操作.而且擦除.编程或读取FLASH数据需要遵循相当复杂的时序步骤.N76E003提供方便FALSH编程方式,可以帮助用户通过IAP方式,重新 ...
- SpringMVC系列之URL匹配问题
一.工程目录 二.web.xml配置文件及与其他文件的关系 三.控制器部分 四.返回值 五.url前后缀 六.项目源代码 http://files.cnblogs.com/files/xujian20 ...
- liunx trac 插件使用之DateFieldPlugin
插件GanttCalendarPlugin安装完以后,有一个问题,就是在选择起始与结束时间的时候,为了方便有datepicker功能,如图 需要用到插件DateFieldPlugin,官网链接http ...
- 布式实时日志系统(三) 环境搭建之centos 6.4下hadoop 2.5.2完全分布式集群搭建最全资料
最近公司业务数据量越来越大,以前的基于消息队列的日志系统越来越难以满足目前的业务量,表现为消息积压,日志延迟,日志存储日期过短,所以,我们开始着手要重新设计这块,业界已经有了比较成熟的流程,即基于流式 ...
- Qt编写密钥生成器+使用demo(开源)
在很多商业软件中,需要提供一些可以试运行的版本,这样就需要配套密钥机制来控制,纵观大部分的试用版软件,基本上采用以下几种机制来控制.1:远程联网激活,每次启动都联网查看使用时间等,这种方法最完美,缺点 ...