import numpy as np
a = np.array([1,2,3,4,5,6,7,8]) #一维数组
print(a.shape[0]) #值为8,因为有8个数据
print(a.shape[1]) #IndexError: tuple index out of range a = np.array([[1,2,3,4],[5,6,7,8]]) #二维数组
print(a.shape[0]) #值为2,最外层矩阵有2个元素,2个元素还是矩阵。
print(a.shape[1]) #值为4,内层矩阵有4个元素。
print(a.shape[2]) #IndexError: tuple index out of range

a = np.array([1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]) #一维数组
print(a.reshape(2,8))#建立二维数组,两行八列
print(a.reshape((2,2,2,2)))#建立四维数组
print(a.reshape((2,2,2,2)))#建立四维数组
print(a.reshape((2,4,2)))#建立三维数组


图像重建数组

image = np.array([[[ 0.67826139, 0.29380381],
[ 0.90714982, 0.52835647],
[ 0.4215251 , 0.45017551]],

[[ 0.92814219, 0.96677647],
[ 0.85304703, 0.52351845],
[ 0.19981397, 0.27417313]],

[[ 0.60659855, 0.00533165],
[ 0.10820313, 0.49978937],
[ 0.34144279, 0.94630077]]])

三维数组相当于(3,3,2)

image.shape[0]=3最外层

image.shape[1]=3次外层

image.shape[2]=2最里层

3*3*2=16

经过 v = image.reshape(image.shape[0]*image.shape[1]*image.shape[2],1)

变成 16行,1列

image2vector(image) = 
[[0.67826139]
[0.29380381]
[0.90714982]
[0.52835647]
[0.4215251 ]
[0.45017551]
[0.92814219]
[0.96677647]
[0.85304703]
[0.52351845]
[0.19981397]
[0.27417313]
[0.60659855]
[0.00533165]
[0.10820313]
[0.49978937]
[0.34144279]
[0.94630077]]

最新文章

  1. SVN:Previous operation has not finished; run 'cleanup' if it was interrupted
  2. 七天学会ASP.NET MVC (三)——ASP.Net MVC 数据处理
  3. UE4 WCF RestFul 服务器 读取JSON 数据并解析 简单实例
  4. 用nhibernate的几点小经验
  5. CSS ID选择器(三)
  6. Oracle11g 32位安装步骤
  7. 分享一款简洁的jQuery轮播源码
  8. 【转载】GDB反向调试(Reverse Debugging)
  9. pthread_create用法
  10. php的数组与字符串的转换函数整理
  11. What is Flux?
  12. Unitty 3D 贪吃蛇 今日小记 -- 碰撞
  13. ROS_Kinetic_25 在ubuntu16.04使用Leap_motion并作为手势输入控制Gazebo中的机器人
  14. day 14 递归、匿名函数、内置函数
  15. [UOJ317]【NOI2017】游戏 题解
  16. C_求两个日期相隔的天数(闰年)
  17. 解决Linux服务器tomact-8.0启动慢的问题
  18. (原+转)Ubuntu16.04软件中心闪退及wifi消失
  19. ThinkPHP5命令行 执行控制器下的某方法
  20. mysqldump对于DB进行逻辑备份的时候,是否会备份视图呢?

热门文章

  1. 攻防世界--Shuffle
  2. JavaScript的进制转换
  3. 记录使用node启用微信公众平台服务器配置
  4. Tesseract-OCR识别中文与训练字库
  5. 2019-9-8-WPF-渲染原理
  6. printcap - 打印机相容性数据库
  7. vue,一路走来(6)--微信支付
  8. windows切换窗口和网页快捷键
  9. 一、免费API调用
  10. java通过反射拿到mybatis中的sql语句并操作