当前位置:网站首页>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("***********************")

主要是将所给的数组展平成我们所需要的形式!!!!
边栏推荐
- Meituan dynamic thread pool practice idea has been open source
- Ten MySQL locks, one article will give you full analysis
- 如何阅读一篇论文
- Overview of drug discovery-01 overview of drug discovery
- The contents of the latex table are left, middle and right
- 【开源】开源系统整理-考试问卷等
- Original | 2025 to achieve the "five ones" goal! The four products of Jiefang power are officially released
- Evaluation - grey correlation analysis
- Qu'est - ce que la numérisation? Qu'est - ce que la transformation numérique? Pourquoi les entreprises choisissent - elles la transformation numérique?
- TD Hero 线上发布会|7月2日邀你来
猜你喜欢

Adobe Premiere Basics - common video effects (corner positioning, mosaic, blur, sharpen, handwriting tools, effect control hierarchy) (16)

Review of drug discovery-03-molecular design and optimization

766. toplitz matrix

Deepmind | pre training of molecular property prediction through noise removal

Réseau neuronal pour la solution détaillée Multi - diagrammes de fondation zéro

【说明】Jmeter乱码的解决方法

Adobe Premiere Basics - common video effects (cropping, black and white, clip speed, mirroring, lens halo) (XV)

TIA botu_ Concrete method of making analog input and output Global Library Based on SCL language

The research group of Xuyong and duanwenhui of Tsinghua University has developed an efficient and accurate first principles electronic structure deep learning method and program

Import the data table in MySQL into Excel
随机推荐
机器学习笔记 - 时间序列作为特征
Adobe Premiere foundation - sound adjustment (volume correction, noise reduction, telephone tone, pitch shifter, parameter equalizer) (XVIII)
OS模块与OS.path 模块的学习
嵌入式必学,硬件资源接口详解——基于ARM AM335X开发板 (上)
766. toplitz matrix
Adobe Premiere基础-常用的视频特效(边角定位,马赛克,模糊,锐化,手写工具,效果控件层级顺序)(十六)
免费、好用、强大的开源笔记软件综合评测
What is digitalization? What is digital transformation? Why do enterprises choose digital transformation?
TD Hero 线上发布会|7月2日邀你来
【牛客討論區】第四章:Redis
同花顺上能炒股开户吗?安全吗?
Adobe Premiere基础-编辑素材文件常规操作(脱机文件,替换素材,素材标签和编组,素材启用,便捷调节不透明度,项目打包)(十七)
PostgreSQL设置自增字段
国外LEAD赚钱的一些习惯
想开户买股票,在网上办理股票开户安全吗?
The interviewer asked: this point of JS
零基础多图详解图神经网络
Solve storage problems? WMS warehouse management system solution
Prometeus 2.35.0 新特性
数据人面试指南 | 准备好这几点做到有备无患!
