# How do I get multiple loss per sample in keras evaluate?

Usually, when I evaluate() a model, I would get a single loss that is already averaged over all samples. How do I get the loss per each sample and return all of them?

E.g. if my dataset has 100 samples, I want to get 100 losses, for each of the sample instead of 1 averaged loss.

You cannot achieve that from a single model.evaluate(...) call. But you could always do evals = [model.eval(X[i:i+1], Y[i:i+1]) for i in range(len(X))].
Note if you get the tensors yourself, you can get the backend session from keras.backend.get_session() and get anything you want by making your own sess.run() calls
• @off99555 using the .evaluate method sure, but thats because of how it's interfaced to return aggregates. On the other hand, using the sess method or using .predict and computing the metrics on your own will still let you batchify it (in other words parallelize), you just can't if your forcing .evaluate as OP asked about. – mshlis Dec 19 '19 at 8:47