当前位置:网站首页>np. transpose & np.expand_ dims
np. transpose & np.expand_ dims
2022-07-26 23:30:00 【Fire, chicken】
np.transpose & np.expand_dims
One 、numpy.transpose(a, axes=None)
function :
Transform the high-dimensional array on the coordinate axis , That is, perform transpose operation .
Parameters :
a: Numpy Input array
axes: If specified , It must contain [0,1,…,N-1] Arranged tuples or lists , among N yes a The number of shaft ( It can be understood as dimension ). Returns the second row of the array i The axes will correspond to axes[i] Entered number axis . If not specified , The default is range(a.ndim)[::-1], This will reverse the order of the shafts
return :
dst: Transposed array
If expressed in linear algebra, it is the same as the following figure :

Put it simply transpose() The function of Change the position of different dimensions in the array .
for instance :
import numpy as np
x = np.ones((1,2,3)) # We first create a three-dimensional array

We use transpose() Function exchange x Positions of different dimensions of the array :
x_temp = np.transpose(x, (1, 0, 2))

Obviously , We can see x The first of an array of 0 Uighur 2 Dimension exchange position , It was (1,2,3) The format array becomes (2,1,3) Format .
Two 、numpy.expand_dims(a, axes=None)
function :
Add a new dimension to the array
Parameters :
a: Numpy Input array
axes: Place new dimensions ( Or multiple dimensions ) The location of .
return :
dst: The array after adding the new dimension
Example :
x = np.ones((1,2,3))
x_temp2 = np.expand_dims(x,0) # stay 0 Dimension insert a new dimension

x = np.ones((1,2,3))
x_temp2 = np.expand_dims(x,axis=(0, 1)) #axis It could also be a tuple

边栏推荐
- Hcia-r & s self use notes (20) VLAN comprehensive experiment, GVRP
- 公有云安全性和合规性方面的考虑事项
- 第二部分—C语言提高篇_8. 文件操作
- The memory occupation of the computer is too high after it is turned on (more than 50%)
- Ribbon负载均衡
- 第二部分—C语言提高篇_9. 链表
- Silicon Valley class lesson 6 - Tencent cloud on demand management module (I)
- Science | University of Washington uses AI and structural prediction to design new proteins
- 第二部分—C语言提高篇_13. 递归函数
- Real time voice quality monitoring
猜你喜欢
![[shaders realize distorted outline effect _shader effect Chapter 2]](/img/b3/ab28039cce2521ff1d59f0de6bf852.png)
[shaders realize distorted outline effect _shader effect Chapter 2]

Kalibr calibration realsensed435i -- multi camera calibration

SQL 基础知识

Science | University of Washington uses AI and structural prediction to design new proteins

Lesson 2 of Silicon Valley classroom - building project environment and developing lecturer management interface

程序员成长第二十九篇:如何激励员工?

华测RTK采集的GPX数据如何带属性转出kml、shp进行后续的管理和分析

百度网址收录

黑马瑞吉外卖之新增员工

Basic use of gateway
随机推荐
【MySQL】CentOS 7.9安装、使用MySQL-5.7.39二进制版
Kingbasees database administrator's Guide -- 11 manage data files and temporary files
MySQL random paging to get non duplicate data
C.Net timestamp and time conversion support time zone
Problems and solutions encountered in using nextline(), nextint() and next() in scanner
Hcia-r & s self use notes (21) STP technical background, STP foundation and data package structure, STP election rules and cases
Concept of functional interface & definition and use of functional interface
Several inventory terms often used in communication
SQL Basics
公有云安全性和合规性方面的考虑事项
Hcia-r & s self use notes (23) DHCP
[postgresql]postgresqlg use generate_ Series() function completes statistics
8 other programming languages -- Recording
云原生微服务第一章之服务器环境说明
HCIA-R&S自用笔记(23)DHCP
Typescript notes
Real time voice quality monitoring
KT6368A蓝牙芯片开发注意事项以及问题集锦--长期更新
Differences between PHP round and sprintf functions
SQL 基础知识