Skip to Content
深度学习入门 : 基于Python的理论与实现
book

深度学习入门 : 基于Python的理论与实现

by 斋藤康毅
July 2018
Intermediate to advanced
310 pages
8h 21m
Chinese
Posts & Telecom Press
Content preview from 深度学习入门 : 基于Python的理论与实现
5.7  误差反向传播法的实现 
159
t_batch = t_train[:3]
grad_numerical = network.numerical_gradient(x_batch, t_batch)
grad_backprop = network.gradient(x_batch, t_batch)
#
求各个权重的绝对误差的平均值
for key in grad_numerical.keys():
diff = np.average( np.abs(grad_backprop[key] - grad_numerical[key]) )
print(key + ":" + str(diff))
和以前一样,读入
MNIST
数据集。然后,使用训练数据的一部分,确
认数值微分求出的梯度和误差反向传播法求出的梯度的误差。这里误差的计
算方法是求各个权重参数中对应元素的差的绝对值,并计算其平均值。运行
上面的代码后,会输出如下结果。
b1:9.70418809871e-13
W2:8.41139039497e-13
b2:1.1945999745e-10
W1:2.2232446644e-13
从这个结果可以看出,通过数值微分和误差反向传播法求出的梯度的差
非常小。比如,第 1 层的偏置的误差是
9.7e-13
0.00000000000097
)。这样一来,
我们就知道了通过误差反向传播法求出的梯度是正确的,误差反向传播法的
实现没有错误。
数值微分和误差反向传播法的计算结果之间的误差为0 是很少见的。
这是因为计算机的计算精度有限 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

ルールズ・オブ・プログラミング ―より良いコードを書くための21のルール

ルールズ・オブ・プログラミング ―より良いコードを書くための21のルール

Chris Zimmerman, 久富木 隆一

Publisher Resources

ISBN: 9787115485588