deeplearning.ai学习(numpy方法使用)

train_set_x_orig, train_set_y, test_set_x_orig, test_set_y, classes = load_dataset()


train_set_x_orig -- 一组图片
plt.imshow(train_set_x_orig[index]) -- 展示出第index图片




train_set_y[:, index] -- 取出train_set_y结果值中的第index的值




A trick when you want to flatten a matrix X of shape (a,b,c,d) to a matrix X_flatten of shape (b$*$c$*$d, a) is to use: 
```python
X_flatten = X.reshape(X.shape[0], -1).T      # X.T is the transpose of X
```




e的-z次方
np.exp(-z)




创建一个二维数组,其中要用两个括号
w = np.zeros((dim,1))




两个矩阵相乘必须要用公式,不能用 * 来表示
np.dot(A,Y)




所以初始化维度必须要用shape[0],因为前面已经被向量化
X_train.shape: (12288, 209)
w, b = initialize_with_zeros(X_train.shape[0])






def sigmoid(z):


def initialize_with_zeros(dim):


def propagate(w, b, X, Y):


def optimize(w, b, X, Y, num_iterations, learning_rate, print_cost = False):


def predict(w, b, X):

你可能感兴趣的:(机器学习)