且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Keras模型的predict和predict_on_batch方法之间有什么区别?

更新时间:2023-12-02 15:01:28

不同之处在于,当您以大于一批的数据作为x数据进行传递时.

The difference lies in when you pass as x data that is larger than one batch.

predict 将通过所有数据,逐批,用于预测标签. 因此,它在内部分批进行分批处理,并且一次进给一批.

predict will go through all the data, batch by batch, predicting labels. It thus internally does the splitting in batches and feeding one batch at a time.

predict_on_batch ,在另一方面,假设您传入的数据恰好是一批,因此将其馈送到网络.它不会尝试拆分它(如果阵列很大,则取决于您的设置,这可能会给您的GPU内存带来问题)

predict_on_batch, on the other hand, assumes that the data you pass in is exactly one batch and thus feeds it to the network. It won't try to split it (which, depending on your setup, might prove problematic for your GPU memory if the array is very big)