声明

本文参考(8条消息) 【中文】【吴恩达课后编程作业】Course 1 - 神经网络和深度学习 - 第四周作业(1&2)_何宽的博客-CSDN博客

力求自己理解,刚刚走进深度学习希望可以一起探索。

本文所使用的资料已上传到百度网盘【点击下载】,提取码:xx1w,请在开始之前下载好所需资料,并将资料与代码放在相同界面

在正式开始之前,我们先来了解一下我们要做什么。在本次教程中,我们要构建两个神经网络,一个是构建两层的神经网络,一个是构建多层的神经网络,多层神经网络的层数可以自己定义。本次的教程的难度有所提升,但是我会力求深入简出。在这里,我们简单的讲一下难点,本文会提到**[LINEAR-> ACTIVATION]转发函数,比如我有一个多层的神经网络,结构是输入层->隐藏层->隐藏层->···->隐藏层->输出层**,在每一层中,我会首先计算Z = np.dot(W,A) + b,这叫做【linear_forward】,然后再计算A = relu(Z) 或者 A = sigmoid(Z),这叫做【linear_activation_forward】,合并起来就是这一层的计算方法,所以每一层的计算都有两个步骤,先是计算Z,再计算A

流程图

请注意,对于每个前向函数,都有一个相应的后向函数。 这就是为什么在我们的转发模块的每一步都会在cache中存储一些值,cache的值对计算梯度很有用,

在反向传播模块中,我们将使用cache来计算梯度。 现在我们正式开始分别构建两层神经网络和多层神经网络。这里很重要。

  1. import numpy as np
  2. import h5py
  3. import matplotlib.pyplot as plt
  4. import testCases #参见资料包
  5. from dnn_utils import sigmoid, sigmoid_backward, relu, relu_backward #参见资料包
  6. import lr_utils #参见资料包

为了和我的数据匹配,你需要指定随机种子

  1. np.random.seed(1)

对于一个两层的的神经网络而言,如下图

初始化参数如下

  1. def initialize_parameters(n_x,n_h,n_y):
  2. """
  3. 此函数是为了初始化两层网络参数而使用的函数。
  4. 参数:
  5. n_x - 输入层节点数量
  6. n_h - 隐藏层节点数量
  7. n_y - 输出层节点数量
  8.  
  9. 返回:
  10. parameters - 包含你的参数的python字典:
  11. W1 - 权重矩阵,维度为(n_h,n_x)
  12. b1 - 偏向量,维度为(n_h,1)
  13. W2 - 权重矩阵,维度为(n_y,n_h)
  14. b2 - 偏向量,维度为(n_y,1)
  15.  
  16. """
  17. W1 = np.random.randn(n_h, n_x) * 0.01
  18. b1 = np.zeros((n_h, 1))
  19. W2 = np.random.randn(n_y, n_h) * 0.01
  20. b2 = np.zeros((n_y, 1))
  21.  
  22. #使用断言确保我的数据格式是正确的
  23. assert(W1.shape == (n_h, n_x))
  24. assert(b1.shape == (n_h, 1))
  25. assert(W2.shape == (n_y, n_h))
  26. assert(b2.shape == (n_y, 1))
  27.  
  28. parameters = {"W1": W1,
  29. "b1": b1,
  30. "W2": W2,
  31. "b2": b2}
  32.  
  33. return parameters

接下来,我们测试一下

  1. print("==============测试initialize_parameters==============")
  2. parameters = initialize_parameters(3,2,1)
  3. print("W1 = " + str(parameters["W1"]))
  4. print("b1 = " + str(parameters["b1"]))
  5. print("W2 = " + str(parameters["W2"]))
  6. print("b2 = " + str(parameters["b2"]))
  1. ==============测试initialize_parameters==============
  2. W1 = [[ 0.01624345 -0.00611756 -0.00528172]
  3. [-0.01072969 0.00865408 -0.02301539]]
  4. b1 = [[0.]
  5. [0.]]
  6. W2 = [[ 0.01744812 -0.00761207]]
  7. b2 = [[0.]]

    两层的神经网络测试已经完毕了,那么对于一个L层的神经网络而言呢?初始化会是什么样的?
    当然我们在大学都学过矩阵的乘法和加法吧,我们来看代码
  1. def initialize_parameters_deep(layers_dims):
  2. """
  3. 此函数是为了初始化多层网络参数而使用的函数。
  4. 参数:
  5. layers_dims - 包含我们网络中每个图层的节点数量的列表
  6.  
  7. 返回:
  8. parameters - 包含参数“W1”,“b1”,...,“WL”,“bL”的字典:
  9. W1 - 权重矩阵,维度为(layers_dims [1],layers_dims [1-1])
  10. bl - 偏向量,维度为(layers_dims [1],1)
  11. """
  12. np.random.seed(3)
  13. parameters = {}
  14. L = len(layers_dims)
  15.  
  16. for l in range(1,L):
  17. parameters["W" + str(l)] = np.random.randn(layers_dims[l], layers_dims[l - 1]) / np.sqrt(layers_dims[l - 1]) # 这个根号其实和上面的0.01是一样目的的
  18. parameters["b" + str(l)] = np.zeros((layers_dims[l], 1))
  19.  
  20. #确保我要的数据的格式是正确的
  21. assert(parameters["W" + str(l)].shape == (layers_dims[l], layers_dims[l-1]))
  22. assert(parameters["b" + str(l)].shape == (layers_dims[l], 1))
  23.  
  24. return parameters

我们来测试一下

  1. #测试initialize_parameters_deep
  2. print("==============测试initialize_parameters_deep==============")
  3. layers_dims = [5,4,3]
  4. parameters = initialize_parameters_deep(layers_dims)
  5. print("W1 = " + str(parameters["W1"]))
  6. print("b1 = " + str(parameters["b1"]))
  7. print("W2 = " + str(parameters["W2"]))
  8. print("b2 = " + str(parameters["b2"]))
  1. ==============测试initialize_parameters_deep==============
  2. W1 = [[ 0.79989897 0.19521314 0.04315498 -0.83337927 -0.12405178]
  3. [-0.15865304 -0.03700312 -0.28040323 -0.01959608 -0.21341839]
  4. [-0.58757818 0.39561516 0.39413741 0.76454432 0.02237573]
  5. [-0.18097724 -0.24389238 -0.69160568 0.43932807 -0.49241241]]
  6. b1 = [[0.]
  7. [0.]
  8. [0.]
  9. [0.]]
  10. W2 = [[-0.59252326 -0.10282495 0.74307418 0.11835813]
  11. [-0.51189257 -0.3564966 0.31262248 -0.08025668]
  12. [-0.38441818 -0.11501536 0.37252813 0.98805539]]
  13. b2 = [[0.]
  14. [0.]
  15. [0.]]
    我们分别构建了两层和多层神经网络的初始化参数的函数,现在我们开始构建前向传播函数。

