Technical tips
This blog will include encountered important techniques in coding.
Misunderstandings
- Matrix multiplication with numpy
- The shape of np.array([1,1]) is (2,), which will be broadcasted in addition, and reduce dimensions in multiplication.
Useful functions
- np.clip(data, threshold1, threshold2, out = data)
- out means update a variable in place
- x.ravel() takes a multi-dimensional array and returns its contents inside of a 1D vector.
- append() is an in-place function
- np.real() gets the real part of a complex variable
- np.random.choice(a,b,replace, p) indicates the function will sample an array of size (b) from 1-dimensional array (a) repeatedly (replace=True) or not, according to possibilities of list (p) with the same of a.
This post is licensed under
CC BY 4.0
by the author.