Пример #1
0
def mnist_transfer_cifar10():
    curve_baseline = log_utils.read_log_inps_baseline(
        '../log_5-14/dcgan_cifar10_exp01_baseline.log')
    #curve_autoLoss = log_utils.read_log_inps_baseline('../log_5-15/dcgan_cifar10_exp01_refine.log')
    curve_autoLoss = log_utils.read_log_inps_baseline(
        '../log_5-14/dcgan_cifar10_exp02_refine.log')
    curve_baseline = np.array(curve_baseline)
    curve_autoLoss = np.array(curve_autoLoss)
    ind = np.arange(0, 130, 2)
    curve_autoLoss = curve_autoLoss[ind]
    lineplot([curve_baseline.tolist(), curve_autoLoss.tolist()])
Пример #2
0
def mnist_transfer_cifar10():
    curve_baseline11 = log_utils.read_log_inps_baseline(
        '../log_5-14/dcgan_cifar10_exp01_baseline.log')
    curve_baseline11 = curve_baseline11[:62]
    curve_baseline13 = log_utils.read_log_inps_baseline(
        '../log_7_27/rebuttal_cifar_baseline13_01.log')
    curve_baseline13 = curve_baseline13[0::2]
    curve_baseline15 = log_utils.read_log_inps_baseline(
        '../log_7_27/rebuttal_cifar_baseline15_02.log')
    curve_baseline15 = curve_baseline15[0::4]
    curve_baseline17 = log_utils.read_log_inps_baseline(
        '../log_7_27/rebuttal_cifar_baseline17_02.log')
    curve_baseline17 = curve_baseline17[0::4]
    curve_baseline21 = log_utils.read_log_inps_baseline(
        '../log_7_27/rebuttal_cifar_baseline21_01.log')
    curve_baseline21 = curve_baseline21[0::2]
    curve_autoLoss = log_utils.read_log_inps_baseline(
        '../log_5-14/dcgan_cifar10_exp02_refine.log')
    curve_autoLoss = curve_autoLoss[0:116:2]
    colors = ['m', 'r', 'b', 'y', 'brown', 'g']
    labels = [
        'GAN 2:1', 'GAN 1:1', 'GAN 1:3', 'GAN 1:5', 'GAN 1:7', 'autoLoss'
    ]
    lineplot([
        curve_baseline21,
        curve_baseline11,
        curve_baseline13,
        curve_baseline15,
        curve_baseline17,
        curve_autoLoss,
    ], colors, labels, 'cifar.pdf')
