Image inference takes lot of time on first few layers

Hi everyone. I have taken a pre trained resnet model. I created a new model with the first few layers(and i also transferred the weights of the first common layers), somewhere around half of the original pre trained model. When I pass an image as an input, the time the new custom model takes to process the image for its layers is more than the whole of resnet takes to process. Is there something wrong ? A smilar thing is hapening when I use alexnet pre trained. I created a new model which comtains only the ‘features’ part of the original alexnet model. The time my new model takes is highly large than the ful alexnet model takes to process… Please help me :slight_smile:

Its normal for the first few layers to dominate the time, since the image is really large at the start, hasnt gone through any maxpooling layers yet.

if you can find a solution to this, I guess this is paper-worthy :slight_smile:

But even the last layers take more time than the full model itself if done separately…

Oh, I see. Well, that could be explainable by the time it takes to copy data to and from the gpu. But I have trouble visualizing how you’re rewriting the layers to cause such a copy? Perhaps you can paste a short representative working example of how such code looks?