向前传播函数

  • LINEAR
  • LINEAR - >ACTIVATION,其中激活函数将会使用ReLU或Sigmoid。
  • [LINEAR - > RELU] ×(L-1) - > LINEAR - > SIGMOID(整个模型)

线性部分【LINEAR】

前向传播中,线性部分计算如下:

  1. def linear_forward(A,W,b):
  2. """
  3. 实现前向传播的线性部分。
  4.  
  5. 参数:
  6. A - 来自上一层(或输入数据)的激活,维度为(上一层的节点数量,示例的数量)
  7. W - 权重矩阵,numpy数组,维度为(当前图层的节点数量,前一图层的节点数量)
  8. b - 偏向量,numpy向量,维度为(当前图层节点数量,1)
  9.  
  10. 返回:
  11. Z - 激活功能的输入,也称为预激活参数
  12. cache - 一个包含“A”,“W”和“b”的字典,存储这些变量以有效地计算后向传递
  13. """
  14. Z = np.dot(W,A) + b
  15. assert(Z.shape == (W.shape[0],A.shape[1]))
  16. cache = (A,W,b)
  17.  
  18. return Z,cache

我们来测试一下:

  1. #测试linear_forward
  2. print("==============测试linear_forward==============")
  3. A,W,b = testCases.linear_forward_test_case()
  4. Z,linear_cache = linear_forward(A,W,b)
  5. print("Z = " + str(Z))
  1. ==============测试linear_forward==============
  2. Z = [[ 3.26295337 -1.23429987]]

线性激活部分【LINEAR - >ACTIVATION】

我们为了实现LINEAR->ACTIVATION这个步骤, 使用的公式是:A[l]=g(z[l])=g(W[l]A[l-1]+b[l]),其中,函数g会是sigmoid() 或者是 relu(),当然sigmoid()只在输出层使用,现在我们正式构建前向线性激活部分。

我们发现在同一层中A的序列号总是会少1。

  1. def linear_activation_forward(A_prev,W,b,activation):
  2. """
  3. 实现LINEAR-> ACTIVATION 这一层的前向传播
  4.  
  5. 参数:
  6. A_prev - 来自上一层(或输入层)的激活,维度为(上一层的节点数量,示例数)
  7. W - 权重矩阵,numpy数组,维度为(当前层的节点数量,前一层的大小)
  8. b - 偏向量,numpy阵列,维度为(当前层的节点数量,1)
  9. activation - 选择在此层中使用的激活函数名,字符串类型,【"sigmoid" | "relu"】
  10.  
  11. 返回:
  12. A - 激活函数的输出,也称为激活后的值
  13. cache - 一个包含“linear_cache”和“activation_cache”的字典,我们需要存储它以有效地计算后向传递
  14. """
  15.  
  16. if activation == "sigmoid":
  17. Z, linear_cache = linear_forward(A_prev, W, b)
  18. A, activation_cache = sigmoid(Z)
  19. elif activation == "relu":
  20. Z, linear_cache = linear_forward(A_prev, W, b)
  21. A, activation_cache = relu(Z)
  22.  
  23. assert(A.shape == (W.shape[0],A_prev.shape[1]))
  24. cache = (linear_cache,activation_cache)
  25.  
  26. return A,cache

我们来测试一下:

  1. #测试linear_activation_forward
  2. print("==============测试linear_activation_forward==============")
  3. A_prev, W,b = testCases.linear_activation_forward_test_case()
  4.  
  5. A, linear_activation_cache = linear_activation_forward(A_prev, W, b, activation = "sigmoid")
  6. print("sigmoid,A = " + str(A))
  7.  
  8. A, linear_activation_cache = linear_activation_forward(A_prev, W, b, activation = "relu")
  9. print("ReLU,A = " + str(A))
  1. ==============测试linear_activation_forward==============
  2. sigmoidA = [[0.96890023 0.11013289]]
  3. ReLUA = [[3.43896131 0. ]]

我们把两层模型需要的前向传播函数做完了,那多层网络模型的前向传播是怎样的呢?我们调用上面的那两个函数来实现它,为了在实现L层神经网络时更加方便,

我们需要一个函数来复制前一个函数(带有RELU的linear_activation_forward)L-1次,然后用一个带有SIGMOID的linear_activation_forward跟踪它,

我们来看一下它的结构是怎样的:

在下面的代码中,AL表示A[L]=g(Z[L])=g(W[L]A[L-1]+b[L]),(也可称作 Y_hat)

多层模型的前向传播计算模型代码如下:

  1. def L_model_forward(X,parameters):
  2. """
  3. 实现[LINEAR-> RELU] *(L-1) - > LINEAR-> SIGMOID计算前向传播,也就是多层网络的前向传播,为后面每一层都执行LINEAR和ACTIVATION
  4.  
  5. 参数:
  6. X - 数据,numpy数组,维度为(输入节点数量,示例数)
  7. parameters - initialize_parameters_deep()的输出
  8.  
  9. 返回:
  10. AL - 最后的激活值
  11. caches - 包含以下内容的缓存列表:
  12. linear_relu_forward()的每个cache(有L-1个,索引为从0到L-2)
  13. linear_sigmoid_forward()的cache(只有一个,索引为L-1)
  14. """
  15. caches = []
  16. A = X
  17. L = len(parameters) // 2 # 因为有两个参数(W,b)因此要整除以2
  18. for l in range(1,L):
  19. A_prev = A
  20. A, cache = linear_activation_forward(A_prev, parameters['W' + str(l)], parameters['b' + str(l)], "relu")
  21. caches.append(cache)
  22.  
  23. AL, cache = linear_activation_forward(A, parameters['W' + str(L)], parameters['b' + str(L)], "sigmoid")
  24. caches.append(cache)
  25.  
  26. assert(AL.shape == (1,X.shape[1]))
  27.  
  28. return AL,caches