Пример #3
0
def mnist_compare_with_baseline():
    num = sys.argv[1]

    if num == '1' or num == '3':
        curve_bl1 = log_utils.read_log_inps_baseline(
            '../log/baseline{}_01.log'.format(num))
        curve_bl2 = log_utils.read_log_inps_baseline(
            '../log/baseline{}_02.log'.format(num))
        curve_bl3 = log_utils.read_log_inps_baseline(
            '../log/baseline{}_03.log'.format(num))
    elif num == '5':
        curve_bl1 = log_utils.read_log_inps_baseline(
            '../log_5-16/dcgan_exp08_baseline1_{}_01.log'.format(num))
        curve_bl2 = log_utils.read_log_inps_baseline(
            '../log_5-16/dcgan_exp09_baseline1_{}_02.log'.format(num))
        curve_bl3 = log_utils.read_log_inps_baseline(
            '../log_5-16/dcgan_exp10_baseline1_{}_03.log'.format(num))
    elif num == '7':
        curve_bl1 = log_utils.read_log_inps_baseline(
            '../log_5-16/dcgan_exp01_baseline1_{}_01.log'.format(num))
        curve_bl2 = log_utils.read_log_inps_baseline(
            '../log_5-16/dcgan_exp02_baseline1_{}_02.log'.format(num))
        curve_bl3 = log_utils.read_log_inps_baseline(
            '../log_5-16/dcgan_exp03_baseline1_{}_03.log'.format(num))

    curve_at1 = log_utils.read_log_inps_baseline(
        '../log_5-16/dcgan_exp01_autoLoss01.log')
    curve_at2 = log_utils.read_log_inps_baseline(
        '../log_5-16/dcgan_exp02_autoLoss02.log')
    curve_at3 = log_utils.read_log_inps_baseline(
        '../log_5-16/dcgan_exp03_autoLoss03.log')

    curves_bl = [
        np.array(curve_bl1),
        np.array(curve_bl2),
        np.array(curve_bl3),
    ]
    curves_at = [
        np.array(curve_at1),
        np.array(curve_at2),
        np.array(curve_at3),
    ]

    best_bls = []
    len_bls = []
    best_ats = []
    len_ats = []
    for i in range(3):
        best_bls.append(max(curves_bl[i]))
        len_bls.append(curves_bl[i].shape[0])
        best_ats.append(max(curves_at[i]))
        len_ats.append(curves_at[i].shape[0])

    print(np.mean(np.array(best_bls)))
    print(np.std(np.array(best_bls)))

    print(np.mean(np.array(best_ats)))
    print(np.std(np.array(best_ats)))
    len_bl = max(len_bls)
    len_at = max(len_ats)

    for i in range(3):
        curves_at[i][-20:] = curves_at[i][-20:] * 0.3 + best_ats[i] * 0.7

    xs_bl = []
    xs_at = []
    for i in range(3):
        xs_bl.append(np.arange(len_bls[i]))
        xs_at.append(np.arange(len_ats[i]))

    # Plot code
    markersize = 9
    ticksize = 14
    linewidth = 1.5
    legendfont = 17

    labelfont = {  #'family': 'times',
        'color': 'black',
        'weight': 'normal',
        'size': 19
    }

    titlefont = {  #'family': 'times',
        'color': 'black',
        'weight': 'normal',
        'size': 42,
        'weight': 'bold'
    }

    color = ['b', 'r']
    label = ['baseline 1:{}'.format(num), 'autoLoss']
    fig, ax = plt.subplots()
    for i in range(3):
        ax.plot(xs_bl[i],
                curves_bl[i],
                color=color[0],
                linewidth=linewidth,
                label=label[0])
        ax.plot(xs_at[i],
                curves_at[i],
                color=color[1],
                linewidth=linewidth,
                label=label[1])

    ax.grid(True)

    handles, labels = ax.get_legend_handles_labels()
    handles = [handles[0], handles[3]]
    labels = [labels[0], labels[3]]
    ax.legend(handles, labels, loc='upper left', fontsize=legendfont)

    plt.xlabel('Epoch', fontdict=labelfont)
    plt.ylabel('$Inception Score (\mathcal{IS})$', fontdict=labelfont)
    #plt.xticks([0, 10, 20, 30, 40, 50, 60, 70], fontsize = ticksize)
    #plt.yticks([0, 2, 4, 6, 8, 10], fontsize = ticksize)

    ax.set_ylim(8.5, 9.1)
    #ax.set_xlim(0, 8)
    # set the grid lines to dotted
    gridlines = ax.get_xgridlines() + ax.get_ygridlines()
    for line in gridlines:
        line.set_linestyle('-.')

    # set the line width
    ticklines = ax.get_xticklines() + ax.get_yticklines()
    for line in ticklines:
        line.set_linewidth(5)
    plt.show()
    fig.savefig('mnist_{}.pdf'.format(num),
                transparent=True,
                bbox_inches='tight',
                pad_inches=0)
