-

Monday 29 January 2018

Tips and Tricks for Keras Beginners.

How to save trained model in Keras?
Ans: the model can be easily saved just by following the line of the code in keras.
model.save('file_name.h5')  

How to load pretrained model in Keras?
Ans:
from keras.models import load_model  
model = load_model('file_name.h5')  

How to change backend in Keras?
Ans:
If you want to change the backend in Keras, open .json file in .keras folder. Then change backend from theano-->tensorflow-->cntk.

 {  
   "image_data_format": "channels_last",  
   "epsilon": 1e-07,  
   "floatx": "float32",  
   "backend": "tensorflow"  
 }  

How to limit your GPU usage per user account in Keras?
Ans:
For the tensorflow backend, we can limit GPU memory usage by including the following lines at the starting of the code. If you have 12GB GPU memory following lines can limit to 4GB.
import tensorflow as tf  
from keras.backend.tensorflow_backend import set_session  
config = tf.ConfigProto()  
config.gpu_options.per_process_gpu_memory_fraction = 0.3  
set_session(tf.Session(config=config))  

How to use early stopping?

How to save training performance for every epoch in Keras?

1 comment:

  1. Such a very useful information!Thanks for sharing this useful information with us. Really great effort.
    artificial intelligence course in noida

    ReplyDelete