How to load trained keras model once and predict on individual input multiple times?
874 views
Skip to first unread message
search...@gmail.com
unread,
Mar 2, 2017, 9:23:12 AM3/2/17
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Keras-users
Hi,
How to load trained keras model once and predict on individual input across method call?
If for each input to method, I load keras model and weights, it becomes very slow as it takes time to load model.
Please suggest.
Thanks,
Mahesh
jpeg729
unread,
Mar 3, 2017, 12:14:58 PM3/3/17
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Keras-users, search...@gmail.com
Just run
prediction = model.predict(input)
for each input. No need to reload the model each time.
search...@gmail.com
unread,
Mar 6, 2017, 11:47:22 PM3/6/17
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Keras-users, search...@gmail.com
Hi,
Thanks for reply.
My problem is I am doing this in Python method. for every new input I am calling this method where I have to load the model.
I might be needing some global variables to save keras model and reuse that.
I am new to python.
Please suggest.
Thanks,
Mahesh
tempd...@gmail.com
unread,
Sep 28, 2018, 12:53:53 AM9/28/18
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Keras-users
Hi,
You can write a function with parameters or define a class. The class includes a keras model as its member. So an instance of the class will keep the model and no need to reload it every time.