As a new learner of Numpy, it is very common to be confused by the form of array, braces nested in braces, such as ‘a= np.array[[[1],[2],[3]]]’ so that its shape cannot be precisely known by the users, although the shape can be fetched through ‘a.shape’, making users unable to perform multidimensional array correctly.

The method is as the following:(1)every array needs a most out brace.(2) Go inner, the number of paired brace is the element number of 0 axis, 1 axis, 2 axis etc.(3) The dimension number increased along with the going-inner, until the number element is reached, the sum of levels is the dimensional number.

For example:

>>> import numpy as np
>>> data=np.arange(4)
>>> data1=data.reshape((4,1))
>>> data2=data.reshape((1,4))
>>> data3=data.reshape((2,2))
>>> data4=data.reshape((1,2,2))
>>> data5=data.reshape((2,1,2))
>>> data6=data.reshape((2,2,1))
>>> data
array([0, 1, 2, 3])
>>> data1
array([[0],
[1],
[2],
[3]])
>>> data2
array([[0, 1, 2, 3]])
>>> data3
array([[0, 1],
[2, 3]])
>>> data4
array([[[0, 1],
[2, 3]]])
>>> data5
array([[[0, 1]], [[2, 3]]])
>>> data6
array([[[0],
[1]], [[2],
[3]]])

①data1's shape is (4,1),so firstly, the most out brace pair shall be set-->[ ], and then 0 axis is 4, meaning 4 pairs of brace inside -->[ [ ],[ ],[ ],[ ] ] ,finally, 1 axis is 1,and is the final dimension, meaning 1 number element shall be inside-->[ [0],[1],[2],[3]].

② data2's shape is (1,4), firstly-->[ ], then -->[ [ ] ], finally -->[ [ 0,1,2,3] ]

③ data3's shape is (2,2), firstly-->[ ] ,then--> [ [ ], [ ] ], finally-->[ [0,1], [2,3] ]

④data4' shape is (1,2,2), firstly-->[ ] ,then-->[ [ ] ], then--> [ [ [ ], [ ] ] ], finally--> [ [ [ 0,1], [2,3 ] ] ]

⑤data5's shape is (2,1,2),firstly--> [ ],then-->[ [ ],[ ] ], then-->[ [ [ ] ], [ [ ] ] ], finally --> [ [ [ 0,1],[ [ 2,3] ] ]

⑥data6's shape is (2,2,1),firstly-->[ ],then --> [ [ ] ,[ ] ],then-->[ [ [ ], [ ] ], [ [ ] , [ ] ] ],finally-->[ [ [ 0],[1] ], [ [2],[3] ] ]

A convenient way to recognize and handwrite multidimensional arrays in Numpy的更多相关文章

  1. Multidimensional Arrays

    Overview An array having more than two dimensions is called a multidimensional array in the MATLAB® ...

  2. [Java in NetBeans] Lesson 13. Multidimensional Arrays

    这个课程的参考视频和图片来自youtube. 主要学到的知识点有: 1. Multidimensional Array: Array that has more than one dimension. ...

  3. How do I learn machine learning?

    https://www.quora.com/How-do-I-learn-machine-learning-1?redirected_qid=6578644   How Can I Learn X? ...

  4. TensorFlow良心入门教程

    All the matrials come from Machine Learning class in Polyu,HK and I reorganize them and add referenc ...

  5. Java性能提示(全)

    http://www.onjava.com/pub/a/onjava/2001/05/30/optimization.htmlComparing the performance of LinkedLi ...

  6. [转]50 Shades of Go: Traps, Gotchas, and Common Mistakes for New Golang Devs

    http://devs.cloudimmunity.com/gotchas-and-common-mistakes-in-go-golang/ 50 Shades of Go: Traps, Gotc ...

  7. What is the fastest way of (not) logging?

    原文地址:http://www.slf4j.org/faq.html#logging_performance SLF4J supports an advanced feature called par ...

  8. awk overview

    VARIABLES, RECORDS AND FIELDS AWK  variables are dynamic; they come into existence when they are fir ...

  9. Java Knowledge series 3

    JVM & Bytecode Abstract & Object Object in Java (1) 所有东西都是对象object.可将对象想象成一种新型变量:它保存着数据,但可要求 ...

随机推荐

  1. NGINX学习积累(学习牛人)

    大牛:http://www.cnblogs.com/zengkefu/p/5563608.html 当请求来临的时候,NGINX会选择进入虚拟主机,匹配location后,进入请求处理阶段. 在请求处 ...

  2. 八 Struts2访问Servlet的API方式三:接口注入

    Struts2访问Servlet的API方式三:接口注入 通过实现ServletRequestAware, ServletContextAware 接口,拿到Request.ServletContex ...

  3. JavaScript 数字

    数字(Number)也称为数值或数. 数值直接量 当数字直接出现在程序中时,被称为数值直接量.在 JavaScript 程序中,直接输入的任何数字都被视为数值直接量. 示例1 数值直接量可以细分为整型 ...

  4. express框架开发接口部署线上环境PM2

    1.PM2介绍 PM2是一个线上环境下,用于启动nodejs进程守护的工具,用来保证服务的稳定及分摊服务器进程和压力. 2.下载安装 npm install pm2 -g  => pm2 --v ...

  5. php 增删改查范例(2)

    增加页面add.php: <!DOCTYPE html><html lang="en"><head>    <meta charset=& ...

  6. titleView发生偏移、titleView与masonry、titleView的设置、titleView的使用

    navigationItem的titleView属性的设置本身是很简单的,容易出问题的原因是自动化布局与frame混用造成的. 本文一步一步的讲解,力求找到问题的起源.如果你也在这块同样遇到问题,不妨 ...

  7. 按钮UIButton的使用

    一.使用概要 当添加一个按钮到你的界面,执行以下步骤: 1.在创建时设置按钮的类型. 2.提供一个标题字符串或图像,为您的内容适当调整按钮的大小. 3.连接一个或多个操作按钮的方法. 4.设置自动布局 ...

  8. 还在用SimpleDateFormat?Java8都发布N年了,转LocalDateTime吧

    前言 Java8发布,已有数年之久,但是发现很多人都还是坚持着用SimpleDateFormat和Date进行时间操作.SimpleDateFormat这个类不是线程安全的,在使用的时候稍不注意,就会 ...

  9. 十一 队列 Queue

    队列:  一种先进先出的数据结构  FIFO 数组队列的实现:

  10. 吴裕雄--天生自然HADOOP操作实验学习笔记:ETL案例

    实验目的 熟悉hadoop生态系统 初步了解大数据点击流分析业务 学会使用hadoop进行数据分析统计 实验原理 hadoop主要有三部分,hdfs做数据存储.mapreduce做数据计算.yarn做 ...