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))
相关推荐
郝学胜_神的一滴4 分钟前
Python 高级编程 027:四大推导式全攻略
python·pycharm
菜冻鱼14 分钟前
Python-sklearn-特征工程
开发语言·人工智能·python·机器学习·numpy·matplotlib·sklearn
mit6.82423 分钟前
archived
后端·python·flask
船长@25 分钟前
FastAPI 快速上手:从零基础到实操入门
python·ai·fastapi
我要两颗404西柚1 小时前
2【python】:常用关键字,函数,方法
python
COOLMO研究AI1 小时前
Python 如何给 AI API 实现断路器模式:防止雪崩与保护本地服务
人工智能·python·php
zzzzzz3101 小时前
LLM 成本治理:从 token 账单到线上熔断,团队应该先做哪三件事?
人工智能·python·api
AC赳赳老秦2 小时前
网页公开附件自动采集:OpenClaw 批量下载页面内嵌 Word/Excel 附件,统一格式后结构化入库
java·python·word·php·excel·deepseek·openclaw
北斗落凡尘2 小时前
LangGraph 入门实战(3)
python·langchain
TAN-90°-2 小时前
Deep Learning for Computer Vision——Image Classification with Linear Classifiers
python·深度学习·算法·计算机视觉·线性回归