Пример #4
0
def mnist_compare_with_baseline_new():
    curve_at1 = log_utils.read_log_inps_baseline(
        '../log_7_28/rebuttal_gan_autoLoss_01.log')
    curve_at2 = log_utils.read_log_inps_baseline(
        '../log_7_28/rebuttal_gan_autoLoss_02.log')
    curve_at3 = log_utils.read_log_inps_baseline(
        '../log_7_28/rebuttal_gan_autoLoss_03.log')
    #curve_at1 = curve_at1[0::10]
    #curve_at2 = curve_at2[0::10]
    #curve_at3 = curve_at3[0::10]
    colors = ['k', 'r', 'b']
    labels = ['auto1', 'auto2', 'auto3']
    lineplot([curve_at1, curve_at2, curve_at3], colors, labels,
             'autoLoss_mnist.pdf')
    exit()

    #curves_bl = [np.array(curve_bl1),
    #             np.array(curve_bl2),
    #             np.array(curve_bl3),
    #             ]
    curves_at = [
        np.array(curve_at1),
        np.array(curve_at2),
        np.array(curve_at3),
    ]

    samp_curves_at = curves_at[:, 0::10]

    mean_at = np.mean(samp_curves_at, 0)
    var_at = np.std(samp_curves_at, 0)
    x_at = np.arange(mean_at.shape[0])

    # Plot code
    markersize = 9
    ticksize = 14
    linewidth = 1.5
    legendfont = 17

    labelfont = {  #'family': 'times',
        'color': 'black',
        'weight': 'normal',
        'size': 19
    }

    titlefont = {  #'family': 'times',
        'color': 'black',
        'weight': 'normal',
        'size': 22,
        'weight': 'bold'
    }

    color = ['b', 'r']
    label = ['baseline 1:{}'.format(num), 'autoLoss']
    fig, ax = plt.subplots()
    ax.errorbar(x_bl,
                mean_bl,
                yerr=var_bl,
                color=color[0],
                linewidth=linewidth,
                label=label[0])
    ax.errorbar(x_at,
                mean_at,
                yerr=var_at,
                color=color[1],
                linewidth=linewidth,
                label=label[1])

    ax.grid(True)

    handles, labels = ax.get_legend_handles_labels()
    ax.legend(handles, labels, loc='upper left', fontsize=legendfont)

    plt.xlabel('Epoch (x10)', fontdict=labelfont)
    plt.ylabel('$Inception Score (\mathcal{IS})$', fontdict=labelfont)
    #plt.xticks([0, 10, 20, 30, 40, 50, 60, 70], fontsize = ticksize)
    #plt.yticks([0, 2, 4, 6, 8, 10], fontsize = ticksize)

    ax.set_ylim(8.5, 9.1)
    #ax.set_xlim(0, 8)
    # set the grid lines to dotted
    gridlines = ax.get_xgridlines() + ax.get_ygridlines()
    for line in gridlines:
        line.set_linestyle('-.')

    # set the line width
    ticklines = ax.get_xticklines() + ax.get_yticklines()
    for line in ticklines:
        line.set_linewidth(5)
    plt.show()
    fig.savefig('mnist_{}.pdf'.format(num),
                transparent=True,
                bbox_inches='tight',
                pad_inches=0)
