<gh_stars>1-10
import numpy as np
import glob
import os


def makefolder(folder):
    '''
    Helper function to make a new folder if doesn't exist
    :param folder: path to new folder
    :return: True if folder created, False if folder already exists
    '''

    if not os.path.exists(folder):
        os.makedirs(folder)
        return True
    return False

def get_latest_model_checkpoint_path(folder, name):
    '''
    Returns the checkpoint with the highest iteration number with a given name
    :param folder: Folder where the checkpoints are saved
    :param name: Name under which you saved the model
    :return: The path to the checkpoint with the latest iteration
    '''

    iteration_nums = []
    for f in glob.glob(os.path.join(folder, '{}*.meta'.format(name))):

        f = f.split('/')[-1]
        file_base, postfix_and_number, rest = f.split('.')[0:3]
        it_num = int(postfix_and_number.split('-')[-1])

        iteration_nums.append(it_num)

    latest_iteration = np.max(iteration_nums)

    return os.path.join(folder, name + '-' + str(latest_iteration))

import numpy as np
import glob
import os


def makefolder(folder):
    '''
    Helper function to make a new folder if doesn't exist
    :param folder: path to new folder
    :return: True if folder created, False if folder already exists
    '''

    if not os.path.exists(folder):
        os.makedirs(folder)
        return True
    return False

def get_latest_model_checkpoint_path(folder, name):
    '''
    Returns the checkpoint with the highest iteration number with a given name
    :param folder: Folder where the checkpoints are saved
    :param name: Name under which you saved the model
    :return: The path to the checkpoint with the latest iteration
    '''

    iteration_nums = []
    for f in glob.glob(os.path.join(folder, '{}*.meta'.format(name))):

        f = f.split('/')[-1]
        file_base, postfix_and_number, rest = f.split('.')[0:3]
        it_num = int(postfix_and_number.split('-')[-1])

        iteration_nums.append(it_num)

    latest_iteration = np.max(iteration_nums)

    return os.path.join(folder, name + '-' + str(latest_iteration))
Helper function to make a new folder if doesn't exist     :param folder: path to new folder     :return: True if folder created, False if folder already exists Returns the checkpoint with the highest iteration number with a given name     :param folder: Folder where the checkpoints are saved     :param name: Name under which you saved the model     :return: The path to the checkpoint with the latest iteration