自动保留参数

def load_para():
    index = None
    fileName = None
    for root, dirs, files in os.walk("./data/"):
        for file in files:
            if "weights_and_bias" in file:
                _index = int(file.split(' ')[1])
                if index is None:
                    index = _index
                    fileName = file
                else:
                    if _index > index:
                        index = _index
                        fileName = file
    return fileName,index


def save_para(data):
    _,index = load_para()
    np.savetxt("./data/weights_and_bias {} .csv".format(index + 1), data, delimiter=',')

你可能感兴趣的:(自动保留参数)