-
Notifications
You must be signed in to change notification settings - Fork 19.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
what's model._make_predict_function() used for? #6124
Comments
Using theano or tensorflow is a two step process: build and compile the function on the GPU, then run it as necessary. make predict function performs that first step. Keras builds the GPU function the first time you call predict(). That way, if you never call predict, you save some time and resources. However, the first time you call predict is slightly slower than every other time. This isn't safe if you're calling predict from several threads, so you need to build the function ahead of time. That line gets everything ready to run on the GPU ahead of time. Cheers |
The problem is there is zero documentation on this issue. |
@jaara you're not wrong about that. Maybe some comments on that function would be nice. As a bigger problem, there are a lot of issues related to the whole compilation/execution division. Issues like "get_updates is only called once, what is going on?" or "why is call only called once?" or "can't use numpy in custom layer". The whole idea of creating the function and then calling the function throws a lot of people for a loop. Just check out the issue log. Not sure the best way to clear up the confusion but it is definitely a common problem. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 30 days if no further activity occurs, but feel free to re-open a closed issue if needed. |
Running on 1-gpu machine, adding lr = self.lr
if self.initial_decay > 0:
lr *= (1. / (1. + self.decay * self.iterations))
self.updates .append(K.update_add(self.iterations, 3))
lr = tf.Print(lr, [lr], message="This is SGD lr: ") # print lr on every call |
isn't _make_predict_function() deprecated? i couldn't find it in the official Keras documentation any more... |
+1 |
+1 |
@bstriner Hi
I wanna know why that's not save. this answer in stack_overflow also mentioned:
However, I can not really understand it. Could you please help? |
Discussions on why it isn't recommended to call: * keras-team/keras#6124 * keras-team/keras#13116
I have some problem using Keras model for prediction in parallel, details described here. Today I read some code from jaara/AI-blog/CartPole-A3C.py and found this:
I think this is what makes difference. So can anyone tells me how this function works? I can't find any documentation about it.
edit:
I put the same issue here and got an reply. But I want more information from the Keras Community.
The text was updated successfully, but these errors were encountered: