jaromiru/AI-blog

what is model._make_predict_function() used for?

leckie-chn opened this issue · 2 comments

I am also working on multi-thread prediction on RL model. I've been stuck on this issue for about a week until I saw this line of your code:

model._make_predict_function()	# have to initialize before threading

So can you tell me what does this function do and why we need to add this line of code? I can't find any documentation about this.

Hi,

_make_predict_function() is called only after a call to predict(). I believe this is a flaw in Keras design - this code is not synchronous and not thread ready. Thats why I need to call this function before threading.

It goes in conjunction with:
self.default_graph.finalize() # avoid modifications

I don't want to modify the model when running the computation.

Thank you! I put the same issue on Keras Github Repo here