cnn常用參數記錄


1. epoch

在代碼中經常見到n_epochs這個參數,該參數到底是什么意思呢?答案如下:

在一個epoch中,所有訓練集數據使用一次

one  epoch = one forward pass and one backward pass of  all the training examples

2. batch_size

一般情況下,一個訓練集中會有大量的samples,為了提高訓練速度,會將整個training set分為n_batch組,每組包含batch_size個samples

即:整個數據集samples個數 = batch_size * n_batch

batch size = the number of training examples in one forward/backward pass. The higher the batch size, the more memory space you'll need.

3. iterations

看到iteration和epoch這兩個參數,很是困惑,總是分不清楚它們之間到底什么區別,這兩個參數是完全不同的概念

每次iteration進行的工作為:利用某個batch的samples對model進行訓練

number of iterations = number of passes, each pass using [batch size] number of examples. To be clear, one pass = one forward pass + one backward pass (we do not count the forward pass and backward pass as two different passes)

具體地

# epoch個數
n_epochs = 100
# 樣本總個數
numSamples = 100 000
# 要將樣本分割為n_batch組
n_batch = 10
# 每個batch包含的samples
batch_size = numSamples / n_batch 
# 尅是進行訓練
iterations = 0
for i in range(n_epochs ):
    for j in range (n_batch):
       #利用第j組batch進行training
       train (j) 
       # iterations個數加1
       iterations = iterations  +1            

可見:iterations = epoch * n_batch

即,每個epoch進行n_batch次training,每次training,利用batch_size個samples

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM