当前位置:网站首页>Numpy duplicate data
Numpy duplicate data
2022-06-09 20:52:00 【Eager to learn】
numpy Medium main use tile Functions and repeat Function to realize data duplication
tile function
tile The function is defined as follows :
def tile(A, reps)
The function mainly has two parameters , Parameters A Specifies a duplicate array , Parameters reps The number of times the order is repeated .
Be careful : If reps The length of is d, Then the dimension of the last repeated array is max(d, A.ndim), Take away d And A The maximum value of the dimension . If A.ndim < d, By adding a new axis A Turn into d dimension . For example, for shape by (3,) adopt 2 Dimensional repetition shape Turn into (1,3), adopt 3 Dimensional repetition shape Turn into (1,1,3).
Example :


repeat function
The function is defined as follows :
repeat(a, repeats, axis=None):
repeat The main functions are 3 Parameters , Parameters a Specify the array elements that need to be repeated , Parameters repeats Specify the number of repetitions , Parameters axis Specifies which axis to repeat along .
- axis=None, It will be flatten Current matrix , In fact, it becomes a line vector
- axis=0, Along y Axis copy , Actually increased the number of lines
- axis=1, Along x Axis copy , Actually increase the number of columns

>>> np.repeat(x, 3, axis=0)
array([[1, 2],
[1, 2],
[1, 2],
[3, 4],
[3, 4],
[3, 4]])
summary :
The main difference between these two functions is :tile The function is to repeat the operation on the array ,repeat The function is to repeat the operation on each element in the array .
边栏推荐
猜你喜欢

Set up ngrok server, realize intranet penetration service, and realize online access from external network to internal network

堆(优先队列)

Fanwei oa8 foreground SQL injection

逻辑回归总结

Figure guessing game in C language

Target Segmentation -- semantic segmentation of multi category dataset by Unet

Ceisum三维场景demo

Cvpr2022 oral | cross view transformer for semantic segmentation of real-time map views

二叉树的层序遍历

C language to realize computer automatic shutdown program -- it can be used to spoof roommate's computer
随机推荐
TypeScript 变量声明
部署 Kubernetes + KubeVirt 以及 KubeVirt的基本使用
03 Wireshark TCP
GBase8s数据库select子句6
排序-快速排序
Soflu software robot: an automatic tool to assist enterprises in landing Devops
C#中委托的应用
C#中的匿名函数的应用
申请软件代码签名证书
BI 如何让SaaS产品具有 “安全感”和“敏锐感”(上)
ModelArts存储方案建议
GBase8s数据库select子句2
Lambda Exception
Who says redis can't save big keys
Knowledge points of string in C #
Set up ngrok server, realize intranet penetration service, and realize online access from external network to internal network
Make money by doing sideline work. These popular we media platforms have made a lot of profits
C# For循环的一些小细节
Kubevirt network source code analysis (2)
C#中的继承关系