撒花!《神经网络与深度学习》中文教程正式开源!全书 pdf、ppt 和代码一同放出

简介: 撒花!《神经网络与深度学习》中文教程正式开源!全书 pdf、ppt 和代码一同放出


红色石头之前在某乎上回答“机器学习该怎么入门”这个问题的时候,曾经给入门学者提过一个建议,就是放弃海量资料。确实,资料不在多而在精!一份优秀的资料完全可以帮助我们快速地入门和进阶。


今天给大家推荐一份最近新出的非常火热的深度学习入门教程:《神经网络与深度学习》,这本书由复旦大学的邱锡鹏老师所著。


image.png


神经网络与深度学习》排在首位的特点就是它是完全的中文教程。我相信大部分深度学习入门学者面对英文教程的时候,战斗力多半会削减大半。而邱锡鹏老师的这本书恰恰为中国学生而著,大大降低了深度学习的语言门槛,让大家有更多的精力放在核心知识内容的学习上。


关于本书


关于本书,邱锡鹏是这样评价的:


近年来,以机器学习、知识图谱为代表的人工智能技术逐渐变得普及。从车牌识别、人脸识别、语音识别、智能问答、推荐系统到自动驾驶,人们在日常生活中都可能有意无意地使用到了人工智能技术。这些技术的背后都离不开人工智能领域研究者们的长期努力。特别是最近这几年,得益于数据的增多、计算能力的增强、学习算法的成熟以及应用场景的丰富,越来越多的人开始关注这一个“崭新”的研究领域:深度学习。深度学习以神经网络为主要模型,一开始用来解决机器学习中的表示学习问题。但是由于其强大的能力,深度学习越来越多地用来解决一些通用人工智能问题,比如推理、决策等。目前,深度学习技术在学术界和工业界取得了广泛的成功,受到高度重视,并掀起新一轮的人工智能热潮。


这本书的作者邱锡鹏老师,目前是复旦大学计算机科学技术学院的博士生导师、自然语言处理与深度学习组的副教授。


神经网络与深度学习》主要介绍神经网络与深度学习中的基础知识、主要模型(卷积神经网络、递归神经网络等)以及在计算机视觉、自然语言处理等领域的实际应用。


主要内容


这本书目前已经更新完毕,总共包含了 15 章。内容涉及神经网络集基础知识以及经典的 CNN、RNN 模型,还有其在 CV 和 NLP 方面的应用。15 章内容分为三大部分:第一部分为入门篇,包括 1~3 章;第二部分为基础模型,包括 4~10 章;第三部分为进阶模型,包括 11~15 章。


完整书籍目录如下:


  • 第 1 章:绪论
  • 第 2 章:机器学习概述
  • 第 3 章:线性模型
  • 第 4 章:前馈神经网络
  • 第 5 章:卷积神经网络
  • 第 6 章:循环神经网络
  • 第 7 章:网络优化与正则化
  • 第 8 章:注意力机制与外部记忆
  • 第 8 章:无监督学习
  • 第 10 章:模型独立的学习方式
  • 第 11 章:概率图模型
  • 第 12 章:深度信念网络
  • 第 13 章:深度生成模型
  • 第 14 章:深度强化学习
  • 第 15 章:序列生成模型


除了 15 章正文内容外,作者还为我们提供了详细的数学基础知识,放在了附录部分。数学基础总共包含 4 方面内容:


  • 附录 A:线性代数
  • 附录 B:微积分
  • 附录 C:数学优化
  • 附录 D:概率论


image.png


这些数学基础知识,可谓是神经网络与深度学习的内功心法!也是本书的最大亮点之一,能够极大提升我们在阅读本书的效率。


课程资源


目前,邱锡鹏老师已经开源了该课程所有的资源,包括书籍 pdf,课程 ppt,书籍相关习题参考代码等。


课程主页:

https://nndl.github.io/


全书 pdf:

https://nndl.github.io/nndl-book.pdf


3 小时课程概要:

https://nndl.github.io/ppt/%E7%A5%9E%E7%BB%8F%E7%BD%91%E7%BB%9C%E4%B8%8E%E6%B7%B1%E5%BA%A6%E5%AD%A6%E4%B9%A0-3%E5%B0%8F%E6%97%B6.pdf


示例代码:

https://github.com/nndl/nndl-codes


课程练习:

https://github.com/nndl/exercise


关于课程练习,作者大都提供了最热门的 PyTorch 和 TensorFlow 两种框架的实现方式。以第 5 章 CNN 为例,我们来看一下相关代码。


PyTorch 实现:


