Why does prediction require a batch size in Keras?

Keras uses predict_classes() to predict data:

classes = model.predict_classes(X_test, batch_size=32)

I know the use of batch_size in training, but why does he need batch_size for prediction? how it works?

+7
classification neural-network keras
source share
1 answer

Keras can simultaneously predict multiple values, for example, if you enter a vector of 100 elements, Keras can calculate one prediction for each element, providing 100 outputs. This calculation can also be performed in batches defined by the batch_size parameter.

This is just in case when you cannot fit all the data into the CPU / GPU RAM at the same time, and batch processing is required.

+10
source share

All Articles