点击上方“程序员爱码士”,选择“星标”公众号
重磅干货,第一时间送达

入门深度学习,最重要的就是找一份通俗易懂的书籍!今天给大家推荐一套口碑上佳的中文版深度学习书,名叫《神经网络与深度学习》,由复旦大学老师邱锡鹏出品。

这本《神经网络与深度学习》全中文版,大大降低了深度学习的语言门槛,让大家有更多的精力放在核心知识内容的学习上。内容上,它面向深度学习小白,从人工智能的基本概念开始讲起,可以说很友好了。此外,各种附加资料一站式配齐:从教材、讲解PPT、示例代码到课后练习,全方位无死角学习。
这本书的作者邱锡鹏老师,目前是复旦大学计算机科学技术学院的博士生导师、自然语言处理与深度学习组的副教授。
重要内容:
这本书目前已经更新完,共包含了 16 章内容,从机器学习概论开始,涵盖多种基础神经网络模型的基础知识。课程目录如下:
绪论
机器学习概述
线性模型
前馈神经网络
卷积神经网络
循环神经网络
网络优化与正则化
注意力机制与外部记忆
无监督学习
模型独立的学习方式
概率图模型
深度信念网络
深度生成模型
深度强化学习
序列生成模型
数学基础
附录 A:线性代数
附录 B:微积分
附录 C:数学优化
附录 D:概率论
附录 E:信息熵
本书特色:
《神经网络与深度学习》是邱锡鹏老师倾力打造的,其课件 PPT 包含了非常多的图解释。
例如,关于正则化的通俗解释:

模型的选择,方差与偏差:

激活函数:

除了课程内容之外,每一张还包含大量的课程练习,作者大都提供了最热门的 PyTorch 和 TensorFlow 两种框架的实现方式。
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)
传送门:
课程主页:
https://nndl.github.io/
PDF 讲义:
https://nndl.github.io/nndl-book.pdf
课件 PDF:
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/exercise
资源下载:
《神经网络与深度学习》电子版 PDF 已经打包好,获取步骤如下:
1. 扫描下方二维码关注 "程序员爱码士" 公众号
2. 公众号后台回复关键词:NNDL