我们来测试一下:

  1. #测试L_model_forward
  2. print("==============测试L_model_forward==============")
  3. X,parameters = testCases.L_model_forward_test_case()
  4. AL,caches = L_model_forward(X,parameters)
  5. print("AL = " + str(AL))
  6. print("caches 的长度为 = " + str(len(caches)))
  1. ==============测试L_model_forward==============
  2. AL = [[0.17007265 0.2524272 ]]
  3. caches 的长度为 = 2

计算成本

我们已经把这两个模型的前向传播部分完成了,我们需要计算成本(误差),以确定它到底有没有在学习,成本的计算公式如:

  1. def compute_cost(AL,Y):
  2. """
  3. 上面定义的成本函数。
  4.  
  5. 参数:
  6. AL - 与标签预测相对应的概率向量,维度为(1,示例数量)
  7. Y - 标签向量(例如:如果不是猫,则为0,如果是猫则为1),维度为(1,数量)
  8.  
  9. 返回:
  10. cost - 交叉熵成本
  11. """
  12. m = Y.shape[1]
  13. cost = -np.sum(np.multiply(np.log(AL),Y) + np.multiply(np.log(1 - AL), 1 - Y)) / m
  14.  
  15. cost = np.squeeze(cost)
  16. assert(cost.shape == ())
  17.  
  18. return cost

我们来测试一下:

  1. #测试compute_cost
  2. print("==============测试compute_cost==============")
  3. Y,AL = testCases.compute_cost_test_case()
  4. print("cost = " + str(compute_cost(AL, Y)))
  1. ==============测试compute_cost==============
  2. cost = 0.414931599615397
    我们已经把误差值计算出来了,现在开始进行反向传播

反向传播

反向传播用于计算相对于参数的损失函数的梯度,我们来看看向前和向后传播的流程图:

与前向传播类似,我们有需要使用三个步骤来构建反向传播:

LINEAR 后向计算
LINEAR -> ACTIVATION 后向计算,其中ACTIVATION 计算Relu或者Sigmoid 的结果
[LINEAR -> RELU] × \times× (L-1) -> LINEAR -> SIGMOID 后向计算 (整个模型)

线性部分【LINEAR backward】

我们来实现后向传播线性部分:

  1. def linear_backward(dZ,cache):
  2. """
  3. 为单层实现反向传播的线性部分(第L层)
  4.  
  5. 参数:
  6. dZ - 相对于(当前第l层的)线性输出的成本梯度
  7. cache - 来自当前层前向传播的值的元组(A_prev,W,b)
  8.  
  9. 返回:
  10. dA_prev - 相对于激活(前一层l-1)的成本梯度,与A_prev维度相同
  11. dW - 相对于W(当前层l)的成本梯度,与W的维度相同
  12. db - 相对于b(当前层l)的成本梯度,与b维度相同
  13. """
  14. A_prev, W, b = cache
  15. m = A_prev.shape[1]
  16. dW = np.dot(dZ, A_prev.T) / m
  17. db = np.sum(dZ, axis=1, keepdims=True) / m
  18. dA_prev = np.dot(W.T, dZ)
  19.  
  20. assert (dA_prev.shape == A_prev.shape)
  21. assert (dW.shape == W.shape)
  22. assert (db.shape == b.shape)
  23.  
  24. return dA_prev, dW, db

我们来测试一下:

  1. #测试linear_backward
  2. print("==============测试linear_backward==============")
  3. dZ, linear_cache = testCases.linear_backward_test_case()
  4.  
  5. dA_prev, dW, db = linear_backward(dZ, linear_cache)
  6. print ("dA_prev = "+ str(dA_prev))
  7. print ("dW = " + str(dW))
  8. print ("db = " + str(db))
  1. ==============测试linear_backward==============
  2. dA_prev = [[ 0.51822968 -0.19517421]
  3. [-0.40506361 0.15255393]
  4. [ 2.37496825 -0.89445391]]
  5. dW = [[-0.10076895 1.40685096 1.64992505]]
  6. db = [[0.50629448]]

线性激活部分【LINEAR -> ACTIVATION backward】

如果 g ( . )  是激活函数, 那么sigmoid_backward 和 relu_backward 这样计算:dZ[L]=dA[L]*g(Z[L])

我们先在正式开始实现后向线性激活:

  1. def linear_activation_backward(dA,cache,activation="relu"):
  2. """
  3. 实现LINEAR-> ACTIVATION层的后向传播。
  4.  
  5. 参数:
  6. dA - 当前层l的激活后的梯度值
  7. cache - 我们存储的用于有效计算反向传播的值的元组(值为linear_cache,activation_cache)
  8. activation - 要在此层中使用的激活函数名,字符串类型,【"sigmoid" | "relu"】
  9. 返回:
  10. dA_prev - 相对于激活(前一层l-1)的成本梯度值,与A_prev维度相同
  11. dW - 相对于W(当前层l)的成本梯度值,与W的维度相同
  12. db - 相对于b(当前层l)的成本梯度值,与b的维度相同
  13. """
  14. linear_cache, activation_cache = cache
  15. if activation == "relu":
  16. dZ = relu_backward(dA, activation_cache)
  17. dA_prev, dW, db = linear_backward(dZ, linear_cache)
  18. elif activation == "sigmoid":
  19. dZ = sigmoid_backward(dA, activation_cache)
  20. dA_prev, dW, db = linear_backward(dZ, linear_cache)
  21.  
  22. return dA_prev,dW,db

下面我们来测试一下:

  1. #测试linear_activation_backward
  2. print("==============测试linear_activation_backward==============")
  3. AL, linear_activation_cache = testCases.linear_activation_backward_test_case()
  4.  
  5. dA_prev, dW, db = linear_activation_backward(AL, linear_activation_cache, activation = "sigmoid")
  6. print ("sigmoid:")
  7. print ("dA_prev = "+ str(dA_prev))
  8. print ("dW = " + str(dW))
  9. print ("db = " + str(db) + "\n")
  10.  
  11. dA_prev, dW, db = linear_activation_backward(AL, linear_activation_cache, activation = "relu")
  12. print ("relu:")
  13. print ("dA_prev = "+ str(dA_prev))
  14. print ("dW = " + str(dW))
  15. print ("db = " + str(db))
  1. ==============测试linear_activation_backward==============
  2. sigmoid:
  3. dA_prev = [[ 0.11017994 0.01105339]
  4. [ 0.09466817 0.00949723]
  5. [-0.05743092 -0.00576154]]
  6. dW = [[ 0.10266786 0.09778551 -0.01968084]]
  7. db = [[-0.05729622]]
  8.  
  9. relu:
  10. dA_prev = [[ 0.44090989 -0. ]
  11. [ 0.37883606 -0. ]
  12. [-0.2298228 0. ]]
  13. dW = [[ 0.44513824 0.37371418 -0.10478989]]
  14. db = [[-0.20837892]]
    我们已经把两层模型的后向计算完成了,对于多层模型我们也需要这两个函数来完成,我们来看一下流程图:

