Python-Numpy中的repmat

python 复制代码
np.tile
 
Python numpy 下的 np.tile有些类似于 matlab 中的 repmat函数。不需要 axis 关键字参数,仅通过第二个参数便可指定在各个轴上的复制倍数。
 
>> a = np.arange(3)
>> np.tile(a, 2)
array([0, 1, 2, 0, 1, 2])
>> np.tile(a, (2, 2))
array([[0, 1, 2, 0, 1, 2],
       [0, 1, 2, 0, 1, 2]])
 
>> b = np.arange(1, 5).reshape(2, 2)
>> np.tile(b, 2)
array([[1, 2, 1, 2],
       [3, 4, 3, 4]])
 
# 等价于
>> np.tile(b, (1, 2))
相关推荐
小猴子爱上树29 分钟前
Temu批量视频翻译Python实现方案
开发语言·python·音视频
X1A0RAN42 分钟前
Python 并发请求性能优化实战
python·性能优化·并发编程
陈同学xxx1 小时前
Hermes Agent 接入飞书,在手机上随时聊天
linux·python·飞书
卷无止境1 小时前
Python 中基于 Qt 的 GUI 库授权方式全解析
后端·python
卷无止境1 小时前
Guardrails.ai:为大语言模型加一道"安全阀"
后端·python
汤姆小白5 小时前
01-环境搭建与项目导览
人工智能·python·机器学习·numpy
向日的葵00612 小时前
langchain的Tools教程(三)
python·langchain·tools
言乐613 小时前
Python实现可运行解密游戏游戏框架
python·游戏·小程序·游戏程序·关卡设计
YUS云生13 小时前
Python学习笔记·第31天:FastAPI入门——路由、路径参数、查询参数与请求体
笔记·python·学习
智写-AI14 小时前
真实有效的免费降英文AI工具服务商
人工智能·python