May 2025
Beginner to intermediate
252 pages
3h 16m
Chinese
本作品已使用人工智能进行翻译。欢迎您提供反馈和意见:translation-feedback@oreilly.com
如果你试图了解神经网络和 Deep Learning,你可能会遇到大量的资源,从博文到质量参差不齐的 MOOC(大规模开放在线课程,如 Coursera 和 Udacity 上提供的课程),甚至还有一些书籍--我知道我几年前开始探索这个主题时就是这样。不过,如果你正在阅读这篇序言,很可能你所接触到的每一种对神经网络的解释都存在某些欠缺。我在开始学习时也发现了同样的问题:各种解释就像盲人在描述大象的不同部分,却没有一个能描述出整体。这就是我写这本书的初衷。
这些关于神经网络的现有资源大多分为两类。有些是概念性和数学性的,既有神经网络解释中常见的图画,即由两端带箭头的线连接的圆,也有大量的数学解释,让你可以 "理解理论"。伊恩-古德费洛(Ian Goodfellow)等人撰写的《深度学习》(Deep Learning)一书(麻省理工学院出版社)就是一个典型的例子。
其他资源有密集的代码块,如果运行这些代码块,似乎会显示损失值随着时间的推移而减少,从而显示神经网络在 "学习"。例如,PyTorch 文档中的以下示例确实在随机生成的数据上定义并训练了一个简单的神经网络:
# N is batch size; D_in is input dimension;# H is hidden dimension; D_out is output dimension.N,D_in,H,D_out=64,1000,100,10# Create random input and output datax=torch.randn(N,D_in,device=device,dtype=dtype)y=torch.randn(N,D_out,device=device,dtype=dtype)# Randomly initialize weightsw1=torch.randn(D_in,H,device=device,dtype=dtype)w2=torch.randn(H,D_out,device=device,dtype=dtype)learning_rate=1e-6fortinrange(500):# Forward pass: compute predicted yh=x.mm(w1)h_relu=h.clamp(min=0)y_pred=h_relu.mm(w2)# Compute and print lossloss=(y_pred-y).pow(2).sum().item()(t,loss)# Backprop to compute gradients of w1 and w2 with respect to lossgrad_y_pred=2.0*(y_pred-y)grad_w2=h_relu.t().mm(grad_y_pred)grad_h_relu=grad_y_pred.mm(w2.t())grad_h=grad_h_relu.clone()grad_h[h<0]=0grad_w1=x.t().mm(grad_h)# Update weights using gradient descentw1-=learning_rate*grad_w1 ...