📜  Python| numpy matrix.ravel()

📅  最后修改于: 2022-05-13 01:54:27.509000             🧑  作者: Mango

Python| numpy matrix.ravel()

Numpy matrix.ravel()方法的帮助下,我们可以从给定的矩阵中得到展的矩阵。

示例 #1:
在这个例子中,我们可以看到我们能够在方法matrix.ravel()的帮助下从给定的矩阵中获取展平矩阵。

# import the important module in python
import numpy as np
          
# make matrix with numpy
gfg = np.matrix('[64, 1; 12, 3]')
          
# applying matrix.ravel() method
geeks = gfg.ravel()
    
print(geeks)
输出:
[[64  1 12  3]]

示例 #2:

# import the important module in python
import numpy as np
          
# make a matrix with numpy
gfg = np.matrix('[1, 2, 3; 4, 5, 6; 7, 8, -9]')
          
# applying matrix.ravel() method
geeks = gfg.ravel()
    
print(geeks)
输出:
[[ 1  2  3  4  5  6  7  8 -9]]