utils.py 文件源码

python
阅读 22 收藏 0 点赞 0 评论 0

项目:mpi_learn 作者: duanders 项目源码 文件源码
def load_model(filename=None, json_str=None, weights_file=None, custom_objects={}):
    """Loads model architecture from JSON and instantiates the model.
        filename: path to JSON file specifying model architecture
        json_str: (or) a json string specifying the model architecture
        weights_file: path to HDF5 file containing model weights
    custom_objects: A Dictionary of custom classes used in the model keyed by name"""
    import_keras()
    from keras.models import model_from_json
    if filename != None:
        with open( filename ) as arch_f:
            json_str = arch_f.readline()
    model = model_from_json( json_str, custom_objects=custom_objects) 
    if weights_file is not None:
        model.load_weights( weights_file )
    return model
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号