当前位置:网站首页>Numpy notes
Numpy notes
2022-07-04 14:56:00 【Taochengyi 2.0】
List of articles
1、 establish numpy Variable
a = np.array([1,2,3,4,5,6])
print(a.shape,a.dtype)
b = np.array([1,2,3,4,5,6]).astype(np.float32)
print(b.shape,b.dtype)
c = np.array([[1,2],[3,4],[5,6]])
print(c.shape,c.dtype)
The running results are as follows :

2、numpy and list convert
a = [1,2,3,4,5,6]
b = np.array(a)
print(b.shape,b.dtype)
a = [[1,2],[3,4],[5,6]]
b = np.array(a)
print(b.shape,b.dtype)
c = np.array([1,2,3,4,5,6])
print(c.tolist()) # Turn into list
d = np.array([[1,2],[3,4],[5,6]])
print(d.tolist()) # Turn into list
The running results are as follows :

3、 Create whole 0 whole 1 Of numpy object
a = np.zeros([3,4])
print(a)
a = np.ones([3,4])
print(a)
The running results are as follows :

4、 Statistical applications
1、 Sum up
To a numpy Object for direct summation :

Specify data type summation :

If you don't operate on a two-dimensional matrix, you can sum all the elements directly :

The two-dimensional matrix operates in different dimensions ( The two-dimensional matrix is not rigorous , Because he is just numpy object , But we can treat it as a matrix )

The concept of dimension is added here , It can be understood as if axis=0 Just look up , And then it's equal to 1 Just look sideways :
2、 mean value
The effect here is similar to the previous average , The explanation can be seen in the mean part :

3、 Standard deviation
The effect here is similar to the previous average , The explanation can be seen in the mean part :

4、 Mean square error
The effect here is similar to the previous average , The explanation can be seen in the mean part :

In addition to the above part , There's more to it :
- abs: Find the absolute value
- sqrt: take a square root
5、 Data processing
1、 Find data
Directly find out whether a certain data exists , Return the location of the data :

Want to find the number of all matching data :

2、 Data sorting
If it is a direct sort , Just write it directly :
If it is a two-dimensional sort , We need to deal with , Or according to the previous numerical direction and horizontal direction :
If you want to get their ranked position :
3、 Get non repeating elements
Here you can use functions directly :

4、 Take the maximum and minimum
Simple value , Use functions directly :

If it's a two-dimensional matrix , Still refer to the above , It is divided into vertical direction and horizontal direction :

If you want to get the position of the maximum and minimum value :( Here I directly use the two-dimensional , One dimensional is the same )

5、 Interval uniform sampling
This is the same as the ordinary python The operation is basically the same , Is the beginning and end, and then add the step size OK 了 :

6、 Matrix operation
1、 Dimension extension
Next, a one-dimensional matrix is extended to a two-dimensional matrix , As shown below :

2、 Matrix splicing
The same direction dimension can be spliced , The effect is as follows :
Of course, we can also use our previous method of adding dimension parameters to splice :

3、 Matrix replication
Copy as you want :

4、 Four operations of matrix
It's the same as ordinary four arithmetic operations :

6、 The inner product of a matrix
It's the stuff of linear algebra , But it should be expressed by functions :

7、 random number
There are three common random numbers , As shown below :

For multi-dimensional Gaussian random numbers , The meaning of each parameter is as follows :

边栏推荐
- Explain of SQL optimization
- IO flow: node flow and processing flow are summarized in detail.
- 深度学习7 Transformer系列实例分割Mask2Former
- 都在说DevOps,你真正了解它吗?
- 对话龙智高级咨询顾问、Atlassian认证专家叶燕秀:Atlassian产品进入后Server时代,中国用户应当何去何从?
- numpy笔记
- 产品好不好,谁说了算?Sonar提出分析的性能指标,帮助您轻松判断产品性能及表现
- [C language] Pointer written test questions
- Gin integrated Alipay payment
- Wt588f02b-8s (c006_03) single chip voice IC scheme enables smart doorbell design to reduce cost and increase efficiency
猜你喜欢

Korean AI team plagiarizes shock academia! One tutor with 51 students, or plagiarism recidivist

numpy笔记

An overview of 2D human posture estimation

92. (cesium chapter) cesium building layering

Introduction to asynchronous task capability of function calculation - task trigger de duplication

UFO:微软学者提出视觉语言表征学习的统一Transformer,在多个多模态任务上达到SOTA性能!...
![[C language] Pointer written test questions](/img/89/3d463cbbb321e45ba8342f0ddfef8f.png)
[C language] Pointer written test questions

深度学习 神经网络的优化方法

内存管理总结

【C语言】指针笔试题
随机推荐
[information retrieval] link analysis
UFO: Microsoft scholars have proposed a unified transformer for visual language representation learning to achieve SOTA performance on multiple multimodal tasks
Ffmpeg Visual Studio development (IV): audio decoding
Detailed explanation of visual studio debugging methods
Red envelope activity design in e-commerce system
信号处理之一阶RC低通滤波器宏指令实现(繁易触摸屏)
leetcode:6109. Number of people who know the secret [definition of DP]
LeetCode 1200 最小绝对差[排序] HERODING的LeetCode之路
开发中常见问题总结
为什么国产手机用户换下一部手机时,都选择了iPhone?
openresty 限流
Leetcode 1200 minimum absolute difference [sort] The Path of leetcode for heroding
LeetCode 1200 最小絕對差[排序] HERODING的LeetCode之路
Xcode abnormal pictures cause IPA packet size problems
IO flow: node flow and processing flow are summarized in detail.
Combined with case: the usage of the lowest API (processfunction) in Flink framework
5g TV cannot become a competitive advantage, and video resources become the last weapon of China's Radio and television
leetcode:6110. The number of incremental paths in the grid graph [DFS + cache]
Opencv learning notes - linear filtering: box filtering, mean filtering, Gaussian filtering
How to match chords