示例#1
0
def plot1(name, xlist, ylist):
    pylab.grid(True)
    for i in xrange(len(ylist)):
        plt.plot(xlist, ylist[i], colors[i % len(colors)], marker=markers[i % len(markers)])
    plt.legend(label, loc='center right')
    plt.xlim(xlist[0] / 2, xlist[-1] + xlist[0] / 2)
    plt.xlabel('Node Set Percentage')
    plt.ylabel('Locality Percentage')
    plt.title('{}: step={}'.format(name, len(xlist)))
    fname = name + '_exp1.png'
    plt.savefig(utils.get_result_fname(fname))
    plt.clf()
示例#2
0
def plot2(name, labels, xlist, ylist):
    pylab.grid(True)
    for i in xrange(len(ylist)):
        plt.plot(xlist, ylist[i], colors[i % len(colors)], marker=markers[i % len(markers)])

    plt.legend(labels, loc='center right')
    plt.xlim(xlist[0] / 2, xlist[-1] + xlist[0] / 2)
    plt.xlabel('Number of Parts')
    plt.ylabel('Locality Percentage')
    plt.title('{}: Average Localities for different Parts'.format(name))
    fname = name + '_exp2.png'
    plt.savefig(utils.get_result_fname(fname))
    plt.clf()
示例#3
0
def plot1_bar(name, xlist, ylist):
    pylab.grid(True)
    width = 0.15
    ind = np.arange(len(xlist))
    fig, ax = plt.subplots()
    for i in xrange(len(ylist)):
        ax.bar(ind + i * width, ylist[i], width, color=colors[i % 3])
    ax.set_xticks(ind + width)
    ax.set_xticklabels(xlist)
    ax.legend(label, loc='center')
    plt.title('{}: step={}'.format(name, len(xlist)))
    fname = name + '_exp1_bar.png'
    plt.savefig(utils.get_result_fname(fname))
    plt.clf()
示例#4
0
def plot2_random_partition(name, xlist, ylist):
    yy = []
    for x, y in zip(xlist, ylist):
        yy.append(x * y)
    plt.plot(xlist, yy)
    plt.xlabel(r'$\textsf{num}$')
    plt.ylabel(r'$\textsf{l}*\textsf{num}$')
    plt.title('{}: Random Partition Locality'.format(name))
    plt.legend(['Parts*Locality'], loc='best')
    plt.ylim([0.5, 1.5])
    pylab.grid(True)
    fname = name + '_exp2_rnd.png'
    plt.savefig(utils.get_result_fname(fname))
    plt.clf()
示例#5
0
    train_dl, val_dl = load_data(config.dataset,
                                 config.batch_size,
                                 num_workers=0)
    print(config.key2val, config.max_epochs)
    # Train model
    trainer = pl.Trainer(max_epochs=config.max_epochs,
                         logger=logger,
                         gpus=utils.get_n_gpus())
    trainer.fit(fodvae, train_dl, val_dl)
    fodvae_best_version = fodvae

    # Save best version
    save_path = str(MODELS_DIR / model_fname(config))
    torch.save(fodvae_best_version.state_dict(), save_path)

    return evaluate(config, fodvae_best_version, logger, return_results)


if __name__ == "__main__":
    args = parse_args()
    config = utils.Config(args)
    return_results = config.experiment == "ablative"
    results = main(config, return_results=return_results)
    print(results)
    if return_results:
        with open(RESULTS_DIR / utils.get_result_fname(config), "w") as f:
            f.write(json.dumps(results, indent=2))
            print(
                f"Written results to {(RESULTS_DIR / utils.get_result_fname(args)).relative_to(PROJECT_DIR)}"
            )