在之前的前向计算中,我们存储了一些包含包含(X,W,b和Z)的cache,我们将会使用它们来计算梯度值,

所以,在L层模型中,我们需要从L层遍历所有的隐藏层,在每一步中,我们需要使用那一层的cache值来进行反向传播。

我们开始构建多层模型向后传播函数:

  1. def L_model_backward(AL,Y,caches):
  2. """
  3. 对[LINEAR-> RELU] *(L-1) - > LINEAR - > SIGMOID组执行反向传播,就是多层网络的向后传播
  4.  
  5. 参数:
  6. AL - 概率向量,正向传播的输出(L_model_forward())
  7. Y - 标签向量(例如:如果不是猫,则为0,如果是猫则为1),维度为(1,数量)
  8. caches - 包含以下内容的cache列表:
  9. linear_activation_forward("relu")的cache,不包含输出层
  10. linear_activation_forward("sigmoid")的cache
  11.  
  12. 返回:
  13. grads - 具有梯度值的字典
  14. grads [“dA”+ str(l)] = ...
  15. grads [“dW”+ str(l)] = ...
  16. grads [“db”+ str(l)] = ...
  17. """
  18. grads = {}
  19. L = len(caches)
  20. m = AL.shape[1]
  21. Y = Y.reshape(AL.shape)
  22. dAL = - (np.divide(Y, AL) - np.divide(1 - Y, 1 - AL))
  23.  
  24. current_cache = caches[L-1]
  25. grads["dA" + str(L)], grads["dW" + str(L)], grads["db" + str(L)] = linear_activation_backward(dAL, current_cache, "sigmoid")
  26.  
  27. for l in reversed(range(L-1)):
  28. current_cache = caches[l]
  29. dA_prev_temp, dW_temp, db_temp = linear_activation_backward(grads["dA" + str(l+2)], current_cache, "relu")
  30. grads["dA" + str(l + 1)] = dA_prev_temp
  31. grads["dW" + str(l + 1)] = dW_temp
  32. grads["db" + str(l + 1)] = db_temp
  33.  
  34. return grads

相信第一次看到for循环的小伙伴会跟我一样懵,我以我自己的理解来说明:

在同一层a的序号总是比W,b少1;

reversed将列表逆序变成了[L-2,L-3,L-4.....,2,1,0],又因为W没有dw[0],subsequent全员+1;

千万不要认为str(l+2)是L-2+2=L,列表的顺序依旧是[0,1,2,3,4...],所以str(l+2)是str(0+2)=str(2)

测试一下:

  1. 测试L_model_backward
  2. print("==============测试L_model_backward==============")
  3. AL, Y_assess, caches = testCases.L_model_backward_test_case()
  4. grads = L_model_backward(AL, Y_assess, caches)
  5. print ("dW1 = "+ str(grads["dW1"]))
  6. print ("db1 = "+ str(grads["db1"]))
  7. print ("dA0 = "+ str(grads["dA1"]))
  1. ==============测试L_model_backward==============
  2. dW1 = [[0.41010002 0.07807203 0.13798444 0.10502167]
  3. [0. 0. 0. 0. ]
  4. [0.05283652 0.01005865 0.01777766 0.0135308 ]]
  5. db1 = [[-0.22007063]
  6. [ 0. ]
  7. [-0.02835349]]
  8. dA0 = [[ 0.12913162 -0.44014127]
  9. [-0.14175655 0.48317296]
  10. [ 0.01663708 -0.05670698]]

更新参数

  1. def update_parameters(parameters, grads, learning_rate):
  2. """
  3. 使用梯度下降更新参数
  4.  
  5. 参数:
  6. parameters - 包含你的参数的字典
  7. grads - 包含梯度值的字典,是L_model_backward的输出
  8.  
  9. 返回:
  10. parameters - 包含更新参数的字典
  11. 参数[“W”+ str(l)] = ...
  12. 参数[“b”+ str(l)] = ...
  13. """
  14. L = len(parameters) // 2 #整除
  15. for l in range(L):
  16. parameters["W" + str(l + 1)] = parameters["W" + str(l + 1)] - learning_rate * grads["dW" + str(l + 1)]
  17. parameters["b" + str(l + 1)] = parameters["b" + str(l + 1)] - learning_rate * grads["db" + str(l + 1)]
  18.  
  19. return parameters

测试一下:

  1. #测试update_parameters
  2. print("==============测试update_parameters==============")
  3. parameters, grads = testCases.update_parameters_test_case()
  4. parameters = update_parameters(parameters, grads, 0.1)
  5.  
  6. print ("W1 = "+ str(parameters["W1"]))
  7. print ("b1 = "+ str(parameters["b1"]))
  8. print ("W2 = "+ str(parameters["W2"]))
  9. print ("b2 = "+ str(parameters["b2"]))
  1. ==============测试update_parameters==============
  2. W1 = [[-0.59562069 -0.09991781 -2.14584584 1.82662008]
  3. [-1.76569676 -0.80627147 0.51115557 -1.18258802]
  4. [-1.0535704 -0.86128581 0.68284052 2.20374577]]
  5. b1 = [[-0.04659241]
  6. [-1.28888275]
  7. [ 0.53405496]]
  8. W2 = [[-0.55569196 0.0354055 1.32964895]]
  9. b2 = [[-0.84610769]]
    至此为止,我们已经实现该神经网络中所有需要的函数。接下来,我们将这些方法组合在一起,构成一个神经网络类,可以方便的使用。

建立两层的神经网络:

