During the process of training the model, there are different ways to use the dataset:

total dataset is splitted into many tiny parts named mini-batch:
num_batch=total_sample / batch_size
for epoch:  # here one epoch means the entire dataset
for num_batch:
batch = dataset[…num_betch…]
training…
2.sample randomly as a batch:
for epoch: # here one epoch means a batch sampled randomly
batch = random_sample(batch_size)
training…

What the difference between the aforementioned ways?