2
$\begingroup$

tl;dr I'm trying to train a small CNN (two conv layers and two connected layers) to find humans in the COCO dataset. Is my network big enough, and if so, roughly how many epochs of training will it need (there are 64115 training images)?

I am trying to make a neural network that can draw bounding boxes around humans in an image.

I initially intended to use YOLO, since it already exists and does exactly what I want. However, I found that it took many seconds to do a single forward pass through the YOLO network, which is far too slow for my purposes. Since my task is much simpler (YOLO can distinguish between many object classes, whereas I'm only interested in humans), and I don't need as much accuracy, I decided to make a smaller CNN in the style of YOLO, but with far fewer layers and parameters.

I have made a CNN with two convolutional layers and two fully connected layers, which can do a forward pass in a fraction of a second, and I am training it on the images from the COCO dataset that contain humans. My problem now is that, since the network is so small, I have no idea whether it can actually perform the task, and I don't know how long to train it before trying a bigger architecture. I'm also concerned that, since I'm on an ordinary laptop, it might take months or even years for enough training to take place.

If anyone could tell me what the minimum network size is for this sort of task, and how many epochs of training are usually required, it would be much appreciated. Alternatively, if I've made a wrong assumption (i.e. maybe I'm using the pretrained networks wrong for them to be so slow), it would be very helpful if someone could point that out.

$\endgroup$
3
  • 1
    $\begingroup$ The questions asked (network architecture, epochs, ..) are answerable only in a trial and error manner, espeially for deep models. There is no theoretical hard limit answer, if that is what you are after. $\endgroup$
    – Nikos M.
    Commented Jun 19, 2021 at 12:27
  • 1
    $\begingroup$ @NikosM. I know that there isn't much theory about this, but I'd have thought that an experienced practitioner might be able to give a rough order of magnitude estimate. Is that not the case? $\endgroup$
    – Qwertiops
    Commented Jun 19, 2021 at 12:29
  • 1
    $\begingroup$ It is the case if someone has tackled the exact same problem with same dataset and same models. Then experience can provide guidelines $\endgroup$
    – Nikos M.
    Commented Jun 19, 2021 at 12:31

1 Answer 1

2
$\begingroup$

As rightly said by @Nikos M., it is based on trial and error. And here are some tips you might find useful -

  1. Create a good enough validation set.
  2. Use YOLO-tiny versions instead of custom architecture.
  3. Use Google Colab

how many epochs of training will it need

Your data is very large. Training time depends on batch_siz, learning_rate, and other hyperparameters. So I will suggest run your training loop according to steps (one step = one backprop). Start running the training for a large number of steps (or infinite steps). But, test your model on Val set after every 100-200 steps (according to your speed) and check your model's accuracy. If the model gets you sufficient accuracy after 2000 steps only, then interrupt the training. Make sure to save the checkpoints after a certain number of steps.

I initially intended to use YOLO

I am assuming that you are using YOLO from 2016. There are many versions of YOLO after that, and mainly I will suggest you should try YOLO-tiny models. You will find these tiny models for each version for YOLO (v3,v4,v5). And these models are superfast and super tiny. One more advantage of using these pre-trained models will be that they are pre-trained! You will save a lot of training time if at all needed.

since I'm on an ordinary laptop

Use google colab for free high-end GPUs. And if getting your data in google drive is an issue then try resizing your images to the standard input size of your network (like 448x448) which will drastically reduce the dataset size. If that doesn't shrink the dataset size by a lot, try training on a part of your dataset, and try getting good accuracy on Val set. I feel that 60K is a very huge dataset already and I have trained models with very good accuracy using 3K-5K images max. (but again I have not seen your task and your images).

$\endgroup$
1
  • 2
    $\begingroup$ Thank you! Very helpful answer $\endgroup$
    – Qwertiops
    Commented Jun 19, 2021 at 16:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.