zoukankan      html  css  js  c++  java
  • 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]]]])

  • 相关阅读:
    关于IDEA2019.3在书写pom依赖坐标无法自动提示补全的问题
    vue props的接收格式
    axios请求添加请求头 标准写法
    VUE后台管理系统建立
    arguments
    表单验证规则
    <<>> html内显示
    vue_UI组件库vant之加载转圈
    vue_axios请求拦截器
    vue_js数字有效长度16位_超出的解决办法
  • 原文地址:https://www.cnblogs.com/Sabre/p/7976702.html
Copyright © 2011-2022 走看看