当前位置:网站首页>[song] rebirth of me in py introductory training (10): numpy
[song] rebirth of me in py introductory training (10): numpy
2022-07-27 06:05:00 【Collapse an old face】
It's not easy to create , Before reference , Point a praise , Collection , You can't pay too much attention , Family
The first 1 Turn off :Numpy Create array
Task description
The small goal of this level is , Use Numpy Create a multidimensional array .
---------------------------------------------------------
Programming requirements
The task of this pass is , Complete the right editor Begin-End Interval code , To create a m*n The function of multidimensional array . The specific requirements are as follows :
The function takes two arguments , Then create the corresponding multidimensional array ;
See the following... For the test examples of this level .
# Please add the code to create multidimensional array here and assign it to ret #********** Begin *********# b=np.arange(n); ret = np.array([b]*m) #********** End **********#The first 2 Turn off :Numpy The basic operation of array
Task description
The small goal of this level is , Learn to Numpy Some basic operations of two-dimensional array .
---------------------------------------------------------
Programming requirements
The task of this pass is , Complete the right editor Begin-End Interval code , To realize the function of adding and multiplying vectors and scalars . The specific requirements are as follows :
The function takes three arguments , Then the operation between vector and scalar
#********** Begin *********#
ret = m+b[n]
#********** End **********#
return ret
# Definition opemul function
def opemul(m,b,n):
'''
Parameters :
m: Is an array
b: It's a list
n: Is the index in the list
What you need to do is m*b[n]
Return value :
ret: One numpy Array
'''
ret = 0
#********** Begin *********#
ret = m*b[n]
#********** End **********#
return retThe first 3 Turn off :Numpy Slicing and indexing of arrays
Task description
The small goal of this level is , Select the specified element from the array .
-----------------------------------------------------------------
Programming requirements
The task of this pass is , In the editor on the right Begin-End Interval code , In order to realize the Numpy The index function of array . The specific requirements are as follows :
- The function takes two arguments , Then return the specified element found by the slice
# Please add the code of the slice here , To find out the multidimensional array a pass the civil examinations m The first part of an array n Elements And assign it to ret #********** Begin *********# ret = a[m,:n] #********** End **********# return ret
The first 4 Turn off :Numpy Stack of arrays
Task description
The goal of this level is , change Numpy The shape of the array .
-------------------------------------------------------------
Programming requirements
The task of this pass is , Complete the right editor Begin-End Interval code , respectively Numpy Vertical superposition of arrays 、 Horizontal superposition 、 Depth overlay . The specific requirements are as follows :
- The function takes two arguments , Then the two parameters are superimposed ;
# Please add code here to realize the vertical superposition of the array and assign it to ret
#********** Begin *********#
ret = np.vstack((m,n))
#********** End **********#
return ret
# Definition darray function
def darray(m,n):
'''
Parameters :
m: Is the first array
n: Is the second array
Return value :
ret: One numpy Array
'''
ret = 0
# Please add code here to realize the depth superposition of the array and assign it to ret
#********** Begin *********#
ret = np.dstack((m,n))
#********** End **********#
return ret
# Definition harray function
def harray(m,n):
'''
Parameters :
m: Is the first array
n: Is the second array
Return value :
ret: One numpy Array
'''
ret = 0
# Please add code here to realize the horizontal superposition of the array and assign it to ret
#********** Begin *********#
#********** End **********#
return retThe first 5 Turn off :Numpy The split
Task description
The goal of this level is , Yes Numpy Split the array .
-----------------------------------------------------------------
Programming requirements
The task of this pass is , Complete the right editor Begin-End Interval code , respectively Numpy Vertical split of array 、 Horizontal resolution 、 Deep split . The specific requirements are as follows :
- Function takes an argument , Then split the array
# Please add code here to realize the vertical splitting of the array and assign it to ret #********** Begin *********# ret = np.vsplit(m,n) #********** End **********# return ret # Definition darray function def dsarray(m,n): ''' Parameters : m: Is the first array n: It is the dimension that needs to be split Return value : ret: One numpy Array ''' ret = 0 # Please add code here to realize the deep splitting of the array and assign it to ret #********** Begin *********# ret = np,dsplit(m,n) #********** End **********# return ret # Definition harray function def hsarray(m,n): ''' Parameters : m: Is the first array n: It is the dimension that needs to be split Return value : ret: One numpy Array ''' ret = 0 # Please add code here to realize the horizontal splitting of the array and assign it to ret #********** Begin *********# ret = np.hsplit(m,n) #********** End **********# return ret
notes : The content is only for reference and sharing , Do not spread without permission , Tort made delete
边栏推荐
- 【头歌】重生之机器学习-线性回归
- 【头歌】重生之我在py入门实训中(10): Numpy
- ps 2022 六月更新,都新增了哪些功能
- 12. Optimization problem practice
- Gbase 8C - SQL reference 6 SQL syntax (14)
- 如何管理大量的定时任务
- 安全帽反光衣检测识别数据集和yolov5模型
- Day 3. Suicidal ideation and behavior in institutions of higher learning: A latent class analysis
- C语言扫雷最新 递归展开 超详解(附源码)
- 使用Markdowm
猜你喜欢

STM32-红外遥控

Day 3. Suicidal ideation and behavior in institutions of higher learning: A latent class analysis

15. GPU acceleration, Minist test practice and visdom visualization

Weidongshan digital photo frame project learning (IV) simple TXT document display (e-paper book)

发布 分辨率0.22m的建筑物分割数据库

arcgis for js api(2) 获取要素服务的id集合

13. Logistic regression

【头歌】重生之机器学习-线性回归

pytorch的多GPU训练的两种方式

A photo breaks through the face recognition system: you can nod your head and open your mouth, netizens
随机推荐
能替代ps的修图软件?
编程学习记录——第5课【分支和循环语句】
pytorch的多GPU训练的两种方式
Greedy high performance neural network and AI chip application research and training
Live Home 3D Pro室内家居设计工具
When multiple formulas in latex share a sequence number
PZK学C语言之数据类型,进制转换,输入输出,运算符,分支语句ifelse
[first song] rebirth of me in py introductory training (4): Circular program
为什么交叉熵损失可以用于刻画损失
C语言-自定义结构类型
向量和矩阵的范数
【头歌】重生之数据科学导论——回归进阶
Day 3. Suicidal ideation and behavior in institutions of higher learning: A latent class analysis
What tools are needed to make video post effects?
11. Gradient derivation of perceptron
C language - linear sequence table
根据SQL必知必会学习SQL(MYSQL)
[song] rebirth of me in py introductory training (7): function call
Kaggle调用自定义模块方法
关于druid连接不上数据库的问题