【DSW Gallery】使用Numpy实现卷积神经网络

本文涉及的产品
交互式建模 PAI-DSW,5000CU*H 3个月
模型训练 PAI-DLC,5000CU*H 3个月
模型在线服务 PAI-EAS,A10/V100等 500元 1个月
简介: Numpy是数值计算中使用非常广泛的一个工具包,可以进行高纬度空间内部的矩阵运算。本文以CNN为例子,使用Numpy来实现CNN网络的前向传递和反向传递逻辑。对于了解CNN网络的细节以及学习如何使用Numpy都很有帮助。

直接使用

请打开使用Numpy实现卷积神经网络,并点击右上角 “ 在DSW中打开” 。

image.png

使用Numpy实现CNN的前向网络以及反向传播

本文用到的数据集来自Kaggle,可以在这里下载

import numpy as np
import pandas as pd
from matplotlib import pyplot as plt
data = pd.read_csv('train_numpy.csv')
data.shape
(2290, 785)
data = np.array(data)
m, n = data.shape
np.random.shuffle(data) # shuffle before splitting into dev and training sets
data_dev = data[0:1000].T
Y_dev = data_dev[0]
X_dev = data_dev[1:n]
X_dev = X_dev / 255.
data_train = data[1000:m].T
Y_train = data_train[0]
X_train = data_train[1:n]
X_train = X_train / 255.
_,m_train = X_train.shape

本例中,我们定义一个只有两层的卷积神经网络

  1. Activate function选的是 Relu,因为它可以有效的改善梯度弥散现象
  2. 最后会通过Softmax将各个神经元的输出结果转化为[0,1]之间的数字

前向传递

13-1.png

反向传递

13-2.png

参数更新的计算公式

13-3.png

根据上面的公式,定义activation function

def init_params():
    W1 = np.random.rand(10, 784) - 0.5
    b1 = np.random.rand(10, 1) - 0.5
    W2 = np.random.rand(10, 10) - 0.5
    b2 = np.random.rand(10, 1) - 0.5
    return W1, b1, W2, b2
def ReLU(Z):
    return np.maximum(Z, 0)
def ReLU_deriv(Z):
    return Z > 0
def softmax(Z):
    A = np.exp(Z) / sum(np.exp(Z))
    return A

定义前向传递的函数和反向传递的函数

def forward_prop(W1, b1, W2, b2, X):
    Z1 = W1.dot(X) + b1
    A1 = ReLU(Z1)
    Z2 = W2.dot(A1) + b2
    A2 = softmax(Z2)
    return Z1, A1, Z2, A2
def one_hot(Y):
    one_hot_Y = np.zeros((Y.size, int(Y.max()) + 1)).astype(int)
    one_hot_Y[np.arange(Y.size), Y.astype(int)] = 1
    one_hot_Y = one_hot_Y.T
    return one_hot_Y
def backward_prop(Z1, A1, Z2, A2, W1, W2, X, Y):
    one_hot_Y = one_hot(Y)
    dZ2 = A2 - one_hot_Y
    dW2 = 1 / m * dZ2.dot(A1.T)
    db2 = 1 / m * np.sum(dZ2)
    dZ1 = W2.T.dot(dZ2) * ReLU_deriv(Z1)
    dW1 = 1 / m * dZ1.dot(X.T)
    db1 = 1 / m * np.sum(dZ1)
    return dW1, db1, dW2, db2
def update_params(W1, b1, W2, b2, dW1, db1, dW2, db2, alpha):
    W1 = W1 - alpha * dW1
    b1 = b1 - alpha * db1    
    W2 = W2 - alpha * dW2  
    b2 = b2 - alpha * db2    
    return W1, b1, W2, b2

定义预测、梯度下降还有计算精确度的函数

def get_predictions(A2):
    return np.argmax(A2, 0)
def get_accuracy(predictions, Y):
    print(predictions, Y)
    return np.sum(predictions == Y) / Y.size
def gradient_descent(X, Y, alpha, iterations):
    W1, b1, W2, b2 = init_params()
    for i in range(iterations):
        Z1, A1, Z2, A2 = forward_prop(W1, b1, W2, b2, X)
        dW1, db1, dW2, db2 = backward_prop(Z1, A1, Z2, A2, W1, W2, X, Y)
        W1, b1, W2, b2 = update_params(W1, b1, W2, b2, dW1, db1, dW2, db2, alpha)
        if i % 10 == 0:
            print("Iteration: ", i)
            predictions = get_predictions(A2)
            print(get_accuracy(predictions, Y))
    return W1, b1, W2, b2