我们正式开始构建两层的神经网络:

  1. def two_layer_model(X,Y,layers_dims,learning_rate=0.0075,num_iterations=3000,print_cost=False,isPlot=True):
  2. """
  3. 实现一个两层的神经网络,【LINEAR->RELU】 -> 【LINEAR->SIGMOID】
  4. 参数:
  5. X - 输入的数据,维度为(n_x,例子数)
  6. Y - 标签,向量,0为非猫,1为猫,维度为(1,数量)
  7. layers_dims - 层数的向量,维度为(n_y,n_h,n_y)
  8. learning_rate - 学习率
  9. num_iterations - 迭代的次数
  10. print_cost - 是否打印成本值,每100次打印一次
  11. isPlot - 是否绘制出误差值的图谱
  12. 返回:
  13. parameters - 一个包含W1,b1,W2,b2的字典变量
  14. """
  15. np.random.seed(1)
  16. grads = {}
  17. costs = []
  18. (n_x,n_h,n_y) = layers_dims
  19.  
  20. """
  21. 初始化参数
  22. """
  23. parameters = initialize_parameters(n_x, n_h, n_y)
  24.  
  25. W1 = parameters["W1"]
  26. b1 = parameters["b1"]
  27. W2 = parameters["W2"]
  28. b2 = parameters["b2"]
  29.  
  30. """
  31. 开始进行迭代
  32. """
  33. for i in range(0,num_iterations):
  34. #前向传播
  35. A1, cache1 = linear_activation_forward(X, W1, b1, "relu")
  36. A2, cache2 = linear_activation_forward(A1, W2, b2, "sigmoid")
  37.  
  38. #计算成本
  39. cost = compute_cost(A2,Y)
  40.  
  41. #后向传播
  42. ##初始化后向传播
  43. dA2 = - (np.divide(Y, A2) - np.divide(1 - Y, 1 - A2))
  44.  
  45. ##向后传播,输入:“dA2,cache2,cache1”。 输出:“dA1,dW2,db2;还有dA0(未使用),dW1,db1”。
  46. dA1, dW2, db2 = linear_activation_backward(dA2, cache2, "sigmoid")
  47. dA0, dW1, db1 = linear_activation_backward(dA1, cache1, "relu")
  48.  
  49. ##向后传播完成后的数据保存到grads
  50. grads["dW1"] = dW1
  51. grads["db1"] = db1
  52. grads["dW2"] = dW2
  53. grads["db2"] = db2
  54.  
  55. #更新参数
  56. parameters = update_parameters(parameters,grads,learning_rate)
  57. W1 = parameters["W1"]
  58. b1 = parameters["b1"]
  59. W2 = parameters["W2"]
  60. b2 = parameters["b2"]
  61.  
  62. #打印成本值,如果print_cost=False则忽略
  63. if i % 100 == 0:
  64. #记录成本
  65. costs.append(cost)
  66. #是否打印成本值
  67. if print_cost:
  68. print("第", i ,"次迭代,成本值为:" ,np.squeeze(cost))
  69. #迭代完成,根据条件绘制图
  70. if isPlot:
  71. plt.plot(np.squeeze(costs))
  72. plt.ylabel('cost')
  73. plt.xlabel('iterations (per tens)')
  74. plt.title("Learning rate =" + str(learning_rate))
  75. plt.show()
  76.  
  77. #返回parameters
  78. return parameters
  1. train_set_x_orig , train_set_y , test_set_x_orig , test_set_y , classes = lr_utils.load_dataset()
  2.  
  3. train_x_flatten = train_set_x_orig.reshape(train_set_x_orig.shape[0], -1).T
  4. test_x_flatten = test_set_x_orig.reshape(test_set_x_orig.shape[0], -1).T
  5.  
  6. train_x = train_x_flatten / 255
  7. train_y = train_set_y
  8. test_x = test_x_flatten / 255
  9. test_y = test_set_y

数据集加载完成,开始正式训练:

  1. n_x = 12288
  2. n_h = 7
  3. n_y = 1
  4. layers_dims = (n_x,n_h,n_y)
  5.  
  6. parameters = two_layer_model(train_x, train_set_y, layers_dims = (n_x, n_h, n_y), num_iterations = 2500, print_cost=True,isPlot=True)
  1. 0 次迭代,成本值为: 0.6930497356599891
  2. 100 次迭代,成本值为: 0.6464320953428849
  3. 200 次迭代,成本值为: 0.6325140647912677
  4. 300 次迭代,成本值为: 0.6015024920354665
  5. 400 次迭代,成本值为: 0.5601966311605748
  6. 500 次迭代,成本值为: 0.515830477276473
  7. 600 次迭代,成本值为: 0.47549013139433266
  8. 700 次迭代,成本值为: 0.4339163151225749
  9. 800 次迭代,成本值为: 0.400797753620389
  10. 900 次迭代,成本值为: 0.3580705011323798
  11. 1000 次迭代,成本值为: 0.3394281538366412
  12. 1100 次迭代,成本值为: 0.30527536361962637
  13. 1200 次迭代,成本值为: 0.27491377282130186
  14. 1300 次迭代,成本值为: 0.2468176821061483
  15. 1400 次迭代,成本值为: 0.19850735037466102
  16. 1500 次迭代,成本值为: 0.1744831811255663
  17. 1600 次迭代,成本值为: 0.17080762978097416
  18. 1700 次迭代,成本值为: 0.11306524562164691
  19. 1800 次迭代,成本值为: 0.09629426845937152
  20. 1900 次迭代,成本值为: 0.08342617959726865
  21. 2000 次迭代,成本值为: 0.07439078704319084
  22. 2100 次迭代,成本值为: 0.06630748132267936
  23. 2200 次迭代,成本值为: 0.05919329501038171
  24. 2300 次迭代,成本值为: 0.05336140348560559
  25. 2400 次迭代,成本值为: 0.04855478562877018

迭代完成之后我们就可以进行预测了,预测函数如下:

  1. def predict(X, y, parameters):
  2. """
  3. 该函数用于预测L层神经网络的结果,当然也包含两层
  4.  
  5. 参数:
  6. X - 测试集
  7. y - 标签
  8. parameters - 训练模型的参数
  9.  
  10. 返回:
  11. p - 给定数据集X的预测
  12. """
  13.  
  14. m = X.shape[1]
  15. n = len(parameters) // 2 # 神经网络的层数
  16. p = np.zeros((1,m))
  17.  
  18. #根据参数前向传播
  19. probas, caches = L_model_forward(X, parameters)
  20.  
  21. for i in range(0, probas.shape[1]):
  22. if probas[0,i] > 0.5:
  23. p[0,i] = 1
  24. else:
  25. p[0,i] = 0
  26.  
  27. print("准确度为: " + str(float(np.sum((p == y))/m)))
  28.  
  29. return p

预测函数构建好了我们就开始预测,查看训练集和测试集的准确性:

  1. predictions_train = predict(train_x, train_y, parameters) #训练集
  2. predictions_test = predict(test_x, test_y, parameters) #测试集
  1. 准确度为: 1.0
  2. 准确度为: 0.72

