numpy中的transpose通俗解释

版权声明:本文为博主原创文章,可以随便转载 https://blog.csdn.net/appleyuchi/article/details/82562661
#-*- coding:utf-8 -*-
import sys
reload(sys)
sys.setdefaultencoding('utf-8')

import numpy as np
arr1=np.arange(16).reshape(2,2,4)

print"arr1=",arr1
print"-----------------------------------------------------------------------------------------"
print"arr1.shape=",arr1.shape
arr2=arr1.transpose((2,0,1)) 
print"arr2=",arr2
print"-----------------------------------------------------------------------------------------"

注意,transform后

#                                               映射关系是201
# 14转换前的坐标是(1,1,2)-------------------------------->(2,1,1)

# [[[ 0  1  2  3]
#   [ 4  5  6  7]]

#  [[ 8  9 10 11]
#   [12 13 14 15]]]
# ||
# ||
# ||2,0,1
# \/
# arr2= [[[ 0  4]
#   [ 8 12]]

#  [[ 1  5]
#   [ 9 13]]

#  [[ 2  6]
#   [10 14]]

#  [[ 3  7]
#   [11 15]]]

transpose到底啥意思

                   transpose(a,b,c)

(x1,x2,x3)------------------------------>(xa,xb,xc)

设x1,x2,x3∈S

扫描二维码关注公众号,回复: 3237796 查看本文章

那么必有xa,xb,xc∈S

猜你喜欢

转载自blog.csdn.net/appleyuchi/article/details/82562661
今日推荐