Home > Backend Development > Python Tutorial > How to increase matrix dimension in python

How to increase matrix dimension in python

php中世界最好的语言
Release: 2018-04-09 17:22:14
Original
4476 people have browsed it

This time I will bring you pythonHow to increase the matrix dimension, what are the precautions for increasing the matrix dimension in Python, the following is a practical case, let's take a look.

numpy.expand_dims(a, axis)

Examples

>>> x = np.array([1,2])
>>> x.shape
(2,)
>>> y = np.expand_dims(x, axis=0)
>>> y
array([[1, 2]])
>>> y.shape
(1, 2)
>>> y = np.expand_dims(x, axis=1) # Equivalent to x[:,newaxis]
>>> y
array([[1],
    [2]])
>>> y.shape
(2, 1)
Copy after login

I believe you read this article You have mastered the case method. For more exciting information, please pay attention to other related articles on the PHP Chinese website!

Recommended reading:

Operation excel to read and write data

##How to perform automated unit testing with Python Unittest

The above is the detailed content of How to increase matrix dimension in python. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template