def load_last(self, save_dir):
'''Load last model from dir
'''
def extract_number_of_epochs(filename):
m = re.search('_ne([0-9]+(\.[0-9]+)?)_', filename)
return float(m.group(1))
# Get all the models for this RNN
file = save_dir + self._get_model_filename("*")
file = np.array(glob.glob(file))
if len(file) == 0:
print('No previous model, starting from scratch')
return 0
# Find last model and load it
last_batch = np.amax(np.array(map(extract_number_of_epochs, file)))
last_model = save_dir + self._get_model_filename(last_batch)
print('Starting from model ' + last_model)
self.load(last_model)
return last_batch
mf_base.py 文件源码
python
阅读 31
收藏 0
点赞 0
评论 0
评论列表
文章目录