utils.py 文件源码

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

项目:midi-rnn 作者: brannondorsey 项目源码 文件源码
def load_model_from_checkpoint(model_dir):

    '''Loads the best performing model from checkpoint_dir'''
    with open(os.path.join(model_dir, 'model.json'), 'r') as f:
        model = model_from_json(f.read())

    epoch = 0
    newest_checkpoint = max(glob.iglob(model_dir + 
                            '/checkpoints/*.hdf5'), 
                            key=os.path.getctime)

    if newest_checkpoint: 
       epoch = int(newest_checkpoint[-22:-19])
       model.load_weights(newest_checkpoint)

    return model, epoch
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号