Python code example for shape calculation matrix

Source: Internet
Author: User
This article mainly introduces the shape calculation matrix method in Python, and involves implementation skills related to Python mathematical operations. if you need it, refer to the following article to introduce the shape calculation matrix method in Python, implementation skills related to Python mathematical operations. For more information, see

This document describes how to calculate the shape matrix in Python. We will share this with you for your reference. The details are as follows:

When I saw the machine learning algorithm, I noticed the shape calculation matrix method. Next, let's talk about my understanding.

>>> From numpy import * >>> import operator >>> a = mat ([[1, 2, 3], [5, 6, 9]) >>> amatrix ([[1, 2, 3], [5, 6, 9])
>>> Shape (a) (2, 3) >>>> a. shape [0] # calculate the number of rows 2 >>> a. shape [1] # calculate the number of columns 3

Next is the explanation in Python.

Examples -------- >>> np. shape (np. eye (3) (3, 3) >>> np. shape ([[1, 2]) (1, 2)> np. shape ([0]) (1,) >>> np. shape (0) () >>> a = np. array ([(1, 2), (3, 4)], dtype = [('X', 'i4'), ('Y ', 'i4')])> np. shape (a) (2,) >>>. shape (2 ,)

The above is the details of the python code example of the shape calculation matrix. For more information, see other related articles in the first PHP community!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.