import os
import torch
import torch.nn as nn
from torch.autograd import Variable
import torch.utils.data as Data
import torchvision
import torch.nn.functional as F
import numpy as np
learning_rate = 1e-4
keep_prob_rate = 0.7 #
max_epoch = 3
BATCH_SIZE = 50
DOWNLOAD_MNIST = False
if not(os.path.exists('./mnist/')) or not os.listdir('./mnist/'):
# not mnist dir or mnist is empyt dir
DOWNLOAD_MNIST = True
train_data = torchvision.datasets.MNIST(root='./mnist/',train=True, transform=torchvision.transforms.ToTensor(), download=DOWNLOAD_MNIST,)
train_loader = Data.DataLoader(dataset = train_data ,batch_size= BATCH_SIZE ,shuffle= True)
test_data = torchvision.datasets.MNIST(root = './mnist/',train = False)
test_x = Variable(torch.unsqueeze(test_data.test_data,dim = 1),volatile = True).type(torch.FloatTensor)[:500]/255.
test_y = test_data.test_labels[:500].numpy()
class CNN(nn.Module):
def __init__(self):
super(CNN, self).__init__()
self.conv1 = nn.Sequential(
nn.Conv2d( # ???
# patch 7 * 7 ; 1 in channels ; 32 out channels ; ; stride is 1
# padding style is same(that means the convolution opration's input and output have the same size)
in_channels= ,
out_channels= ,
kernel_size= ,
stride= ,
padding= ,
),
nn.ReLU(), # activation function
nn.MaxPool2d(2), # pooling operation
)
self.conv2 = nn.Sequential( # ???
# line 1 : convolution function, patch 5*5 , 32 in channels ;64 out channels; padding style is same; stride is 1
# line 2 : choosing your activation funciont
# line 3 : pooling operation function.
)
self.out1 = nn.Linear( 7*7*64 , 1024 , bias= True) # full connection layer one
self.dropout = nn.Dropout(keep_prob_rate)
self.out2 = nn.Linear(1024,10,bias=True)
def forward(self, x):
x = self.conv1(x)
x = self.conv2(x)
x = x.view( ) # flatten the output of coonv2 to (batch_size ,32 * 7 * 7) # ???
out1 = self.out1(x)
out1 = F.relu(out1)
out1 = self.dropout(out1)
out2 = self.out2(out1)
output = F.softmax(out2)
return output
def test(cnn):
global prediction
y_pre = cnn(test_x)
_,pre_index= torch.max(y_pre,1)
pre_index= pre_index.view(-1)
prediction = pre_index.data.numpy()
correct = np.sum(prediction == test_y)
return correct / 500.0
def train(cnn):
optimizer = torch.optim.Adam(cnn.parameters(), lr=learning_rate )
loss_func = nn.CrossEntropyLoss()
for epoch in range(max_epoch):
for step, (x_, y_) in enumerate(train_loader):
x ,y= Variable(x_),Variable(y_)
output = cnn(x)
loss = loss_func(output,y)
optimizer.zero_grad()
loss.backward()
optimizer.step()
if step != 0 and step % 20 ==0:
print("=" * 10,step,"="*5,"="*5, "test accuracy is ",test(cnn) ,"=" * 10 )
if __name__ == '__main__':
cnn = CNN()
train(cnn)

TensorFlow 实现:


import tensorflow as tf
from tensorflow.examples.tutorials.mnist import input_data
mnist = input_data.read_data_sets('MNIST_data', one_hot=True)
learning_rate = 1e-4
keep_prob_rate = 0.7 #
max_epoch = 2000
def compute_accuracy(v_xs, v_ys):
global prediction
y_pre = sess.run(prediction, feed_dict={xs: v_xs, keep_prob: 1})
correct_prediction = tf.equal(tf.argmax(y_pre,1), tf.argmax(v_ys,1))
accuracy = tf.reduce_mean(tf.cast(correct_prediction, tf.float32))
result = sess.run(accuracy, feed_dict={xs: v_xs, ys: v_ys, keep_prob: 1})
return result
def weight_variable(shape):
initial = tf.truncated_normal(shape, stddev=0.1)
return tf.Variable(initial)
def bias_variable(shape):
initial = tf.constant(0.1, shape=shape)
return tf.Variable(initial)
def conv2d(x, W):
# 每一维度 滑动步长全部是 1, padding 方式 选择 same
# 提示 使用函数 tf.nn.conv2d
return
def max_pool_2x2(x):
# 滑动步长 是 2步; 池化窗口的尺度 高和宽度都是2; padding 方式 请选择 same
# 提示 使用函数 tf.nn.max_pool
return
# define placeholder for inputs to network
xs = tf.placeholder(tf.float32, [None, 784])/255.
ys = tf.placeholder(tf.float32, [None, 10])
keep_prob = tf.placeholder(tf.float32)
x_image = tf.reshape(xs, [-1, 28, 28, 1])
# 卷积层 1
## conv1 layer ##
W_conv1 = # patch 7x7, in size 1, out size 32
b_conv1 =
h_conv1 = # 卷积 自己选择 选择激活函数
h_pool1 = # 池化
# 卷积层 2
W_conv2 = # patch 5x5, in size 32, out size 64
b_conv2 =
h_conv2 = # 卷积 自己选择 选择激活函数
h_pool2 = # 池化
# 全连接层 1
## fc1 layer ##
W_fc1 = weight_variable([7*7*64, 1024])
b_fc1 = bias_variable([1024])
h_pool2_flat = tf.reshape(h_pool2, [-1, 7*7*64])
h_fc1 = tf.nn.relu(tf.matmul(h_pool2_flat, W_fc1) + b_fc1)
h_fc1_drop = tf.nn.dropout(h_fc1, keep_prob)
# 全连接层 2
## fc2 layer ##
W_fc2 = weight_variable([1024, 10])
b_fc2 = bias_variable([10])
prediction = tf.nn.softmax(tf.matmul(h_fc1_drop, W_fc2) + b_fc2)
# 交叉熵函数
cross_entropy = tf.reduce_mean(-tf.reduce_sum(ys * tf.log(prediction),
reduction_indices=[1]))
train_step = tf.train.AdamOptimizer(learning_rate).minimize(cross_entropy)
with tf.Session() as sess:
init = tf.global_variables_initializer()
sess.run(init)
for i in range(max_epoch):
batch_xs, batch_ys = mnist.train.next_batch(100)
sess.run(train_step, feed_dict={xs: batch_xs, ys: batch_ys, keep_prob:keep_prob_rate})
if i % 100 == 0:
print(compute_accuracy(
mnist.test.images[:1000], mnist.test.labels[:1000]))


