What is the use of np.expand_dims() and preprocess_input()?

What is the use of np.expand_dims() and preprocess_input()?

Hey @HemantKumar, we need to pass image array as (1,224,224,3) and not as (224,224,3) and hence we need to expand one dimension, so we used np.expand_dims.

We have used preprocess_input() to apply same preprocessing that was applied before the actual model was trained. It may be the case that image array was / 255.0 or not. So preprocess function applies the same preprocessing that was applied for training actual resnet etc model.

Happy Learning :sunny:
Plz mark the doubt as resolved :blush:

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.