AI/tensorflow

[keras] predict_on_batch 와 predict의 차이 ?

교 향 2023. 2. 1. 11:03

What is the difference between the predict and predict_on_batch methods of a Keras model?

 

What is the difference between the predict and predict_on_batch methods of a Keras model?

According to the keras documentation: predict_on_batch(self, x) Returns predictions for a single batch of samples. However, there does not seem to be any difference with the standard predict method

stackoverflow.com

 

predict와 predict_on_batch는 기능적 차이는 크게 없고

predict에 추가적 동작(배치 컬렉션이 제대로 동작하는지 확인하는??)이 부과되어 있는 듯 했음

 

predict는 모든 데이터를 배치by배치로 예측 수행 (네트워크에 매번 배치단위로 데이터를 넣음)

predict_on_batch는 정확히 하나의 배치로 데이터를 가정하고 네트워크로 넣음

predict_on_batch가 predict보다 속도면에서도 빠른 모습.

 

그래서 내가 테스트 해보고 싶은 데이터단을 정확히 하나의 배치로 두고

predict할 것이라면 predict_on_batch를 사용하는 편이 좋을 듯?