博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Python模块NumPy中的tile(A,rep) 函数
阅读量:6168 次
发布时间:2019-06-21

本文共 5110 字,大约阅读时间需要 17 分钟。

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]]]])

 

转载地址:http://ztjba.baihongyu.com/

你可能感兴趣的文章
pytnon入门的一些小实例
查看>>
ubuntu下的dock工具
查看>>
饿了么被上海市市场监督局予以警告处分
查看>>
Java项目读取配置文件时,找不到指定的文件???
查看>>
lua/luajit and tcc
查看>>
前端安全即JS代码安全,前端源码安全探讨!
查看>>
如何快速实现异地不同网络打印机共享
查看>>
openinstall免费服务对App推广有哪些作用?
查看>>
基于Docker的微服务CI CD流水线
查看>>
学好SEO需要掌握哪些知识要点?
查看>>
JetBrains GoLand macv2019.1.2中文版如何换成无牵引模式?
查看>>
电气火灾监控系统工作原理
查看>>
中使馆驳斥《金融时报》“中国网络威胁论”
查看>>
【挨踢人物传】茶乡浪子:“传奇”职场路,一生感谢情(第12期)
查看>>
我的友情链接
查看>>
c#关于数据库连接操作的案例
查看>>
聊聊最近接触的媒体查询!
查看>>
HAproxy指南之haproxy重定向应用(案例篇)
查看>>
学习 HTTP协议挺不错的一个类
查看>>
深入字节码 -- ASM 关键接口 MethodVisitor
查看>>