目录
一、三个术语定义讲解
# Training cycle
for epoch in range(training_epoch):
# Loop over all batches
for i in range(total_batch):
1. 为了减少内存的使用,不一次性将所有训练数据喂给模型,而是分批次输入模型,也就是batch,一次性输入模型的数据量就是batch_size。batch_size=64,32均可。
Definition of Batch_size:The number of training examples in one forward backward pass.
2. 完成一个batch的训练就是Iterations,即完成了一次迭代。
Definition of Iterations: Number of passes, each pass using [batch_size] number of examples.
3. 完成一次全部数据训练,即为完成一个Epoch。全部数据的训练轮次为epoch,训练10轮就是10个epoch。
Definition of Epoch: One forward pass and one backward pass of all the training example.
二、数据加载
为了提高模型的泛化能力,在数据加载(DataLoader)的时候,通常将数据集中的数据进行随机打乱,即shuffle。
如下所示的例子,batch_size = 2,shuffle = True。