搭建多层神经网络

  1. def L_layer_model(X, Y, layers_dims, learning_rate=0.0075, num_iterations=3000, print_cost=False,isPlot=True):
  2. """
  3. 实现一个L层神经网络:[LINEAR-> RELU] *(L-1) - > LINEAR-> SIGMOID。
  4.  
  5. 参数:
  6. X - 输入的数据,维度为(n_x,例子数)
  7. Y - 标签,向量,0为非猫,1为猫,维度为(1,数量)
  8. layers_dims - 层数的向量,维度为(n_y,n_h,···,n_h,n_y)
  9. learning_rate - 学习率
  10. num_iterations - 迭代的次数
  11. print_cost - 是否打印成本值,每100次打印一次
  12. isPlot - 是否绘制出误差值的图谱
  13.  
  14. 返回:
  15. parameters - 模型学习的参数。 然后他们可以用来预测。
  16. """
  17. np.random.seed(1)
  18. costs = []
  19.  
  20. parameters = initialize_parameters_deep(layers_dims)
  21.  
  22. for i in range(0,num_iterations):
  23. AL , caches = L_model_forward(X,parameters)
  24.  
  25. cost = compute_cost(AL,Y)
  26.  
  27. grads = L_model_backward(AL,Y,caches)
  28.  
  29. parameters = update_parameters(parameters,grads,learning_rate)
  30.  
  31. #打印成本值,如果print_cost=False则忽略
  32. if i % 100 == 0:
  33. #记录成本
  34. costs.append(cost)
  35. #是否打印成本值
  36. if print_cost:
  37. print("第", i ,"次迭代,成本值为:" ,np.squeeze(cost))
  38. #迭代完成,根据条件绘制图
  39. if isPlot:
  40. plt.plot(np.squeeze(costs))
  41. plt.ylabel('cost')
  42. plt.xlabel('iterations (per tens)')
  43. plt.title("Learning rate =" + str(learning_rate))
  44. plt.show()
  45. return parameters

我们现在开始加载数据集:

  1. train_set_x_orig , train_set_y , test_set_x_orig , test_set_y , classes = lr_utils.load_dataset()
  2.  
  3. train_x_flatten = train_set_x_orig.reshape(train_set_x_orig.shape[0], -1).T
  4. test_x_flatten = test_set_x_orig.reshape(test_set_x_orig.shape[0], -1).T
  5.  
  6. train_x = train_x_flatten / 255
  7. train_y = train_set_y
  8. test_x = test_x_flatten / 255
  9. test_y = test_set_y

数据集加载完成,开始正式训练:

  1. layers_dims = [12288, 20, 7, 5, 1] # 5-layer model
  2. parameters = L_layer_model(train_x, train_y, layers_dims, num_iterations = 2500, print_cost = True,isPlot=True)
  1. 0 次迭代,成本值为: 0.715731513413713
  2. 100 次迭代,成本值为: 0.6747377593469114
  3. 200 次迭代,成本值为: 0.6603365433622127
  4. 300 次迭代,成本值为: 0.6462887802148751
  5. 400 次迭代,成本值为: 0.6298131216927773
  6. 500 次迭代,成本值为: 0.6060056229265339
  7. 600 次迭代,成本值为: 0.5690041263975134
  8. 700 次迭代,成本值为: 0.5197965350438059
  9. 800 次迭代,成本值为: 0.46415716786282285
  10. 900 次迭代,成本值为: 0.40842030048298916
  11. 1000 次迭代,成本值为: 0.37315499216069037
  12. 1100 次迭代,成本值为: 0.30572374573047123
  13. 1200 次迭代,成本值为: 0.2681015284774084
  14. 1300 次迭代,成本值为: 0.23872474827672574
  15. 1400 次迭代,成本值为: 0.20632263257914704
  16. 1500 次迭代,成本值为: 0.17943886927493524
  17. 1600 次迭代,成本值为: 0.15798735818801113
  18. 1700 次迭代,成本值为: 0.14240413012273798
  19. 1800 次迭代,成本值为: 0.1286516599788517
  20. 1900 次迭代,成本值为: 0.11244314998153365
  21. 2000 次迭代,成本值为: 0.08505631034962911
  22. 2100 次迭代,成本值为: 0.05758391198603161
  23. 2200 次迭代,成本值为: 0.04456753454692599
  24. 2300 次迭代,成本值为: 0.038082751665970464
  25. 2400 次迭代,成本值为: 0.034410749018399016
 

训练完成,我们看一下预测:

  1. pred_train = predict(train_x, train_y, parameters) #训练集
  2. pred_test = predict(test_x, test_y, parameters) #测试集
  1. 准确度为: 0.9952153110047847
  2. 准确度为: 0.78
    72%再到78%,可以看到的是准确度在一点点增加,当然,你也可以手动的去调整layers_dims,准确度可能又会提高一些。

分析

  1. def print_mislabeled_images(classes, X, y, p):
  2. """
  3. 绘制预测和实际不同的图像。
  4. X - 数据集
  5. y - 实际的标签
  6. p - 预测
  7. """
  8. a = p + y
  9. mislabeled_indices = np.asarray(np.where(a == 1))
  10. plt.rcParams['figure.figsize'] = (40.0, 40.0) # set default size of plots
  11. num_images = len(mislabeled_indices[0])
  12. for i in range(num_images):
  13. index = mislabeled_indices[1][i]
  14.  
  15. plt.subplot(2, num_images, i + 1)
  16. plt.imshow(X[:,index].reshape(64,64,3), interpolation='nearest')
  17. plt.axis('off')
  18. plt.title("Prediction: " + classes[int(p[0,index])].decode("utf-8") + " \n Class: " + classes[y[0,index]].decode("utf-8"))
  19.  
  20. print_mislabeled_images(classes, test_x, test_y, pred_test)

分析一下我们就可以得知原因了:

模型往往表现欠佳的几种类型的图像包括:

    • 猫身体在一个不同的位置
    • 猫出现在相似颜色的背景下
    • 不同的猫的颜色和品种
    • 相机角度
    • 图片的亮度
    • 比例变化(猫的图像非常大或很小)

相关库代码

