当前位置:网站首页>Numpy----np. reshape()
Numpy----np. reshape()
2022-06-28 02:07:00 【Rookies should love learning】
Learning goals :
master np.reshape()
function
When it comes to redefining shapes , Pay attention to some grammar :
import numpy as np
a = np.arange(1,17).reshape(4,4) # Definition 4 That's ok 4 Column 1 To 16 Array of
print(" The original array is :\n",a)
# Will array a Redefined as (2,8) Array of
# Method 1
b1 = a.reshape(2,8)
print("b1 As the result of the :\n",b1)
# Method 2
b2 = np.reshape(a,(2,8))
print("b2 As the result of the :\n",b2)
of np.reshape(A,(-1)) Several situations of
‘ See code for details ’
print("***********************")
import numpy as np
z = np.arange(1,17).reshape(4,4)
print(" Turn elements into a column ( A two-dimensional )")
print(np.reshape(z,(-1,1)))
print(" Turn the element into a line ( A two-dimensional )")
print(np.reshape(z,(1,-1)))
print(" Change an element into a string ( A one-dimensional )")
print(np.reshape(z,(-1)))
print("***********************")
It is mainly to flatten the given array into the form we need !!!!
边栏推荐
- Arrays. Aslist() pit
- General process after reference layer reboot
- 嵌入式必学!硬件资源接口详解——基于ARM AM335X开发板 (下)
- Solve storage problems? WMS warehouse management system solution
- Supervised, unsupervised and semi supervised learning
- How fiddle uses agents
- The interviewer asked: this point of JS
- Shardingsphere-proxy-5.0.0 establish MySQL read / write separation connection (6)
- Web3 技术初体验以及相关学习资料
- What are the risks of opening a compass stock account? Is it safe to open a compass account
猜你喜欢
什麼是數字化?什麼是數字化轉型?為什麼企業選擇數字化轉型?
Hi, you have a code review strategy to check!
【牛客讨论区】第四章:Redis
Web3 技术初体验以及相关学习资料
Take n multiple table names of a database as the values of a column in another table (the range can be a table in another database)
Adobe Premiere基础-常用的视频特效(边角定位,马赛克,模糊,锐化,手写工具,效果控件层级顺序)(十六)
What problems should be evaluated before implementing MES management system
基于AM335X开发板 ARM Cortex-A8——Acontis EtherCAT主站开发案例
1382. balancing binary search tree - General method
将某数据库N多表名作为另外一张表中某一列得值(范围可以是别的数据库中得某张表)
随机推荐
Original | 2025 to achieve the "five ones" goal! The four products of Jiefang power are officially released
Review of drug discovery-02-prediction of molecular properties
嵌入式必学,硬件资源接口详解——基于ARM AM335X开发板 (上)
Capacitor
评价——秩和比综合评价
Cesium 多边形(polygon)extrudedHeight 和 height 的区别
Adobe Premiere Basics - common video effects (cropping, black and white, clip speed, mirroring, lens halo) (XV)
Review of drug discovery-03-molecular design and optimization
引用层reboot后的大体流程
MapReduce elementary programming practice
Raspberry pie realizes intelligent cooling by temperature control fan
Evaluation - rank sum ratio comprehensive evaluation
Evaluation - grey correlation analysis
如何阅读一篇论文
MySQL十种锁,一篇文章带你全解析
Adobe Premiere Basics - common video effects (corner positioning, mosaic, blur, sharpen, handwriting tools, effect control hierarchy) (16)
机器学习笔记 - 时间序列作为特征
树莓派实现温控风扇智能降温
要搞清楚什么是同步,异步,串行,并行,并发,进程,线程,协程
Voice network VQA: make the user's subjective experience of unknown video quality in real-time interaction known