Python learning memo for machine learning by Chainer Chapter 8 Introduction to Numpy

What This is an article that summarizes what I noticed and researched when learning machine learning using Chainer. This time, I will study Numpy.

It is written based on my understanding, so it may be incorrect. I will correct any mistakes, please forgive me.

Content

What is Numpy

Algorithms that handle regression analysis, libraries that can conveniently handle multidimensional arrays?

Loading modules into a Python program

import numpy as np

After reading the text, I couldn't understand the difference between the library and the module, so I looked it up. Reference article below https://qiita.com/yutaro50/items/f93893a2d7b23cb05461 Tensors are handled by array.

How to handle the tensor

 a = np.array([1, 2, 3]) #Define a Numpy-style matrix
 a.shape => #Output shape as tuple
 a.rank => #Output rank
 a.size =>#Output size Number of data
 a.ndim =>  #Output len
 a = np.zeros((3, 3)) => #3x3 zero matrix
 a = np.ones((2, 3)) => #Matrix with all 2x3 elements 1
 a = np.full((3, 2), 9) => #A matrix with all 9 3x2 elements
 a = np.eye(5)          => #5x5 identity matrix
 a = np.random.random((4, 5)) => #4x5 with 0 elements~Matrix determined by a random number of 1
 a = np.arange(3, 10, 1) => #Row vector increasing by 1 from 3 to 10
 a = np[0,3] => #Value in the 1st row and 4th column
 #↓ I can't understand this explanation><
 #2 x 3 in the middle of the 4 x 5 matrix e=Extract 6 values
 center = e[1:3, 1:4]
 a[[0, 2, 1], [1, 1, 0]] => # (1, 2), (3, 2), (2, 1)Output the elements of as a row vector

In addition, four arithmetic operations can be performed. Addition and subtraction can be performed even if the matrix shape is different = broadcast On the contrary, unwilling calculation may occur. Caution

Calculation of matrix product AB

np.dot(A,B) or A.dot(B) #Anyway
np.dot(X.T, X)          #Calculate the product of the transposed matrix of matrix X and X
np.linalg.inv(A)        #Calculate the inverse matrix of matrix A

Note the order as the commutative law generally does not hold

If you have trouble handling the procession, look back here

Comment The content has become difficult, so the update frequency has dropped, but let's do our best

Recommended Posts

Python learning memo for machine learning by Chainer Chapter 8 Introduction to Numpy
Python learning memo for machine learning by Chainer Chapter 10 Introduction to Cupy
Python learning memo for machine learning by Chainer Chapter 9 Introduction to scikit-learn
Python learning memo for machine learning by Chainer from Chapter 2
Python learning memo for machine learning by Chainer Chapter 7 Regression analysis
Python learning memo for machine learning by Chainer Chapters 1 and 2
Python learning memo for machine learning by Chainer Chapter 13 Neural network training ~ Chainer completed
Python learning memo for machine learning by Chainer Chapter 13 Basics of neural networks
Python learning memo for machine learning by Chainer until the end of Chapter 2
An introduction to Python for machine learning
Python learning notes for machine learning with Chainer Chapters 11 and 12 Introduction to Pandas Matplotlib
Introduction to Deep Learning for the first time (Chainer) Japanese character recognition Chapter 2 [Model generation by machine learning]
An introduction to OpenCV for machine learning
Python & Machine Learning Study Memo ④: Machine Learning by Backpropagation
Introduction to machine learning
[Python] Easy introduction to machine learning with python (SVM)
An introduction to machine learning for bot developers
Python & Machine Learning Study Memo ②: Introduction of Library
[For beginners] Introduction to vectorization in machine learning
Take the free "Introduction to Python for Machine Learning" online until 4/27 application
An introduction to machine learning
Preparing to start "Python machine learning programming" (for macOS)
How to Introduce IPython (Python2) to Mac OS X-Preparation for Introduction to Machine Learning Theory-
Super introduction to machine learning
Memo for building a machine learning environment using Python
Introduction to Python For, While
"Introduction to Machine Learning by Bayesian Inference" Approximate inference of Poisson mixed model implemented only with Python numpy
How to use machine learning for work? 03_Python coding procedure
Introduction to machine learning Note writing
[Introduction to Python] <numpy ndarray> [edit: 2020/02/22]
[Introduction to Python3 Day 13] Chapter 7 Strings (7.1-7.1.1.1)
Machine learning summary by Python beginners
[Introduction to Python3 Day 14] Chapter 7 Strings (7.1.1.1 to 7.1.1.4)
[Introduction to Python3 Day 15] Chapter 7 Strings (7.1.2-7.1.2.2)
<For beginners> python library <For machine learning>
Introduction to Machine Learning Library SHOGUN
Interval scheduling learning memo ~ by python ~
An introduction to Python for non-engineers
"Scraping & machine learning with Python" Learning memo
[Introduction to Python3 Day 21] Chapter 10 System (10.1 to 10.5)
Introduction to Deep Learning for the first time (Chainer) Japanese character recognition Chapter 4 [Improvement of recognition accuracy by expanding data]
Introduction to Deep Learning for the first time (Chainer) Japanese character recognition Chapter 1 [Environment construction]
Introduction to Python Basics of Machine Learning (Unsupervised Learning / Principal Component Analysis)
Before the introduction to machine learning. ~ Technology required for machine learning other than machine learning ~
I read "Reinforcement Learning with Python: From Introduction to Practice" Chapter 1
A memorandum of scraping & machine learning [development technique] by Python (Chapter 4)
A memorandum of scraping & machine learning [development technique] by Python (Chapter 5)
I read "Reinforcement Learning with Python: From Introduction to Practice" Chapter 2
Python & Machine Learning Study Memo: Environment Preparation
Introduction to Machine Learning: How Models Work
[Learning memo] Basics of class by python
Memo to ask for KPI with python
Amplify images for machine learning with python
[Introduction to Python3, Day 17] Chapter 8 Data Destinations (8.1-8.2.5)
[Introduction to Python3, Day 17] Chapter 8 Data Destinations (8.3-8.3.6.1)
I installed Python 3.5.1 to study machine learning
Why Python is chosen for machine learning
[Introduction to Python3 Day 19] Chapter 8 Data Destinations (8.4-8.5)
[Introduction to Python3 Day 18] Chapter 8 Data Destinations (8.3.6.2 to 8.3.6.3)
[Shakyo] Encounter with Python for machine learning
Introduction to ClearML-Easy to manage machine learning experiments-