for example,

from autograd import grad

grad (func) Differential

 

np.shape

 

reshape (-1,1) rearranged, (- 1) is automatically arranged in a row vecter, (- 1,1) is automatically aligned in one dimension 1

  z.reshape(-1)

  array([ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16])

  z.reshape(-1,1)

  array([[ 1], [ 2], [ 3], [ 4], [ 5], [ 6], [ 7], [ 8], [ 9], [10], [11], [12], [13], [14], [15], [16]])

 

np.vstack (tup) use

In the vertical direction of the matrix are stacked.
Note: the arrays must have the same shape along all but the first axis in addition to a first external dimension, the dimensions of the matrix are stacked to be consistent.
Sample code:

import numpy as np

ARR1 np.array = ([1, 2, 3])
arr2 np.array = ([4, 5, 6])
res = np.vstack ((ARR1, ARR2))

np.hstack (tup)
in the horizontal direction of the array stacked.
Note:
TUP: Sequence of ndarrays
All MUST have have Arrays All But The Same Shape The SECOND Along Axis.
Sample code:

import numpy as np

arr1 = np.array([1, 2, 3])
arr2 = np.array([4, 5, 6])
res = np.hstack((arr1, arr2))

 [6] 

 

 

arr1 = np.array([[1, 2], [3, 4], [5, 6]])
arr2 = np.array([[7, 8], [9, 0], [0, 1]])
res = np.hstack((arr1, arr2))

[[1 2 7 8] [3 4 9 0] [5 6 0 1]]

np.random.shuffle (data) with the upset

np.random.normal(0,1,(256,10))       # normalize (mean ,std , shape)

Arbitrary integer (0,3, size = (256)) # 0 ~ 3 (not included 3) np.random.randint, size of

 

But also traverses the index through the elements

enumerate may also receive a second parameter, the starting value for the specified index

List1 = [ "this", "a", "an", "test"]

for index, item in enumerate(list1):

    print index, item

>>>

This 0

1 is

2 a

3 Test

 

Supplement
the number of rows to be counted if the file can be written:

count = len (open (filepath, 'r'). readlines ())
This method is simple, but may be slower, even when the file is large can not work.

You can use enumerate ():

count = 0
for index, line in enumerate(open(filepath,'r')):
    count += 1

 

Seaborn Matplot is based on the implementation of higher order visualization API, you can make the drawing more convenient and easy. I think the relationship Matplot with Seaborn is like Tensorflow with Keras.

https://medium.com/jameslearningnote/%E8%B3%87%E6%96%99%E5%88%86%E6%9E%90-%E6%A9%9F%E5%99%A8%E5%AD%B8%E7%BF%92-%E7%AC%AC2-5%E8%AC%9B-%E8%B3%87%E6%96%99%E8%A6%96%E8%A6%BA%E5%8C%96-matplotlib-seaborn-plotly-75cd353d6d3f

Guess you like

Origin www.cnblogs.com/pyleu1028/p/10995691.html