Skip to Content
深度學習|內行人的做法
book

深度學習|內行人的做法

by Josh Patterson, Adam Gibson
January 2019
Beginner to intermediate
576 pages
14h 31m
Chinese
GoTop Information, Inc.
Content preview from 深度學習|內行人的做法
小批量數量與訓練階段的控制
|
297
隨著小批量數量的增加,更多的計算可能會讓梯度變得更平滑,但計算成
本也會變得更高。
理想情況下,訓練組資料的每一小批量資料中都應該包含每一種類別的樣本,以便在估
算整個訓練組資料的梯度時,能夠降低取樣的誤差。
瞭解小批量數量的權衡取捨考量
原則上(只要經過適當調整),神經網路採用任何小批量數量都可以進行學習。而在實
務上來說,我們還是需要選擇一個適當的小批量數量,來平衡以下幾個東西:
• 記憶體要求
• 計算效率
• 最佳化效率
記憶體方面的要求,已在前面的章節討論過,所以我們並不打算再次說明。
關於
計算效率
的方面,DL4J(以及其他現代深度學習函式庫)會在數學運算(例如矩
陣乘法與向量運算,像是向量相加、逐個元素相乘等)的層面上,以平行運算的方式來
處理學習。這也就表示,小批量的大小如果太小,就會導致硬體(尤其是 GPU)的利用
效率較差,而小批量數量太大的話,也會導致效率低下
—
因為我們會對小批量資料中
所有樣本的梯度進行平均,這也就表示終究會增加更多梯度的計算成本,最後超過所得
到的好處。
為了
提高表現
(在使用 GPU 的情況下這是最重要的事),小批量數量(
https://svail.
github.io/rnn_perf/
)應該盡可能使用 32 的倍數;如果不能使用 32 的倍數(或為了滿足
其他要求而不能變化太大),也可以考慮使用 16、8、4 或 2 的倍數。簡而言之,其原因
很簡單:記憶體存取與硬體的設計,對於陣列大小為 2 的倍數來說,其操作的最佳化效
果會比其他大小好一點。 ...
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

精實企業|高績效組織如何達成創新規模化

精實企業|高績效組織如何達成創新規模化

Jez Humble, Joanne Molesky, Barry O'Reilly
机器学习和AI精粹

机器学习和AI精粹

诺亚·吉夫特
初探深度學習|使用TensorFlow

初探深度學習|使用TensorFlow

Reza Zadeh, Bharath Ramsundar

Publisher Resources

ISBN: 9789865020262