开始训练

W1, b1, W2, b2 = gradient_descent(X_train, Y_train, 0.10, 500)

image.png

Iteration:  0
[2 2 2 ... 1 3 2] [9. 7. 2. ... 5. 6. 0.]
0.1263565891472868
Iteration:  10
[1 1 0 ... 1 3 6] [9. 7. 2. ... 5. 6. 0.]
0.1821705426356589
Iteration:  20
[1 1 2 ... 4 0 6] [9. 7. 2. ... 5. 6. 0.]
0.2372093023255814
Iteration:  30
[1 1 6 ... 0 0 6] [9. 7. 2. ... 5. 6. 0.]
0.29147286821705426
Iteration:  40
[1 1 6 ... 0 0 6] [9. 7. 2. ... 5. 6. 0.]
0.3333333333333333
Iteration:  50
[1 1 6 ... 0 0 0] [9. 7. 2. ... 5. 6. 0.]
0.38527131782945734
Iteration:  60
[1 1 6 ... 0 0 0] [9. 7. 2. ... 5. 6. 0.]
0.4325581395348837
Iteration:  70
[1 1 2 ... 0 0 0] [9. 7. 2. ... 5. 6. 0.]
0.4906976744186046
Iteration:  80
[5 7 2 ... 0 0 0] [9. 7. 2. ... 5. 6. 0.]
0.537984496124031
Iteration:  90
[5 7 2 ... 0 0 0] [9. 7. 2. ... 5. 6. 0.]
0.5612403100775194
Iteration:  100
[5 7 2 ... 0 0 0] [9. 7. 2. ... 5. 6. 0.]
0.5844961240310077
Iteration:  110
[5 7 2 ... 0 6 0] [9. 7. 2. ... 5. 6. 0.]
0.6069767441860465
Iteration:  120
[5 7 2 ... 0 6 0] [9. 7. 2. ... 5. 6. 0.]
0.624031007751938
Iteration:  130
[5 7 2 ... 0 6 0] [9. 7. 2. ... 5. 6. 0.]
0.6403100775193798
Iteration:  140
[9 7 2 ... 0 6 0] [9. 7. 2. ... 5. 6. 0.]
0.662015503875969
Iteration:  150
[9 7 2 ... 0 6 0] [9. 7. 2. ... 5. 6. 0.]
0.6713178294573643
Iteration:  160
[9 7 2 ... 0 6 0] [9. 7. 2. ... 5. 6. 0.]
0.6922480620155039
Iteration:  170
[9 7 2 ... 0 6 0] [9. 7. 2. ... 5. 6. 0.]
0.6992248062015504
Iteration:  180
[9 7 2 ... 0 6 0] [9. 7. 2. ... 5. 6. 0.]
0.7116279069767442
Iteration:  190
[9 7 2 ... 0 6 0] [9. 7. 2. ... 5. 6. 0.]
0.7162790697674418
Iteration:  200
[9 7 2 ... 0 6 0] [9. 7. 2. ... 5. 6. 0.]
0.724031007751938
Iteration:  210
[9 7 2 ... 0 6 0] [9. 7. 2. ... 5. 6. 0.]
0.727906976744186
Iteration:  220
[9 7 2 ... 0 6 0] [9. 7. 2. ... 5. 6. 0.]
0.7333333333333333
Iteration:  230
[9 7 2 ... 0 6 0] [9. 7. 2. ... 5. 6. 0.]
0.7395348837209302
Iteration:  240
[9 7 2 ... 0 6 0] [9. 7. 2. ... 5. 6. 0.]
0.7434108527131783
Iteration:  250
[9 7 2 ... 5 6 0] [9. 7. 2. ... 5. 6. 0.]
0.7550387596899225
Iteration:  260
[9 7 2 ... 5 6 0] [9. 7. 2. ... 5. 6. 0.]
0.7581395348837209
Iteration:  270
[9 7 2 ... 5 6 0] [9. 7. 2. ... 5. 6. 0.]
0.7697674418604651
Iteration:  280
[9 7 2 ... 5 6 0] [9. 7. 2. ... 5. 6. 0.]
0.7751937984496124
Iteration:  290
[9 7 2 ... 5 6 0] [9. 7. 2. ... 5. 6. 0.]
0.7798449612403101
Iteration:  300
[9 7 2 ... 5 6 0] [9. 7. 2. ... 5. 6. 0.]
0.7821705426356589
Iteration:  310
[9 7 2 ... 5 6 0] [9. 7. 2. ... 5. 6. 0.]
0.7883720930232558
Iteration:  320
[9 7 2 ... 5 6 0] [9. 7. 2. ... 5. 6. 0.]
0.7937984496124031
Iteration:  330
[9 7 2 ... 5 6 0] [9. 7. 2. ... 5. 6. 0.]
0.7968992248062016
Iteration:  340
[9 7 2 ... 5 6 0] [9. 7. 2. ... 5. 6. 0.]
0.8007751937984496
Iteration:  350
[9 7 2 ... 5 6 0] [9. 7. 2. ... 5. 6. 0.]
0.8062015503875969
Iteration:  360
[9 7 2 ... 5 6 0] [9. 7. 2. ... 5. 6. 0.]
0.8093023255813954
Iteration:  370
[9 7 2 ... 5 6 0] [9. 7. 2. ... 5. 6. 0.]
0.8147286821705426
Iteration:  380
[9 7 2 ... 5 6 0] [9. 7. 2. ... 5. 6. 0.]
0.8178294573643411
Iteration:  390
[9 7 2 ... 5 6 0] [9. 7. 2. ... 5. 6. 0.]
0.8217054263565892
Iteration:  400
[9 7 2 ... 5 6 0] [9. 7. 2. ... 5. 6. 0.]
0.8224806201550388
Iteration:  410
[9 7 2 ... 5 6 0] [9. 7. 2. ... 5. 6. 0.]
0.8255813953488372
Iteration:  420
[9 7 2 ... 5 6 0] [9. 7. 2. ... 5. 6. 0.]
0.8255813953488372
Iteration:  430
[9 7 2 ... 5 6 0] [9. 7. 2. ... 5. 6. 0.]
0.8263565891472868
Iteration:  440
[9 7 2 ... 5 6 0] [9. 7. 2. ... 5. 6. 0.]
0.8310077519379845
Iteration:  450
[9 7 2 ... 5 6 0] [9. 7. 2. ... 5. 6. 0.]
0.8333333333333334
Iteration:  460
[9 7 2 ... 5 6 0] [9. 7. 2. ... 5. 6. 0.]
0.8348837209302326
Iteration:  470
[9 7 2 ... 5 6 0] [9. 7. 2. ... 5. 6. 0.]
0.8395348837209302
Iteration:  480
[9 7 2 ... 5 6 0] [9. 7. 2. ... 5. 6. 0.]
0.8395348837209302
Iteration:  490
[9 7 2 ... 5 6 0] [9. 7. 2. ... 5. 6. 0.]
0.8418604651162791
def make_predictions(X, W1, b1, W2, b2):
    _, _, _, A2 = forward_prop(W1, b1, W2, b2, X)
    predictions = get_predictions(A2)
    return predictions