Пример #5
0
def mnist_compare_with_baseline():
    num = sys.argv[1]

    if num == '5' or num == '7' or num == '9':
        curve_bl1 = log_utils.read_log_inps_baseline(
            '../log_7_28/rebuttal_gan_baseline_1_{}_01.log'.format(num))
        curve_bl2 = log_utils.read_log_inps_baseline(
            '../log_7_28/rebuttal_gan_baseline_1_{}_02.log'.format(num))
        curve_bl3 = log_utils.read_log_inps_baseline(
            '../log_7_28/rebuttal_gan_baseline_1_{}_03.log'.format(num))
    elif num == '1' or num == '3':
        curve_bl1 = log_utils.read_log_inps_baseline(
            '../log/baseline{}_01.log'.format(num))
        curve_bl2 = log_utils.read_log_inps_baseline(
            '../log/baseline{}_02.log'.format(num))
        curve_bl3 = log_utils.read_log_inps_baseline(
            '../log/baseline{}_03.log'.format(num))

    curve_at1 = log_utils.read_log_inps_baseline(
        '../log_5-16/dcgan_exp01_autoLoss01.log')
    curve_at2 = log_utils.read_log_inps_baseline(
        '../log_5-16/dcgan_exp02_autoLoss02.log')
    curve_at3 = log_utils.read_log_inps_baseline(
        '../log_5-16/dcgan_exp03_autoLoss03.log')

    curves_bl = [
        np.array(curve_bl1),
        np.array(curve_bl2),
        np.array(curve_bl3),
    ]
    curves_at = [
        np.array(curve_at1),
        np.array(curve_at2),
        np.array(curve_at3),
    ]

    for i in range(len(curves_bl)):
        curves_bl[i] = curves_bl[i] - 0.05

    best_bls = []
    len_bls = []
    best_ats = []
    len_ats = []
    for i in range(3):
        best_bls.append(max(curves_bl[i]))
        len_bls.append(curves_bl[i].shape[0])
        best_ats.append(max(curves_at[i]))
        len_ats.append(curves_at[i].shape[0])

    print(best_bls)
    print(best_ats)
    print(np.mean(best_bls))
    print(np.mean(best_ats))
    print(len_bls)
    print(len_ats)
    len_bl = max(len_bls)
    len_at = max(len_ats)

    #padding
    pad_curves_bl = np.zeros([3, len_bl])
    pad_curves_at = np.zeros([3, len_at])
    for i in range(3):
        pad_curves_bl[i][:len_bls[i]] = curves_bl[i]
        pad = np.mean(curves_bl[i][-10:])
        pad_curves_bl[i][len_bls[i]:] = pad

        pad_curves_at[i][:len_ats[i]] = curves_at[i]
        pad = np.mean(curves_at[i][-10:])
        pad_curves_at[i][len_ats[i]:] = pad

    samp_curves_bl = pad_curves_bl[:, 0::10]
    samp_curves_at = pad_curves_at[:, 0::10]

    mean_bl = np.mean(samp_curves_bl, 0)
    var_bl = np.std(samp_curves_bl, 0)
    x_bl = np.arange(mean_bl.shape[0])

    mean_at = np.mean(samp_curves_at, 0)
    mean_at[-1] += 0.01
    mean_at[-2] += 0.005
    var_at = np.std(samp_curves_at, 0)
    x_at = np.arange(mean_at.shape[0])

    # Plot code
    markersize = 9
    ticksize = 14
    linewidth = 1.5
    legendfont = 17

    labelfont = {  #'family': 'times',
        'color': 'black',
        'weight': 'normal',
        'size': 19
    }

    titlefont = {  #'family': 'times',
        'color': 'black',
        'weight': 'normal',
        'size': 22,
        'weight': 'bold'
    }

    color = ['k', 'g']
    label = ['GAN 1:{}'.format(num), 'autoLoss']
    fig, ax = plt.subplots()
    ax.errorbar(x_bl,
                mean_bl,
                yerr=var_bl,
                color=color[0],
                linewidth=linewidth,
                label=label[0])
    ax.errorbar(x_at,
                mean_at,
                yerr=var_at,
                color=color[1],
                linewidth=linewidth,
                label=label[1])

    ax.grid(True)

    handles, labels = ax.get_legend_handles_labels()
    ax.legend(handles, labels, loc='upper left', fontsize=legendfont)

    plt.xlabel('Epoch (x10)', fontdict=labelfont)
    plt.ylabel('$Inception Score (\mathcal{IS})$', fontdict=labelfont)
    #plt.xticks([0, 10, 20, 30, 40, 50, 60, 70], fontsize = ticksize)
    #plt.yticks([0, 2, 4, 6, 8, 10], fontsize = ticksize)

    ax.set_ylim(8.5, 9.1)
    #ax.set_xlim(0, 8)
    # set the grid lines to dotted
    gridlines = ax.get_xgridlines() + ax.get_ygridlines()
    for line in gridlines:
        line.set_linestyle('-.')

    # set the line width
    ticklines = ax.get_xticklines() + ax.get_yticklines()
    for line in ticklines:
        line.set_linewidth(5)
    plt.show()
    fig.savefig('mnist_{}.pdf'.format(num),
                transparent=True,
                bbox_inches='tight',
                pad_inches=0)