Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I stop Keras from printing after calling model.predict

I am training a keras sequential model and now wish to predict a value. I run the following single line

agent.model.predict(np.array([0,0,0,0]).reshape(1,4))

and get the following output displayed in my notebook

1/1 [==============================] - 0s 29ms/step
array([[0.00760011, 0.01811639]], dtype=float32)

How do I stop Keras from showing the first line in the output?

like image 591
tomammm Avatar asked Sep 12 '25 07:09

tomammm


1 Answers

As mentioned by Gerry P, to prevent Keras from printing the output of model.predict(), set the verbose argument to 0 as follows:

agent.model.predict(np.array([0,0,0,0]).reshape(1,4),verbose = 0)

Reference: Keras documentarion.

like image 68
3 revs, 2 users 55%user11530462 Avatar answered Sep 14 '25 19:09

3 revs, 2 users 55%user11530462