def test_prediction(index, W1, b1, W2, b2):
    current_image = X_train[:, index, None]
    prediction = make_predictions(X_train[:, index, None], W1, b1, W2, b2)
    label = Y_train[index]
    print("Prediction: ", prediction)
    print("Label: ", label)
    current_image = current_image.reshape((28, 28)) * 255
    plt.gray()
    plt.imshow(current_image, interpolation='nearest')
    plt.show()

下面我们选择几个输入,看一下我们的CNN模型是否能够正确识别图片中的字

test_prediction(0, W1, b1, W2, b2)
test_prediction(1, W1, b1, W2, b2)
test_prediction(2, W1, b1, W2, b2)
test_prediction(3, W1, b1, W2, b2)
Prediction:  [9]
Label:  9.0

13-4.png

Prediction:  [7]
Label:  7.0

13-5.png

Prediction:  [2]
Label:  2.0

13-6.png

Prediction:  [7]
Label:  7.0

13-7.png

计算一下模型对整个的数据集的精确度

dev_predictions = make_predictions(X_dev, W1, b1, W2, b2)
print("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习
使用PAI-EAS一键部署ChatGLM及LangChain应用
本场景中主要介绍如何使用模型在线服务(PAI-EAS)部署ChatGLM的AI-Web应用以及启动WebUI进行模型推理,并通过LangChain集成自己的业务数据。
机器学习概览及常见算法
机器学习(Machine Learning, ML)是人工智能的核心,专门研究计算机怎样模拟或实现人类的学习行为,以获取新的知识或技能,重新组织已有的知识结构使之不断改善自身的性能,它是使计算机具有智能的根本途径,其应用遍及人工智能的各个领域。 本课程将带你入门机器学习,掌握机器学习的概念和常用的算法。
相关文章
|
9天前
|
机器学习/深度学习 PyTorch 算法框架/工具
【从零开始学习深度学习】32. 卷积神经网络之稠密连接网络(DenseNet)介绍及其Pytorch实现
【从零开始学习深度学习】32. 卷积神经网络之稠密连接网络(DenseNet)介绍及其Pytorch实现
|
9天前
|
机器学习/深度学习 算法 计算机视觉
卷积神经网络(CNN)的工作原理深度解析
【6月更文挑战第14天】本文深度解析卷积神经网络(CNN)的工作原理。CNN由输入层、卷积层、激活函数、池化层、全连接层和输出层构成。卷积层通过滤波器提取特征,激活函数增加非线性,池化层降低维度。全连接层整合特征,输出层根据任务产生预测。CNN通过特征提取、整合、反向传播和优化进行学习。尽管存在计算量大、参数多等问题,但随着技术发展,CNN在计算机视觉领域的潜力将持续增长。
|
9天前
|
机器学习/深度学习 PyTorch 算法框架/工具
【从零开始学习深度学习】28.卷积神经网络之NiN模型介绍及其Pytorch实现【含完整代码】
【从零开始学习深度学习】28.卷积神经网络之NiN模型介绍及其Pytorch实现【含完整代码】
|
9天前
|
机器学习/深度学习 PyTorch 算法框架/工具
【从零开始学习深度学习】31. 卷积神经网络之残差网络(ResNet)介绍及其Pytorch实现
【从零开始学习深度学习】31. 卷积神经网络之残差网络(ResNet)介绍及其Pytorch实现
|
4天前
|
机器学习/深度学习 网络架构 计算机视觉
VGG深度卷积神经网络架构
VGG深度卷积神经网络架构
|
2天前
|
机器学习/深度学习 算法 计算机视觉
没有公式,不要代码,让你理解 RCNN:目标检测中的区域卷积神经网络
没有公式,不要代码,让你理解 RCNN:目标检测中的区域卷积神经网络
5 0
没有公式,不要代码,让你理解 RCNN:目标检测中的区域卷积神经网络
|
9天前
|
机器学习/深度学习 PyTorch 算法框架/工具
【从零开始学习深度学习】29.卷积神经网络之GoogLeNet模型介绍及用Pytorch实现GoogLeNet模型【含完整代码】
【从零开始学习深度学习】29.卷积神经网络之GoogLeNet模型介绍及用Pytorch实现GoogLeNet模型【含完整代码】
|
2天前
|
机器学习/深度学习 自然语言处理 TensorFlow
深入浅出:理解和实现深度学习中的卷积神经网络(CNN)
在当今的数据驱动世界,深度学习已经成为许多领域的关键技术。本文将深入探讨卷积神经网络(CNN)的原理、结构和应用,旨在帮助读者全面理解这项强大的技术,并提供实际的实现技巧。
17 0
|
8天前
|
机器学习/深度学习 自然语言处理 前端开发
深度学习-[数据集+完整代码]基于卷积神经网络的缺陷检测
深度学习-[数据集+完整代码]基于卷积神经网络的缺陷检测
|
9天前
|
机器学习/深度学习 算法 PyTorch
【从零开始学习深度学习】50.Pytorch_NLP项目实战:卷积神经网络textCNN在文本情感分类的运用
【从零开始学习深度学习】50.Pytorch_NLP项目实战:卷积神经网络textCNN在文本情感分类的运用

热门文章

最新文章