lr_utils.py

  1. # lr_utils.py
  2. import numpy as np
  3. import h5py
  4.  
  5. def load_dataset():
  6. train_dataset = h5py.File('datasets/train_catvnoncat.h5', "r")
  7. train_set_x_orig = np.array(train_dataset["train_set_x"][:]) # your train set features
  8. train_set_y_orig = np.array(train_dataset["train_set_y"][:]) # your train set labels
  9.  
  10. test_dataset = h5py.File('datasets/test_catvnoncat.h5', "r")
  11. test_set_x_orig = np.array(test_dataset["test_set_x"][:]) # your test set features
  12. test_set_y_orig = np.array(test_dataset["test_set_y"][:]) # your test set labels
  13.  
  14. classes = np.array(test_dataset["list_classes"][:]) # the list of classes
  15.  
  16. train_set_y_orig = train_set_y_orig.reshape((1, train_set_y_orig.shape[0]))
  17. test_set_y_orig = test_set_y_orig.reshape((1, test_set_y_orig.shape[0]))
  18.  
  19. return train_set_x_orig, train_set_y_orig, test_set_x_orig, test_set_y_orig, classes

dnn_utils.py

  1. # dnn_utils.py
  2. import numpy as np
  3.  
  4. def sigmoid(Z):
  5. """
  6. Implements the sigmoid activation in numpy
  7.  
  8. Arguments:
  9. Z -- numpy array of any shape
  10.  
  11. Returns:
  12. A -- output of sigmoid(z), same shape as Z
  13. cache -- returns Z as well, useful during backpropagation
  14. """
  15.  
  16. A = 1/(1+np.exp(-Z))
  17. cache = Z
  18.  
  19. return A, cache
  20.  
  21. def sigmoid_backward(dA, cache):
  22. """
  23. Implement the backward propagation for a single SIGMOID unit.
  24.  
  25. Arguments:
  26. dA -- post-activation gradient, of any shape
  27. cache -- 'Z' where we store for computing backward propagation efficiently
  28.  
  29. Returns:
  30. dZ -- Gradient of the cost with respect to Z
  31. """
  32.  
  33. Z = cache
  34.  
  35. s = 1/(1+np.exp(-Z))
  36. dZ = dA * s * (1-s)
  37.  
  38. assert (dZ.shape == Z.shape)
  39.  
  40. return dZ
  41.  
  42. def relu(Z):
  43. """
  44. Implement the RELU function.
  45.  
  46. Arguments:
  47. Z -- Output of the linear layer, of any shape
  48.  
  49. Returns:
  50. A -- Post-activation parameter, of the same shape as Z
  51. cache -- a python dictionary containing "A" ; stored for computing the backward pass efficiently
  52. """
  53.  
  54. A = np.maximum(0,Z)
  55.  
  56. assert(A.shape == Z.shape)
  57.  
  58. cache = Z
  59. return A, cache
  60.  
  61. def relu_backward(dA, cache):
  62. """
  63. Implement the backward propagation for a single RELU unit.
  64.  
  65. Arguments:
  66. dA -- post-activation gradient, of any shape
  67. cache -- 'Z' where we store for computing backward propagation efficiently
  68.  
  69. Returns:
  70. dZ -- Gradient of the cost with respect to Z
  71. """
  72.  
  73. Z = cache
  74. dZ = np.array(dA, copy=True) # just converting dz to a correct object.
  75.  
  76. # When z <= 0, you should set dz to 0 as well.
  77. dZ[Z <= 0] = 0
  78.  
  79. assert (dZ.shape == Z.shape)
  80.  
  81. return dZ

testCase.py

  1. #testCase.py
  2. import numpy as np
  3.  
  4. def linear_forward_test_case():
  5. np.random.seed(1)
  6. A = np.random.randn(3,2)
  7. W = np.random.randn(1,3)
  8. b = np.random.randn(1,1)
  9.  
  10. return A, W, b
  11.  
  12. def linear_activation_forward_test_case():
  13. np.random.seed(2)
  14. A_prev = np.random.randn(3,2)
  15. W = np.random.randn(1,3)
  16. b = np.random.randn(1,1)
  17. return A_prev, W, b
  18.  
  19. def L_model_forward_test_case():
  20. np.random.seed(1)
  21. X = np.random.randn(4,2)
  22. W1 = np.random.randn(3,4)
  23. b1 = np.random.randn(3,1)
  24. W2 = np.random.randn(1,3)
  25. b2 = np.random.randn(1,1)
  26. parameters = {"W1": W1,
  27. "b1": b1,
  28. "W2": W2,
  29. "b2": b2}
  30.  
  31. return X, parameters
  32.  
  33. def compute_cost_test_case():
  34. Y = np.asarray([[1, 1, 1]])
  35. aL = np.array([[.8,.9,0.4]])
  36.  
  37. return Y, aL
  38.  
  39. def linear_backward_test_case():
  40. np.random.seed(1)
  41. dZ = np.random.randn(1,2)
  42. A = np.random.randn(3,2)
  43. W = np.random.randn(1,3)
  44. b = np.random.randn(1,1)
  45. linear_cache = (A, W, b)
  46. return dZ, linear_cache
  47.  
  48. def linear_activation_backward_test_case():
  49. np.random.seed(2)
  50. dA = np.random.randn(1,2)
  51. A = np.random.randn(3,2)
  52. W = np.random.randn(1,3)
  53. b = np.random.randn(1,1)
  54. Z = np.random.randn(1,2)
  55. linear_cache = (A, W, b)
  56. activation_cache = Z
  57. linear_activation_cache = (linear_cache, activation_cache)
  58.  
  59. return dA, linear_activation_cache
  60.  
  61. def L_model_backward_test_case():
  62. np.random.seed(3)
  63. AL = np.random.randn(1, 2)
  64. Y = np.array([[1, 0]])
  65.  
  66. A1 = np.random.randn(4,2)
  67. W1 = np.random.randn(3,4)
  68. b1 = np.random.randn(3,1)
  69. Z1 = np.random.randn(3,2)
  70. linear_cache_activation_1 = ((A1, W1, b1), Z1)
  71.  
  72. A2 = np.random.randn(3,2)
  73. W2 = np.random.randn(1,3)
  74. b2 = np.random.randn(1,1)
  75. Z2 = np.random.randn(1,2)
  76. linear_cache_activation_2 = ( (A2, W2, b2), Z2)
  77.  
  78. caches = (linear_cache_activation_1, linear_cache_activation_2)
  79.  
  80. return AL, Y, caches
  81.  
  82. def update_parameters_test_case():
  83. np.random.seed(2)
  84. W1 = np.random.randn(3,4)
  85. b1 = np.random.randn(3,1)
  86. W2 = np.random.randn(1,3)
  87. b2 = np.random.randn(1,1)
  88. parameters = {"W1": W1,
  89. "b1": b1,
  90. "W2": W2,
  91. "b2": b2}
  92. np.random.seed(3)
  93. dW1 = np.random.randn(3,4)
  94. db1 = np.random.randn(3,1)
  95. dW2 = np.random.randn(1,3)
  96. db2 = np.random.randn(1,1)
  97. grads = {"dW1": dW1,
  98. "db1": db1,
  99. "dW2": dW2,
  100. "db2": db2}
  101.  
  102. return parameters, grads

