一、数学基础
二、numpy
一、数学基础
关键字:求导、偏导、梯度、复合函数求导链式法则
矩阵的转置、矩阵加减、矩阵乘法【矩阵乘法不满足交换律】
二、numpy
#coding:utf-8import numpy as npprint np.__version__# 1- create narrayarray = np.array([1,2,3],dtype=np.uint8)print "array:",array# 2- zerosmat1 = np.zeros((2,3)) #(2,3) tupleprint "mat1:",mat1# 3- 高维矩阵mat2 = np.zeros((1,2,3,4))print mat2.shapeprint mat2.size# 4- 标准矩阵运算# (1) 标量与矩阵相乘scalar = 2mat = np.ones((2,3))mat3 = scalar * matprint "mat3:",mat3# (2) 矩阵转置 mat.Tmat = np.zeros((2,3))tmat = mat.Tprint mat.shape,tmat.shapemat4 = np.array((1,2,3))print "mat4:",mat4tmat4 = mat4.Tprint mat4.shape,tmat4.shape# (3) 矩阵的加法print "add--------------------"mat1 = np.array([[1,2],[3,4]])mat2 = np.zeros((2,2))mat3 = mat1 + mat2print "mat3:",mat3# (4) 矩阵的乘法print "multi------------------"mat1 = np.array([[1,2],[3,4]])mat2 = np.ones((2,2))mat3 = mat1.dot(mat2)print "mat3:",mat3