对象转置的问题

        首先转置是矩阵才有的性质,所以要对一些数据进行转置,就需要保证数据是矩阵的格式,如果不是的话, 是没有效果的,但也不报错。举例如下: 

案例一:

from numpy import *

weights = ones(10)
print(weights)

结果如下:
[ 1.  1.  1.  1.  1.  1.  1.  1.  1.  1.]

Process finished with exit code 0

案例二:

from numpy import *

weights = ones(10)
wgh = (weights).T
print(wgh)

结果如下:
[ 1.  1.  1.  1.  1.  1.  1.  1.  1.  1.]

Process finished with exit code 0

案例三:

from numpy import *

weights = ones(10)
wgh = mat(weights).T
print(wgh)

结果如下:
[[ 1.]
 [ 1.]
 [ 1.]
 [ 1.]
 [ 1.]
 [ 1.]
 [ 1.]
 [ 1.]
 [ 1.]
 [ 1.]]

Process finished with exit code 0

猜你喜欢

转载自blog.csdn.net/qq_20412595/article/details/82495849