load multiple models in Tensorflow

后端 未结 5 1846
北荒
北荒 2021-02-04 09:08

I have written the following convolutional neural network (CNN) class in Tensorflow [I have tried to omit some lines of code for clarity.]

class CNN:
de         


        
5条回答
  •  臣服心动
    2021-02-04 09:46

    One way is to clear your session if you want to train or load multiple models in succession. You can easily do this using

    from keras import backend as K 
    
    # load and use model 1
    
    K.clear_session()
    
    # load and use  model 2
    
    K.clear_session()`
    

    K.clear_session() destroys the current TF graph and creates a new one. Useful to avoid clutter from old models / layers.

提交回复
热议问题