Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How many images per iteration in Detectron2

I am new to using detectron2, just learning it.This might be a noob question, but I really need the answer. I find nothing related to number of epochs in the repository.

We know , epoch means single passing of all data through the model, and a batch means a certain subset of the whole dataset, that has the ability to impact the loss through gradient descent. In this model, (Detectron2) we have something called iteration. What does this iteration mean? Does it mean passing of one batch through the mode, or an epoch(that shouldn't be the case considering time per iteration)

My question is , how do I know the minimum number of iterations that will pass all my images to the model, at least once.

like image 900
Sawradip Saha Avatar asked Aug 25 '20 11:08

Sawradip Saha


2 Answers

In detectron2, epoch is MAX_ITER * BATCH_SIZE / TOTAL_NUM_IMAGES

like image 69
CognitiveRobot Avatar answered Sep 18 '22 11:09

CognitiveRobot


I don't think the currently accepted answer is correct

single_iteration = cfg.SOLVER.NUM_GPUS * cfg.SOLVER.IMS_PER_BATCH

therefore, if you want to now how many iterations you need for an epoch (all images seen once), that number would be

iterations_for_one_epoch = TOTAL_NUM_IMAGES / single_iteration

So if you want to train for 20 epochs, you would set MAX_ITER as follows:

cfg.SOLVER.MAX_ITER = iterations_for_one_epoch * 20

Sources:

Detectron2 Docs (one iteration is one run_step-call, and that pulls one "datapoint" from the loader data = next(self._data_loader_iter))

MaskRCNN-benchmark Github issue explains it in a similar way

like image 35
TobiasWeis Avatar answered Sep 20 '22 11:09

TobiasWeis