Difference between steps and num_epochs

348 Views Asked by At

I don't understand the need of using steps and num_epochs in any kind of ML code.

Some programs include both variables simultaneously.

Can anyone help me out?

2

There are 2 best solutions below

1
On BEST ANSWER

Let's say you got a data of size 1000, num_epoch is 10 and step is 200. At each epoch, the program is going to process each steps. Thus epoch 1 -> 200..400..600..800..1000, epoch 2 -> 200..400..600..800..1000 and so on for each epoch.

0
On

From what I know and understand,

During the training phase of a Machine Learning (ML) model, your goal is usually to minimise a cost function. In supervised learning, you feed data to your model and compare the output with the labels. Then, you take a 'step' toward the minimum of the cost function. That is, you compute some form of gradient and adjust your model's weights accordingly.

Now, this process can be done in different ways. For example, when it comes to Gradient Descent, you can do Batch Gradient Descent, Stochastic Gradient Descent, or Mini-Batch Gradient Descent. When doing Batch Gradient Descent, you will feed all the examples, compute the gradient, and then take a step, repeating this process step times. However, in Stochastic Gradient Descent, you will only feed one example, compute the gradient, take a step, repeat the process step times and then start again 'n_epochs' times (shuffling the data before each epoch).

So step refers to the number of steps you take and n_epoch refers the number of times you go over your data. Some algorithms will go over the data (or part of it) many times and this is why you will need two variables: step and n_epochs.