Confusion about keras Model: __call__ vs. call vs. predict methods

Adding to @Dmitry Kabanov, they are similar yet they aren’t exactly the same thing. If you care about performance, need to look in to critical differences between them.

model.predict model(x)
loops over the data in batches which means means that predict() calls can scale to very large arrays. happens in-memory and doesn’t scale
not differentiable differentiable
use this if you just need the output value use this when you need to retrieve the gradients
Output is NumPy value Output is a Tensor
use this if you have batches of data to be predicted use this for small dataset
relatively slower for small data relatively faster for small data

Please check more detailed explanation in Keras FAQs

Leave a Comment