开源万岁!这份优秀的深度学习资源,赶快试试吧~

目录
打赏
0
0
0
0
104
分享
相关文章
GNS3 v3.0.5 - 开源免费网络模拟器
GNS3 v3.0.5 - 开源免费网络模拟器
190 3
GNS3 v3.0.5 - 开源免费网络模拟器
图神经网络在信息检索重排序中的应用:原理、架构与Python代码解析
本文探讨了基于图的重排序方法在信息检索领域的应用与前景。传统两阶段检索架构中,初始检索速度快但结果可能含噪声,重排序阶段通过强大语言模型提升精度,但仍面临复杂需求挑战
78 0
图神经网络在信息检索重排序中的应用:原理、架构与Python代码解析
Arista CloudEOS 4.32.2F - 云网络基础架构即代码
Arista CloudEOS 4.32.2F - 云网络基础架构即代码
53 1
GPT-4o测评准确率竟不到1%!BrowseComp:OpenAI开源AI代理评测新基准,1266道高难度网络检索问题
OpenAI最新开源的BrowseComp基准包含1266个高难度网络检索问题,覆盖影视、科技、艺术等九大领域,其最新Deep Research模型以51.5%准确率展现复杂信息整合能力,为AI代理的浏览能力评估建立新标准。
147 4
GPT-4o测评准确率竟不到1%!BrowseComp:OpenAI开源AI代理评测新基准,1266道高难度网络检索问题
【工具教程】批量PDF和图片OCR识别指定区域文字自动改图片名字,多个区域一次性批量识别改名批量重命名
本内容介绍了一款用于企业档案、医院病历及办公文件管理的图片和PDF文字识别工具。通过框选识别区域,软件可批量提取关键信息,实现文件重命名或导出为表格,极大提升管理效率。支持图片与PDF两种模式,操作简单,适用于合同、病历、报告等场景。提供详细步骤指导,包含区域设置、文件导入、批量处理及结果校验等功能。
296 8
FireCrawl:开源 AI 网络爬虫工具,自动爬取网站及子页面内容,预处理为结构化数据
FireCrawl 是一款开源的 AI 网络爬虫工具,专为处理动态网页内容、自动爬取网站及子页面而设计,支持多种数据提取和输出格式。
1881 19
FireCrawl:开源 AI 网络爬虫工具,自动爬取网站及子页面内容,预处理为结构化数据
PaSa:字节跳动开源学术论文检索智能体,自动调用搜索引擎、浏览相关论文并追踪引文网络
PaSa 是字节跳动推出的基于强化学习的学术论文检索智能体,能够自动调用搜索引擎、阅读论文并追踪引文网络,帮助用户快速获取精准的学术文献。
432 15
NeurIPS 2024:标签噪声下图神经网络有了首个综合基准库,还开源
NoisyGL是首个针对标签噪声下图神经网络(GLN)的综合基准库,由浙江大学和阿里巴巴集团的研究人员开发。该基准库旨在解决现有GLN研究中因数据集选择、划分及预处理技术差异导致的缺乏统一标准问题,提供了一个公平、用户友好的平台,支持多维分析,有助于深入理解GLN方法在处理标签噪声时的表现。通过17种代表性方法在8个常用数据集上的广泛实验,NoisyGL揭示了多个关键发现,推动了GLN领域的进步。尽管如此,NoisyGL目前主要适用于同质图,对异质图的支持有限。
160 7
nmap 是一款强大的开源网络扫描工具,能检测目标的开放端口、服务类型和操作系统等信息
nmap 是一款强大的开源网络扫描工具,能检测目标的开放端口、服务类型和操作系统等信息。本文分三部分介绍 nmap:基本原理、使用方法及技巧、实际应用及案例分析。通过学习 nmap,您可以更好地了解网络拓扑和安全状况,提升网络安全管理和渗透测试能力。
543 5

热门文章

最新文章

AI助理

你好,我是AI助理

可以解答问题、推荐解决方案等

登录插画

登录以查看您的控制台资源

管理云资源
状态一览
快捷访问