docs,
flatnonzero(a), https://numpy.org/doc/stable/reference/generated/numpy.flatnonzero.html 很好用!
return indices that are non-zero in the flattened version of a.
indices(index-s)
special usage: a = np.array([1, 1, 4, 5, 1, 4]), flatnonzero(a == 1) —> array([0, 1, 4], dtype=int64), because doing relational expression operations with list returns a boolean list. [True, True, False, False, True, False, False]
enumerate, https://docs.python.org/3/library/functions.html
Return an enumerate object. iterable must be a sequence, an iterator, or some other object which supports iteration. The __next__() method of the iterator returned by enumerate() returns a tuple containing a count (from start which defaults to 0) and the values obtained from iterating over iterable.
>>> seasons = [‘Spring’, ‘Summer’, ‘Fall’, ‘Winter’]
>>> list(enumerate(seasons))
[(0, ‘Spring’), (1, ‘Summer’), (2, ‘Fall’), (3, ‘Winter’)]
>>> list(enumerate(seasons, start=1))
[(1, ‘Spring’), (2, ‘Summer’), (3, ‘Fall’), (4, ‘Winter’)]
it’s too slow, just read the doc of that method/function and record the link.
transpose, https://numpy.org/doc/stable/reference/generated/numpy.transpose.html 文档写得比StackOverflow或者知乎都要好。
numpy.ndarray, https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html ,https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=&cad=rja&uact=8&ved=2ahUKEwjczL_km_PvAhUkFjQIHZAdDQkQFjABegQIBxAD&url=https%3A%2F%2Fwww.runoob.com%2Fnumpy%2Fnumpy-ndarray-object.html&usg=AOvVaw0FTb2TXohOoHQCrgb_NpTS ,打开jupyter可以发现,numpy里array的数据类型就表示为ndarray。
标???的就是还没搞懂的
astype???https://www.cnblogs.com/hhh5460/p/5129032.html 这个还没看
np.linalg.norm()???这个还没看
问题——numpy(*10???√√√)
关于axis,轴在很多函数里都会作为一个parameter,起作用可以用一个例子来理解,
>>> a = np.array([[[1,2,3],[4,5,6]],[[1,2,3],[4,5,6]]])
>>> a
array([[[1, 2, 3],
[4, 5, 6]],
[[1, 2, 3],
[4, 5, 6]]])
>>> a.shape
(2, 2, 3)
>>> np.sum(a, axis=2).shape
(2, 2)
意思是,axis在哪一行做sum就让哪一行消失,再比如mean,
>>> np.mean(a, axis=2)
array([[2., 5.],
[2., 5.]])
>>> np.mean(a, axis=2).shape
(2, 2)
再比如,numpy.array各种组合方式,
也是如此,可以暂时先这么理解,后面再纠正。
L1和L2距离,Inline Question 2???,范数这些都没看。
k-NN,SVM,softmax的矩阵化计算方法???还没看!!!
最后把这个算一遍,权当第三次学习一次。
这个repo里面,所有我写的代码里的笔记整理
需要的时候按这个搜索关键词即可
矩阵乘法
广播
numpy.array各种组合方式
Inline Question都很有意思!
我在SVM的jupyter里写的备注非常重要!搞清楚维度问题也很重要!
九点前看完SVM的部分就奖励自己站起来看很久窗外,爽!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
过拟合原因写得不对!
过拟合(原因、解决方案、原理) - 机器学习是魔鬼的文章 - 知乎
https://zhuanlan.zhihu.com/p/114390726
不只是有模型过于复杂这一种情况!!!
numpy.random.choice, https://numpy.org/doc/stable/reference/random/generated/numpy.random.choice.html
replace: https://stackoverflow.com/questions/40689152/what-does-replacement-mean-in-numpy-random-choice
replace=True: 可以从a 中反复选取同一个元素。
replace=False: a 中同一个元素只能被选取一次。
from numpy import random as rd
ary = list(range(10))
usage
In[18]: rd.choice(ary, size=8, replace=False)
Out[18]: array([0, 5, 9, 8, 2, 1, 6, 3]) # no repeated elements
In[19]: rd.choice(ary, size=8, replace=True)
Out[19]: array([4, 9, 8, 5, 4, 1, 1, 9]) # elements may be repeated