当前位置:网站首页>Numpy----np.reshape()
Numpy----np.reshape()
2022-06-27 23:59:00 【菜鸟要爱学习】
学习目标:
掌握np.reshape()
函数
在关于重新定义形状时,要注意一些语法:
import numpy as np
a = np.arange(1,17).reshape(4,4) #定义4行4列1到16的数组
print("原始数组为:\n",a)
#将数组a重新定义为(2,8)的数组
#方法一
b1 = a.reshape(2,8)
print("b1的结果为:\n",b1)
#方法二
b2 = np.reshape(a,(2,8))
print("b2的结果为:\n",b2)
有关np.reshape(A,(-1))的几种情况
‘具体情况见代码’
print("***********************")
import numpy as np
z = np.arange(1,17).reshape(4,4)
print("将元素变成一列(二维)")
print(np.reshape(z,(-1,1)))
print("将元素变成一行(二维)")
print(np.reshape(z,(1,-1)))
print("将元素变成一串(一维)")
print(np.reshape(z,(-1)))
print("***********************")
主要是将所给的数组展平成我们所需要的形式!!!!
边栏推荐
- Ten thousand words long article understanding business intelligence (BI) | recommended collection
- 如何高效读书学习
- 一张图弄懂 MIT,BSD,Apache几种开源协议之间的区别
- 声网 VQA:将实时互动中未知的视频画质用户主观体验变可知
- [Niuke discussion area] Chapter 4: redis
- fiddle如何使用代理
- Implementation of timed tasks in laravel framework
- MySQL十种锁,一篇文章带你全解析
- Data analysts too hot? Monthly income 3W? Tell you the true situation of this industry with data
- Lmsoc: a socially sensitive pre training method
猜你喜欢
Review of drug discovery-03-molecular design and optimization
【ELT.ZIP】OpenHarmony啃论文俱乐部—数据密集型应用内存压缩
[embedded foundation] memory (cache, ram, ROM, flash)
Cloud assisted privacy collection intersection (server assisted psi) protocol introduction: Learning
Implementation of timed tasks in laravel framework
Evaluation - rank sum ratio comprehensive evaluation
美团动态线程池实践思路已开源
Adobe Premiere基础-常用的视频特效(裁剪,黑白,剪辑速度,镜像,镜头光晕)(十五)
pytorch_ lightning. utilities. exceptions. MisconfigurationException: You requested GPUs: [1] But...
fiddle如何使用代理
随机推荐
面试官问:JS的继承
数据人面试指南 | 准备好这几点做到有备无患!
Interviewer asked: Inheritance of JS
Adobe Premiere基础-常用的视频特效(裁剪,黑白,剪辑速度,镜像,镜头光晕)(十五)
766. toplitz matrix
【ELT.ZIP】OpenHarmony啃论文俱乐部—数据密集型应用内存压缩
面试官问:JS的this指向
PostgreSQL设置自增字段
Deepmind | pre training of molecular property prediction through noise removal
PV操作原语
Adobe Premiere foundation - sound adjustment (volume correction, noise reduction, telephone tone, pitch shifter, parameter equalizer) (XVIII)
什么是数字化?什么是数字化转型?为什么企业选择数字化转型?
Lmsoc: a socially sensitive pre training method
[DNS resolution] set the name DNSPod resolution for domain name access of COM
药物发现综述-03-分子设计与优化
Cloud assisted privacy collection intersection (server assisted psi) protocol introduction: Learning
什麼是數字化?什麼是數字化轉型?為什麼企業選擇數字化轉型?
要搞清楚什么是同步,异步,串行,并行,并发,进程,线程,协程
lefse分析本地实现方法带全部安装文件和所有细节,保证成功。
【开源】开源系统整理-考试问卷等