Exemple #1
0
if __name__ == "__main__":

    if not os.path.exists('./results'):
        os.makedirs('./results')

    print("Train LPMC_DC_L with LS-ABS and hybrid-inv")

    model = LPMC_DC(data_folder, file='12_13_14.csv')

    ioa = OptAlg(alg_type='LS-ABS', direction='hybrid-inv')

    res = {'time': [], 'LL': [], 'epochs': []}

    for i in range(20):

        tmp = model.optimize(
            ioa, **{
                'verbose': False,
                'max_epochs': 1000,
                'batch': 1000
            })

        res['time'].append(tmp['opti_time'])
        res['LL'].append(tmp['fun'])
        res['epochs'].append(tmp['nep'])

        with open('results/LS-ABS_hybrid-inv.json', 'w') as outfile:
            json.dump(res, outfile)

        print("{}/20 done!".format(i + 1))
Exemple #2
0
    param_ph = [0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]

    res['perc_hybrid'] = {}

    for ph in param_ph:

        tmp_res = {'time': [], 'LL': [], 'epochs': []}

        print("  Value: {}".format(ph))

        main_params['perc_hybrid'] = ph

        for i in range(draws):

            print(main_params)

            tmp = model.optimize(ioa, **main_params)

            tmp_res['time'].append(tmp['opti_time'])
            tmp_res['LL'].append(tmp['fun'])
            tmp_res['epochs'].append(tmp['nep'])

            res['perc_hybrid'][ph] = tmp_res

            with open('results/DC_hybrid.json', 'w') as outfile:
                json.dump(res, outfile)

            print("{}/{} done!".format(i + 1, draws))
        print("")