深度学习之深L层神经网络的更多相关文章

  1. TensorFlow 2.0 深度学习实战 —— 浅谈卷积神经网络 CNN

    前言 上一章为大家介绍过深度学习的基础和多层感知机 MLP 的应用,本章开始将深入讲解卷积神经网络的实用场景.卷积神经网络 CNN(Convolutional Neural Networks,Conv ...

  2. 深度学习与CV教程(4) | 神经网络与反向传播

    作者:韩信子@ShowMeAI 教程地址:http://www.showmeai.tech/tutorials/37 本文地址:http://www.showmeai.tech/article-det ...

  3. 深度学习与CV教程(6) | 神经网络训练技巧 (上)

    作者:韩信子@ShowMeAI 教程地址:http://www.showmeai.tech/tutorials/37 本文地址:http://www.showmeai.tech/article-det ...

  4. 对比《动手学深度学习》 PDF代码+《神经网络与深度学习 》PDF

    随着AlphaGo与李世石大战的落幕,人工智能成为话题焦点.AlphaGo背后的工作原理"深度学习"也跳入大众的视野.什么是深度学习,什么是神经网络,为何一段程序在精密的围棋大赛中 ...

  5. SIGAI深度学习第八集 卷积神经网络2

    讲授Lenet.Alexnet.VGGNet.GoogLeNet等经典的卷积神经网络.Inception模块.小尺度卷积核.1x1卷积核.使用反卷积实现卷积层可视化等. 大纲: LeNet网络 Ale ...

  6. Andrew Ng - 深度学习工程师 - Part 1. 神经网络和深度学习(Week 4. 深层神经网络)

     =================第2周 神经网络基础=============== ===4.1  深层神经网络=== Although for any given problem it migh ...

  7. SIGAI深度学习第七集 卷积神经网络1

    讲授卷积神经网络核心思想.卷积层.池化层.全连接层.网络的训练.反向传播算法.随机梯度下降法.AdaGrad算法.RMSProp算法.AdaDelta算法.Adam算法.迁移学习和fine tune等 ...

  8. TensorFlow深度学习实战---图像识别与卷积神经网络

    全连接层网络结构:神经网络每两层之间的所有结点都是有边相连的. 卷积神经网络:1.输入层 2.卷积层:将神经网络中的每一个小块进行更加深入地分析从而得到抽象程度更高的特征. 3 池化层:可以认为将一张 ...

  9. 如何可视化深度学习网络中Attention层

    前言 在训练深度学习模型时,常想一窥网络结构中的attention层权重分布,观察序列输入的哪些词或者词组合是网络比较care的.在小论文中主要研究了关于词性POS对输入序列的注意力机制.同时对比实验 ...

  10. 深度学习原理与框架-卷积神经网络基本原理 1.卷积层的前向传播 2.卷积参数共享 3. 卷积后的维度计算 4. max池化操作 5.卷积流程图 6.卷积层的反向传播 7.池化层的反向传播

    卷积神经网络的应用:卷积神经网络使用卷积提取图像的特征来进行图像的分类和识别       分类                        相似图像搜索                        ...

随机推荐

  1. KingbaseESV8R6等待事件之lwlock buffer_content

    前言 等待事件是排查数据库性能的指标之一.简单理解,cpu在处理业务时由于业务逻辑,和不可避免的数据库其他原因造成的前台进程等待,这里的等待事件包含buffer类,io类,以及网络类等等,当我们遇到等 ...

  2. IIS 实现http重定向https(亲测有效:解决URL重写模块配置https重定向不生效的问题)

    前言 以前部署网站的时候,都是通过代码来实现http重定向https,最近在部署个人网站的时候,突发奇想可不可通过IIS来实现无代码的重定向呢? 在一番操作猛如虎的搜索引擎操作后,发现只有google ...

  3. LIMIT和OFFSET分页性能差!今天来介绍如何高性能分页

    GreatSQL社区原创内容未经授权不得随意使用,转载请联系小编并注明来源. GreatSQL是MySQL的国产分支版本,使用上与MySQL一致. 前言 之前的大多数人分页采用的都是这样: SELEC ...

  4. 使用SSH连接Windows Server

    之前发过一篇在Windows Server上启用SSH服务器的文章.最近正好有这个需求,需要使用密钥免密登录服务器,试了一下,发现之前的方法不行了.需要再修正一些文件权限. 需要使用Repair-Au ...

  5. Elasticsearch:Smart Chinese Analysis plugin

    Smart Chinese Analysis插件将Lucene的Smart Chinese分析模块集成到Elasticsearch中,用于分析中文或中英文混合文本. 支持的分析器在大型训练语料库上使用 ...

  6. k8s上安装elasticsearch集群

    官方文档地址:https://www.elastic.co/guide/en/cloud-on-k8s/current/k8s-quickstart.html yaml文件地址:https://dow ...

  7. CentOS yum如何安装php7.4

    centos系统下使用yum安装php7.4正式版,当前基于WLNMP提供的一键安装包来安装 1.添加epel源 yum install epel-release 2.添加WLNMP一键安装包源 rp ...

  8. 内网横向渗透 之 ATT&CK系列一 之 拿下域控制器

    信息收集 信息收集 域控制器的相关信息: 通过arp扫描发现域控制器的ip地址为:192.168.52.138,尝试使用msf的smb_login模块登录smb是否成功 1 search smb_lo ...

  9. iOS Social和Accounts简单使用

    ACAccountStore *account = [[ACAccountStore alloc] init]; ACAccountType *type = [account accountTypeW ...

  10. 《Hyperspectral Image Classification With Deep Feature Fusion Network》论文笔记

    论文题目<Hyperspectral Image Classification With Deep Feature Fusion Network> 论文作者:Weiwei Song, Sh ...