当前位置:网站首页>Numpy multidimensional array transpose transpose
Numpy multidimensional array transpose transpose
2022-06-13 01:39:00 【Under the starry sky 0516】
How to convert multidimensional numpy The axis transformation position of the array , For example, a 3x3x3 Array of , Change the position of the data of the first axis and the data of the third axis , First, let's take a look at one 3x3x3 The arrangement of arrays before replacement :
num = 3
images = np.arange(1, num**3+1).reshape(num, num, num)
for dim in range(0, num):
plt.subplot(1, 3, dim+1)
image = images[dim, :, :]
plt.imshow(image)
for i in range(image.shape[0]):
for j in range(image.shape[1]):
text = plt.text(j, i, int(image[i, j]), ha = "center", va = "center", color="r")
plt.xticks([]); plt.yticks([])
plt.show()
Output pictures :
If the first and third shafts are replaced , You can use the following program :
images = images.transpose((1, 0, 2))
give the result as follows :
边栏推荐
- 服务器安装jupyterlab以及远程登录配置
- Memory learning book reference
- [learn FPGA programming from scratch -21]: Advanced - Architecture - VerilogHDL coding specification
- Sonarqube local installation
- 白噪声的详细理解
- 三、上传织物图片至SQL Server并提供name进行展示织物照片
- Golang learning essay
- Happy string
- Crypto JS reports uglifyjs error
- 开发者来稿|AMD赛灵思中文论坛分享 - 提问的智慧
猜你喜欢
Sliding window summary of TCP connections
Leetcode question brushing 06 bit operation
Use koa to mock data and set cross domain issues
About tkinter Canvas does not display pictures
[MathType] use MathType to output latex style formula
MySQL performance optimization
Crypto JS reports uglifyjs error
Should the audience choose observation mode or positioning mode?
水管工游戏
关于tkinter.Canvas 不显示图片的问题
随机推荐
他山之石:a16z 的 Web3 投资版图
Unity JsonUtility 无法序列化List
[WSL2]限制WSL2可访问的硬件资源(CPU/内存)
Detailed explanation of audience characteristics
RSA encryption colloquial explanation
Large end storage and small end storage
URI, URL and urn difference, relation and syntax diagram
The interviewer only asked me five questions and the interview was over
Machine learning basic SVM (support vector machine)
Design of distributed game server
Facial expression recognition dataset
Leetcode question brushing 03 stack
Alexnet implements image classification of caltech101 dataset (pytorch Implementation)
Happy string
Network communication tcp/ip
Audiences with similar interests
Add default right-click menu
Unity jsonutility failed to serialize list
MySQL - use field alias after where
Auto commit attribute of MySQL