def replot(): # res_size vs mc ax1 = plt.subplot(211) ax1.plot(reservoir_sizes, reservoir_sizes, 'k', linestyle=":") ax1.errorbar(reservoir_sizes, mcb_mean, yerr=mcb_std, label="before ", fmt="--") ax1.errorbar(reservoir_sizes, mca_mean, yerr=mca_std, label="after") plt.ylabel("memory capacity") plt.title("impact of orthogonalization process on MC".format(tau, rho)) plt.grid(True) plt.legend(loc=2) plt.xlim([9,101]) # res_size vs lyap ax2 = plt.subplot(212) mcb_le_mean, mcb_le_std = get_mean_std(mcb_lap) ax2.errorbar(reservoir_sizes, mcb_le_mean, yerr=mcb_le_std, label="before", fmt="--") mca_le_mean, mca_le_std = get_mean_std(mca_lap) ax2.errorbar(reservoir_sizes, mca_le_mean, yerr=mca_le_std, label="after") plt.xlabel("reservoir size") plt.ylabel("lyapunov exponent") plt.grid(True) ax2.legend(loc=2) plt.xlim([9,101]) try_save_fig("figures/figure") try_save_fig("figures/figure", ext="pdf") plt.show()
def replot(): fig = plt.figure() ax = fig.add_subplot(111) ax.errorbar( range(memory_max), np.average(forget_before, axis=0), yerr=np.std(forget_before, axis=0), label="before") ax.errorbar( range(memory_max), np.average(forget_after, axis=0), yerr=np.std(forget_after, axis=0), label="after") ax.text(45, 0.8, "MC = {:.2f}".format(mcbefore), color='blue') ax.text(96, 0.8, "MC = {:.2f}".format(mcafter), color='green') ax.grid(True) ax.legend() plt.title("MC forgetting curves before and after orthogonalization") plt.xlabel("$k$") plt.ylabel("$MC_k$") try_save_fig("figures/figure") try_save_fig("figures/figure", ext='pdf') plt.show()
def replot(): together= True if together: max_yticks = 2 fig = plt.figure() fig.subplots_adjust(hspace=0.4) bins = np.linspace(0, 60, 60) for i, sigma in enumerate(sigmas): if together: sp = plt.subplot(len(sigmas)*100 + 10 + 1 + i) if i < len(sigmas) - 1: plt.setp( sp.get_xticklabels(), visible=False) yloc = plt.MaxNLocator(max_yticks) sp.yaxis.set_major_locator(yloc) #sp.yaxis.set_ticks(np.arange(70000,80000,2500)) plt.hist(hists[i], bins=bins, label="$\sigma={:0.3f}$".format(sigma), normed=True, alpha=0.5) plt.legend(loc=2,prop={'size':16}) plt.grid(True) plt.xlim([0, 60]) plt.yticks(fontsize=16) #fig.set_size_inches(4, 3) #plt.figure(figsize=(4,3)) fig = plt.gcf() plt.xticks(fontsize=20) #fig.set_size_inches(4, 3) try_save_fig(ext="png") try_save_fig(ext="eps") #plt.savefig("figure3.eps") plt.show()
def replot(): fig = plt.figure() ax = fig.add_subplot(111) ax.errorbar(range(memory_max), np.average(forget_before, axis=0), yerr=np.std(forget_before, axis=0), label="before", fmt=next(linecycler)) ax.errorbar(range(memory_max), np.average(forget_after, axis=0), yerr=np.std(forget_after, axis=0), label="after", fmt=next(linecycler)) ax.text(45, 0.8, "MC = {:.2f}".format(mcbefore), color='blue') ax.text(96, 0.8, "MC = {:.2f}".format(mcafter), color='green') ax.grid(True) ax.legend() plt.xlim((0, 140)) plt.ylim((-0.05, 1.2)) plt.title("forgetting curves for OG method") plt.xlabel("$k$") plt.ylabel("$MC_k$") try_save_fig("figures/figure") try_save_fig("figures/figure", ext='pdf') plt.show()
def plot(Y, Yerr, savedir, xticks, lineticks, xlabel="", ylabel="", linelabels=[], loc=1, save=False): xmax = np.zeros(len(lineticks)) ymax = np.zeros(len(lineticks)) for li, _ in enumerate(lineticks): ymax[li] = np.max(Y[li]) xmax[li] = xticks[np.argmax(Y[li])] if not linelabels: linelabels = ["" for _ in lineticks] for li, _ in enumerate(lineticks): plt.errorbar(xticks, Y[li], yerr=Yerr[li], label=linelabels[li], fmt=next(linecycler)) #plt.text(xmax[li], ymax[li] + 3, "({:.3f}, {:.3f})".format(xmax[li], ymax[li]), fontsize=18, ha='center') plt.xlabel(xlabel, fontsize=24, labelpad=-3) plt.ylabel(ylabel, fontsize=24) plt.xticks(fontsize=16) plt.yticks(fontsize=16) plt.grid(True) plt.legend(loc=loc) if save: figname = os.path.join(savedir, 'figure') try_save_fig(fname=figname) try_save_fig(fname=figname, ext="pdf") plt.show()
def replot(): xs = range(ORTHO_ITERATIONS + 1) ax1 = plt.subplot(411) ax1.errorbar( xs, np.average(MCs, axis=0), yerr=np.std(MCs, axis=0)) plt.grid(True) plt.ylabel("memory capacity") plt.setp(ax1.get_xticklabels(), visible=False) # eigenvalues ax2 = plt.subplot(412, sharex=ax1) plt.plot(xs, np.average(EVs, axis=0)) plt.grid(True) plt.ylabel("abs(eigenvalues)") plt.setp(ax2.get_xticklabels(), visible=False) # singular values plt.subplot(413, sharex=ax1) plt.plot(xs, np.average(SVs, axis=0)) plt.grid(True) plt.ylabel("singular value") # lyapunov plt.xlabel("iteration") try_save_fig("figures/figure") try_save_fig("figures/figure", ext="pdf") plt.show()
def replot(): # res_size vs mc ax1 = plt.subplot(211) ax1.plot(reservoir_sizes, reservoir_sizes, 'k', linestyle=":") ax1.errorbar(reservoir_sizes, mcb_mean, yerr=mcb_std, label="before ", fmt="--") ax1.errorbar(reservoir_sizes, mca_mean, yerr=mca_std, label="after") plt.ylabel("memory capacity") plt.title("impact of orthonormalization process on MC".format(tau, rho)) plt.grid(True) plt.legend(loc=2) plt.xlim([9,101]) # res_size vs lyap ax2 = plt.subplot(212) ax2.errorbar(reservoir_sizes, mcb_l_mean, yerr=mcb_l_std, label="before", fmt="--") ax2.errorbar(reservoir_sizes, mca_l_mean, yerr=mca_l_std, label="after") plt.xlabel("reservoir size") plt.ylabel("lyapunov exponent") plt.grid(True) ax2.legend(loc=2) plt.xlim([9,101]) try_save_fig("figures/figure") try_save_fig("figures/figure", ext="pdf") plt.show()
def replot(): fig = plt.figure() ax = fig.add_subplot(111) ax.errorbar( range(memory_max), np.average(forget_before, axis=0), yerr=np.std(forget_before, axis=0), label="before", fmt=next(linecycler)) ax.errorbar( range(memory_max), np.average(forget_after, axis=0), yerr=np.std(forget_after, axis=0), label="after", fmt=next(linecycler)) ax.text(45, 0.8, "MC = {:.2f}".format(mcbefore), color='blue') ax.text(96, 0.8, "MC = {:.2f}".format(mcafter), color='green') ax.grid(True) ax.legend() plt.xlim((0, 140)) plt.ylim((-0.05, 1.2)) plt.title("forgetting curves for OG method") plt.xlabel("$k$") plt.ylabel("$MC_k$") try_save_fig("figures/figure") try_save_fig("figures/figure", ext='pdf') plt.show()
def compare_defs(): global q, sigma, tau, W, WI, mc target_later = False use_input = True q = 20 sigma = 0.10 tau = 0.1 W = sp.random.normal(0, sigma, [q, q]) WI = sp.random.uniform(-tau, tau, q) mc = memory_capacity(W, WI, memory_max=2 * q, iterations_coef_measure=100000, iterations=10000, use_input=use_input, target_later=target_later) mcsum = sum(mc) svds = svd(W, compute_uv=0) print("MC = {}\nsmax={}\nsmin={}\nsspread={}".format( mcsum, svds[0], svds[-1], svds[0] / svds[-1])) plt.grid(True) plt.xlabel("$k$") plt.ylabel("$MC_k$") plt.title("starting k = {}; use_input = {}; MC = {:.3f}".format( int(target_later), use_input, mcsum)) plt.plot(range(len(mc)), mc) try_save_fig() try_save_fig(ext="pdf") plt.show()
def replot(): # res_size vs mc plt.plot(reservoir_sizes, reservoir_sizes, 'k', linestyle=":") for i in range(mcb_mean.shape[0]): plt.errorbar(reservoir_sizes, mcb_mean[i], yerr=mcb_std[i], label=rhos[i], fmt="--", color=cols[i]) for i in range(mcb_mean.shape[0]): plt.errorbar(reservoir_sizes, mca_mean[i], yerr=mcb_std[i], color=cols[i]) plt.ylabel("memory capacity") plt.title("impact of ON method on MC") plt.grid(True) plt.legend(loc=4) plt.xlabel("reservoir size") # plt.xlim([9,101]) try_save_fig("figures/figure") try_save_fig("figures/figure", ext="pdf") plt.show()
def scatter(): fig = plt.figure() ax = fig.add_subplot(111) xs = list(range(memory_max)) * INSTANCES ax.scatter( xs, forget_before.flatten(), label="before", c='b') ax.scatter( xs, forget_after.flatten(), label="after", c='g') ax.text(5, 0.6, "MC = {:.2f}".format(mcbefore), color='blue') ax.text(105, 0.6, "MC = {:.2f}".format(mcafter), color='green') ax.grid(True) ax.legend() plt.title("MC forgetting curves before and after orthogonalization") plt.xlabel("$k$") plt.ylabel("$MC_k$") try_save_fig("figures/scatter") try_save_fig("figures/scatter", ext='pdf') plt.show()
def replot(): xs = range(ORTHO_ITERATIONS + 1) ax1 = plt.subplot(411) ax1.errorbar(xs, np.average(MCs, axis=0), yerr=np.std(MCs, axis=0)) plt.grid(True) plt.ylabel("memory capacity") plt.setp(ax1.get_xticklabels(), visible=False) # eigenvalues ax2 = plt.subplot(412, sharex=ax1) plt.plot(xs, np.average(EVs, axis=0)) plt.grid(True) plt.ylabel("abs(eigenvalues)") plt.setp(ax2.get_xticklabels(), visible=False) # singular values plt.subplot(413, sharex=ax1) plt.plot(xs, np.average(SVs, axis=0)) plt.grid(True) plt.ylabel("singular value") # lyapunov plt.xlabel("iteration") try_save_fig("figures/figure") try_save_fig("figures/figure", ext="pdf") plt.show()
def replot(): lims = [20, 50] fs = 24 plt.subplot(121) plt.xlabel("$\\sigma$", fontsize=fs) plt.ylabel("MC") plt.ylim(lims) plt.grid(True) plt.title("normal W, it={}".format(ITERATIONS)) plt.errorbar(sigmas, Y, Yerr) plt.subplot(122) plt.xlabel("$\\hat\\tau$", fontsize=fs) plt.ylabel("MC") plt.ylim(lims) plt.grid(True) plt.title("uniform W, it={}".format(ITERATIONS)) plt.errorbar(tauhats, Y2, Yerr2) fig = plt.gcf() fig.set_size_inches(14, 6) try_save_fig(ext="png") try_save_fig(ext="eps") plt.show()
def compare_defs(): global q,sigma, tau, W, WI, mc target_later = False use_input = True q = 20 sigma = 0.10 tau = 0.1 W = sp.random.normal(0, sigma, [q, q]) WI = sp.random.uniform(-tau, tau, q) mc = memory_capacity(W, WI, memory_max=2*q, iterations_coef_measure=100000, iterations=10000, use_input=use_input, target_later=target_later) mcsum = sum(mc) svds = svd(W, compute_uv=0) print("MC = {}\nsmax={}\nsmin={}\nsspread={}".format(mcsum, svds[0], svds[-1], svds[0] / svds[-1])) plt.grid(True) plt.xlabel("$k$") plt.ylabel("$MC_k$") plt.title("starting k = {}; use_input = {}; MC = {:.3f}".format( int(target_later), use_input, mcsum)) plt.plot(range(len(mc)), mc) try_save_fig() try_save_fig(ext="pdf") plt.show()
def replot(): # res_size vs mc ax1 = plt.subplot(211) ax1.plot(reservoir_sizes, reservoir_sizes, 'k', linestyle=":") ax1.errorbar(reservoir_sizes, mcb_mean, yerr=mcb_std, label="before ", fmt="--") ax1.errorbar(reservoir_sizes, mca_mean, yerr=mca_std, label="after") plt.ylabel("memory capacity") plt.title("impact of OG method on MC".format(tau, rho)) plt.grid(True) plt.legend(loc=4) plt.setp(ax1.get_xticklabels(), visible=False) plt.xlim([9,101]) # res_size vs lyap ax2 = plt.subplot(212) ax2.errorbar(reservoir_sizes, mcb_l_mean, yerr=mcb_l_std, label="before", fmt="--") ax2.errorbar(reservoir_sizes, mca_l_mean, yerr=mca_l_std, label="after") plt.xlabel("reservoir size") plt.ylabel("lyapunov exponent") plt.grid(True) ax2.legend(loc=4) plt.xlim([9,101]) try_save_fig("figures/figure") try_save_fig("figures/figure", ext="pdf") plt.show()
def replot(): # res_size vs mc ax1 = plt.subplot(211) ax1.plot(reservoir_sizes, reservoir_sizes, 'k', linestyle=":") ax1.errorbar(reservoir_sizes, mcb_mean, yerr=mcb_std, label="before ", fmt="--") ax1.errorbar(reservoir_sizes, mca_mean, yerr=mca_std, label="after") plt.ylabel("memory capacity") plt.title("impact of OG method on MC".format(tau, rho)) plt.grid(True) plt.legend(loc=4) plt.setp(ax1.get_xticklabels(), visible=False) # plt.xlim([9,101]) # res_size vs lyap ax2 = plt.subplot(212) ax2.errorbar(reservoir_sizes, mcb_l_mean, yerr=mcb_l_std, label="before", fmt="--") ax2.errorbar(reservoir_sizes, mca_l_mean, yerr=mca_l_std, label="after") plt.xlabel("reservoir size") plt.ylabel("Lyapunov exponent") plt.grid(True) ax2.legend(loc=4) # plt.xlim([9,101]) try_save_fig("figures/figure") try_save_fig("figures/figure", ext="pdf") plt.show()
def replot(): for li in range(len(sparsities)): plt.errorbar(radiuses, Y[li], yerr=Yerr[li], label="sparsity = {:1.2f}".format(sparsities[li])) plt.grid(True) plt.legend(loc=3) plt.xlabel("$|\lambda|_{max}$") plt.ylabel("MC") try_save_fig() plt.show()
def gep_plot_lines(Y, Yerr, xticks, lineticks, xlabel="", ylabel="", loc=1, linelabel=""): for li in range(len(lineticks)): plt.errorbar(xticks, Y[li], yerr=Yerr[li], label=linelabel.format(lineval=lineticks[li])) plt.grid(True) plt.legend(loc=loc) plt.xlabel(xlabel) plt.ylabel(ylabel) try_save_fig() plt.show()
def replot(): xs = range(ORTHO_ITERATIONS + 1) ax1 = plt.subplot(311) # for mc in MCs: # plt.plot(xs, mc) ax1.errorbar(xs, np.average(MCs, axis=0), yerr=np.std(MCs, axis=0)) plt.grid(True) # plt.yticks([i for i in range(20, 102, 20)]) plt.ylabel("MC", size=20) plt.ylim((30, 102)) plt.setp(ax1.get_xticklabels(), visible=False) # eigenvalues e = [] ax2 = plt.subplot(312, sharex=ax1) for ev in EVs: plt.plot(xs, np.amax(ev, axis=1)) for ev in EVs: e.append(np.amax(ev, axis=1)) # ax2.errorbar(xs, # np.average(e, axis=0), # yerr=np.std(e, axis=0)) # plt.yticks(np.arange(0.8, 1.01, 0.05)) plt.grid(True) plt.ylabel(r'$\rho$', size=26) plt.yticks(np.arange(0.76, 0.94, 0.04)) plt.setp(ax2.get_xticklabels(), visible=False) # singular values ax3 = plt.subplot(313, sharex=ax2) s = [] # for sv in SVs: # plt.plot(xs, np.amax(sv, axis=1)) for sv in SVs: s.append(np.amax(sv, axis=1)) ax3.errorbar(xs, np.average(s, axis=0), yerr=np.std(s, axis=0)) plt.grid(True) plt.ylabel(r'$s_{max}$', size=26) plt.yticks(np.arange(1.0, 2.0, 0.2)) plt.setp(ax3.get_xticklabels(), visible=False) plt.xlim((0, 60)) plt.xlabel("iteration", size=20) try_save_fig("figures/eta=" + str(eta)) try_save_fig("figures/eta=" + str(eta), ext="pdf") plt.show()
def replot(): for line in range(LINES): plt.errorbar(sigmas, Y[line], yerr=Yerr[line], label=("res. size={0}".format(q))) plt.grid(True) plt.xlabel("sigma: $W = N(0, \\sigma)$") plt.ylabel("MC, errbar: $1 \\times \\sigma$") plt.legend(loc=3) #plt.title("tau = {0}".format(tau)) try_save_fig() plt.show()
def draw(): save = True fig = plt.gcf() fig.set_size_inches(8, 3) plt.xticks(fontsize=18) plt.yticks(fontsize=18) if save: try_save_fig() try_save_fig(ext="pdf") plt.clf() else: plt.show()
def draw(): save = True fig = plt.gcf() fig.set_size_inches(8,3) plt.xticks(fontsize=18) plt.yticks(fontsize=18) if save: try_save_fig() try_save_fig(ext="pdf") plt.clf() else: plt.show()
def replot(): for qi in range(LINES): plt.errorbar(svals, Y[qi], label=("res. size={0}".format(res_sizes[qi])), yerr=Yerr[qi]) plt.plot(maxinlineX, maxinlineY, c=(0,0,0), label="maxima") plt.grid(True) plt.xlabel("$s_{max}$") plt.ylabel("MC, errbar: $1 \\times \\sigma$") plt.legend(loc=1) #plt.title("tau = {0}".format(tau)) try_save_fig() plt.show()
def r(): for li, dist in enumerate(dists): interval = "input $\in [{}, {}]$".format(*dists[li][0]) plt.scatter(lines[li][0], lines[li][1],marker='+', c=dists[li][1], label=interval) plt.legend(loc=3) plt.grid(True) plt.xlabel("LE") plt.ylabel("MC") plt.xlim([-1.1, 0.5]) plt.ylim([0, 30]) try_save_fig(ext="png") try_save_fig(ext="eps") plt.show()
def replot(): for qi in range(LINES): plt.errorbar(svals, Y[qi], label=("res. size={0}".format(res_sizes[qi])), yerr=Yerr[qi]) plt.plot(maxinlineX, maxinlineY, c=(0, 0, 0), label="maxima") plt.grid(True) plt.xlabel("$s_{max}$") plt.ylabel("MC, errbar: $1 \\times \\sigma$") plt.legend(loc=1) #plt.title("tau = {0}".format(tau)) try_save_fig() plt.show()
def replot(): # res_size vs mc plt.plot(reservoir_sizes, reservoir_sizes, 'k', linestyle=":") plt.errorbar(reservoir_sizes, mcb_mean, yerr=mcb_std, label="before ", fmt="--") plt.errorbar(reservoir_sizes, mca_mean, yerr=mca_std, label="after") plt.ylabel("memory capacity") plt.title("impact of OG method on MC".format(tau, rho)) plt.grid(True) plt.legend(loc=4) plt.xlabel("reservoir size") # plt.xlim([9,101]) try_save_fig("figures/figure") try_save_fig("figures/figure", ext="pdf") plt.show()
def replot(): # res_size vs mc plt.plot(reservoir_sizes, reservoir_sizes, 'k', linestyle=":") plt.errorbar(reservoir_sizes, mcb_mean, yerr=mcb_std, label="before ", fmt="--") plt.errorbar(reservoir_sizes, mca_mean, yerr=mca_std, label="after") plt.ylabel("memory capacity") plt.title("impact of ON method on MC".format(tau, rho)) plt.grid(True) plt.legend(loc=4) plt.xlabel("reservoir size") # plt.xlim([9,101]) try_save_fig("figures/figure") try_save_fig("figures/figure", ext="pdf") plt.show()
def replot(): # res_size vs mc sp1 = plt.subplot(211) for i in range(mc.shape[0]): sp1.plot(mc[i, :-1], label=reservoir_sizes[i]) plt.xlabel("time") plt.ylabel("memory capacity") plt.title("impact of OG method on MC") plt.legend(loc=4) sp2 = plt.subplot(212) for i in range(mc.shape[0]): sp2.plot(le[i, :-1], label=reservoir_sizes[i]) try_save_fig("figures/figure") try_save_fig("figures/figure", ext="pdf") plt.show()
def replot(): plt.plot(reservoir_sizes, reservoir_sizes, 'k', linestyle="--") plt.errorbar(reservoir_sizes, mcb_mean, yerr=mcb_std, label="before ") plt.errorbar(reservoir_sizes, mca_mean, yerr=mca_std, label="after") plt.xlabel("reservoir size") plt.ylabel("memory capacity") plt.title("impact of orthogonalization process on MC".format(tau, rho)) plt.grid(True) plt.legend(loc=2) print("tau={tau}, rho={rho}, eta={eta}".format(tau=tau, rho=rho, eta=eta)) print("instances={i}, ortho-iterations={oi}".format(i=INSTANCES, oi=ORTHOPROCESS_ITERATIONS)) try_save_fig("figures/figure") try_save_fig("figures/figure", ext="pdf") plt.show()
def replot(): for si, sigma in enumerate(sigmas): plt.plot(ks, mcks[si], label="$\\sigma = {:.3f}$".format(sigma)) fig = plt.gcf() #plt.xticks(fontsize=20) fig.set_size_inches(6, 4.5) plt.grid(True) plt.legend(loc=1) plt.xlabel("$k$") plt.ylabel("$MC_k$") try_save_fig() try_save_fig(ext="eps") plt.show()
def replot(): xs = range(ORTHO_ITERATIONS + 1) ax1 = plt.subplot(411) ax1.errorbar( xs, np.average(MCs, axis=0), yerr=np.std(MCs, axis=0)) plt.grid(True) # plt.legend(loc=legend_location, labels='a') plt.legend(loc=legend_location) plt.ylabel("memory capacity") plt.setp(ax1.get_xticklabels(), visible=False) # eigenvalues ax2 = plt.subplot(412, sharex=ax1) plt.plot(xs, np.average(EVs, axis=0)) plt.grid(True) plt.ylabel("abs(eigenvalues)") plt.setp(ax2.get_xticklabels(), visible=False) # singular values plt.subplot(413, sharex=ax1) plt.plot(xs, np.average(SVs, axis=0)) plt.grid(True) plt.ylabel("singular value") # lyapunov ax4 = plt.subplot(414, sharex=ax1) fixed_les = [] xs = list(range(0, 101, 10)) for i in range(len(LEs)): fixed_les.append(LEs[i][xs]) print(fixed_les) ax4.errorbar( xs, np.average(fixed_les, axis=0), yerr=np.std(fixed_les, axis=0)) plt.grid(True) plt.ylabel("lyapunov exponent") plt.xlabel("iteration") try_save_fig("figures/eta=" + str(eta)) try_save_fig("figures/eta=" + str(eta), ext="pdf") plt.show()
def replot(): plt.plot(reservoir_sizes, reservoir_sizes, 'k', linestyle="--") plt.errorbar(reservoir_sizes, mcb_mean, yerr=mcb_std, label="before ") plt.errorbar(reservoir_sizes, mca_mean, yerr=mca_std, label="after") plt.xlabel("reservoir size") plt.ylabel("memory capacity") plt.title("impact of orthogonalization process on MC".format(tau, rho)) plt.grid(True) plt.legend(loc=2) print("tau={tau}, rho={rho}, eta={eta}".format(tau=tau, rho=rho, eta=eta)) print("instances={i}, ortho-iterations={oi}".format( i=INSTANCES, oi=ORTHOPROCESS_ITERATIONS)) try_save_fig("figures/figure") try_save_fig("figures/figure", ext="pdf") plt.show()
def replot(): xs = range(ORTHO_ITERATIONS + 1) ax1 = plt.subplot(411) for mc in MCs: plt.plot(xs, mc) plt.grid(True) # plt.yticks([i for i in range(20, 102, 20)]) plt.ylabel("MC", size=20) plt.ylim((20, 102)) plt.setp(ax1.get_xticklabels(), visible=False) # eigenvalues ax2 = plt.subplot(412, sharex=ax1) for ev in EVs: plt.plot(xs, np.amax(ev, axis=1)) plt.grid(True) # plt.ylabel("max(abs(eigenvalues))") plt.ylabel(r'$\rho$', size=26) plt.setp(ax2.get_xticklabels(), visible=False) # singular values ax3 = plt.subplot(413, sharex=ax1) for sv in SVs: plt.plot(xs, np.amax(sv, axis=1)) plt.grid(True) plt.ylabel(r'$s_{max}$', size=26) plt.setp(ax3.get_xticklabels(), visible=False) # lyapunov ax4 = plt.subplot(414, sharex=ax1) for le in LEs: plt.plot(xs, le) plt.grid(True) plt.ylabel('LE', size=26) plt.xlim((0, 60)) plt.xlabel("iteration", size=20) try_save_fig("figures/eta=" + str(eta)) try_save_fig("figures/eta=" + str(eta), ext="pdf") plt.show()
def r(): for li, dist in enumerate(dists): interval = "input $\in [{}, {}]$".format(*dists[li][0]) plt.scatter(lines[li][0], lines[li][1], marker='+', c=dists[li][1], label=interval) plt.legend(loc=3) plt.grid(True) plt.xlabel("LE") plt.ylabel("MC") plt.xlim([-1.1, 0.5]) plt.ylim([0, 30]) try_save_fig(ext="png") try_save_fig(ext="eps") plt.show()
def draw(Y, Yerr, save=True): global xmax, ymax ymax = np.max(Y) xmax = xticks[np.argmax(Y)] plt.errorbar(xticks, Y, yerr=Yerr) plt.xlabel(xlabel, fontsize=24, labelpad=-3) plt.ylabel("memory capacity", fontsize=24) #rc('xtick', labelsize=24) #rc('ytick', labelsize=24) plt.xticks(fontsize=16) plt.yticks(fontsize=16) plt.grid() #plt.text(xmax, ymax, "({:.3f}, {:.3f})".format(xmax, ymax), fontsize=24) if save: try_save_fig() try_save_fig(ext="pdf") plt.show()
def replot(): xs = range(ORTHO_ITERATIONS + 1) ax1 = plt.subplot(411) ax1.errorbar( xs, np.average(MCs, axis=0), yerr=np.std(MCs, axis=0)) plt.grid(True) plt.ylabel("MC", size=20) plt.setp(ax1.get_xticklabels(), visible=False) # eigenvalues ax2 = plt.subplot(412, sharex=ax1) for ev in EVs: plt.plot(xs, np.amax(ev, axis=1)) plt.grid(True) # plt.ylabel("max(abs(eigenvalues))") plt.ylabel(r'$\rho$', size=26) plt.setp(ax2.get_xticklabels(), visible=False) # singular values ax3 = plt.subplot(413, sharex=ax1) for sv in SVs: plt.plot(xs, np.amax(sv, axis=1)) plt.grid(True) plt.ylabel(r'$s_{max}$', size=26) plt.setp(ax3.get_xticklabels(), visible=False) # lyapunov ax4 = plt.subplot(414, sharex=ax1) ax4.errorbar( xs, np.average(LEs, axis=0), yerr=np.std(LEs, axis=0)) plt.grid(True) plt.ylabel("LE", size=20) plt.xlabel("iteration", size=20) try_save_fig("figures/eta=" + str(eta)) try_save_fig("figures/eta=" + str(eta), ext="pdf") plt.show()
def replot(): xs = range(ORTHO_ITERATIONS + 1) ax1 = plt.subplot(411) ax1.errorbar(xs, np.average(MCs, axis=0), yerr=np.std(MCs, axis=0)) plt.grid(True) # plt.legend(loc=legend_location, labels='a') plt.legend(loc=legend_location) plt.ylabel("memory capacity") plt.setp(ax1.get_xticklabels(), visible=False) # eigenvalues ax2 = plt.subplot(412, sharex=ax1) plt.plot(xs, np.average(EVs, axis=0)) plt.grid(True) plt.ylabel("abs(eigenvalues)") plt.setp(ax2.get_xticklabels(), visible=False) # singular values plt.subplot(413, sharex=ax1) plt.plot(xs, np.average(SVs, axis=0)) plt.grid(True) plt.ylabel("singular value") # lyapunov ax4 = plt.subplot(414, sharex=ax1) fixed_les = [] xs = list(range(0, 101, 10)) for i in range(len(LEs)): fixed_les.append(LEs[i][xs]) print(fixed_les) ax4.errorbar(xs, np.average(fixed_les, axis=0), yerr=np.std(fixed_les, axis=0)) plt.grid(True) plt.ylabel("lyapunov exponent") plt.xlabel("iteration") try_save_fig("figures/eta=" + str(eta)) try_save_fig("figures/eta=" + str(eta), ext="pdf") plt.show()
def replot(): plt.figure(figsize=(8, 8)) ax = plt.subplot(1,1,1) # res_size vs mc for i in range(mc_mean.shape[1]): ax.errorbar(reservoir_sizes, mc_mean[:, i], yerr=mc_std[:, i], label="{:.0e}".format(taus[i])) ax.scatter(reservoir_sizes, mc_mean[:, i]) plt.ylabel("memory capacity") # plt.xlim((99, 501)) plt.ylim((0, 500)) plt.title("ON method") ax.grid(True) handles, labels = ax.get_legend_handles_labels() ax.legend(handles[::-1], labels[::-1], loc=2) plt.xlabel("reservoir size") try_save_fig("figures/figure") try_save_fig("figures/figure", ext="pdf") plt.show()
def main(): global W, WI, U, L, V, L2 q = 100 sigma = 0.09 tau = 0.1 # boedecker's definition target_later = True use_input = False W = sp.random.normal(0, sigma, [q, q]) WI = sp.random.uniform(-tau, tau, q) U, L, V = svd(W) smin = L[-1] smax = L[0] L2 = sp.zeros_like(L) smins = sp.linspace(smin, 0.4, 40) mcs = sp.zeros_like(smins) for si, new_smin in enumerate(smins): L2 = stretch_min(L, new_smin, smin, smax) W2 = sp.dot(U, sp.dot(sp.diag(L2), V)) mc = memory_capacity(W2, WI, memory_max=2 * q, iterations_coef_measure=1000, iterations=1000, use_input=use_input, target_later=target_later) mcs[si] = sum(mc) plt.plot(smins, mcs) plt.grid(True) plt.xlabel("new $s_{min}$") plt.ylabel("memory capacity") try_save_fig() try_save_fig(ext='pdf') plt.show()
def replot(): # res_size vs mc ax1 = plt.subplot(211) ax1.plot(reservoir_sizes, reservoir_sizes, 'k', linestyle=":") ax1.errorbar(reservoir_sizes, mcb_mean, yerr=mcb_std, label="before ", fmt="--") ax1.errorbar(reservoir_sizes, mca_mean, yerr=mca_std, label="after") plt.ylabel("MC") plt.title("OG method") plt.grid(True) ax2 = plt.subplot(212) ax2.errorbar(reservoir_sizes, leb_mean, yerr=leb_std, label="before ", fmt="--") ax2.errorbar(reservoir_sizes, lea_mean, yerr=lea_std, label="after") plt.ylabel("LE") plt.grid(True) plt.legend(loc=4) plt.xlabel("reservoir size") plt.yticks(np.arange(0.0, -0.11, -0.02)) try_save_fig("figures/figure") try_save_fig("figures/figure", ext="pdf") plt.show()
def replot(): together = True if together: max_yticks = 2 fig = plt.figure() fig.subplots_adjust(hspace=0.4) bins = np.linspace(0, 60, 60) for i, sigma in enumerate(sigmas): if together: sp = plt.subplot(len(sigmas) * 100 + 10 + 1 + i) if i < len(sigmas) - 1: plt.setp(sp.get_xticklabels(), visible=False) yloc = plt.MaxNLocator(max_yticks) sp.yaxis.set_major_locator(yloc) #sp.yaxis.set_ticks(np.arange(70000,80000,2500)) plt.hist(hists[i], bins=bins, label="$\sigma={:0.3f}$".format(sigma), normed=True, alpha=0.5) plt.legend(loc=2, prop={'size': 16}) plt.grid(True) plt.xlim([0, 60]) plt.yticks(fontsize=16) #fig.set_size_inches(4, 3) #plt.figure(figsize=(4,3)) fig = plt.gcf() plt.xticks(fontsize=20) #fig.set_size_inches(4, 3) try_save_fig(ext="png") try_save_fig(ext="eps") #plt.savefig("figure3.eps") plt.show()
def replot(): plt.figure(figsize=(8, 8)) ax = plt.subplot(1, 1, 1) # res_size vs mc for i in range(mc_mean.shape[1]): ax.errorbar(reservoir_sizes, mc_mean[:, i], yerr=mc_std[:, i], label="{:.0e}".format(taus[i])) ax.scatter(reservoir_sizes, mc_mean[:, i]) plt.ylabel("memory capacity") # plt.xlim((99, 501)) plt.ylim((0, 500)) plt.title("ON method") ax.grid(True) handles, labels = ax.get_legend_handles_labels() ax.legend(handles[::-1], labels[::-1], loc=2) plt.xlabel("reservoir size") try_save_fig("figures/figure") try_save_fig("figures/figure", ext="pdf") plt.show()
def main(): global W, WI, U, L, V, L2 q = 100 sigma = 0.09 tau = 0.1 # boedecker's definition target_later = True use_input = False W = sp.random.normal(0, sigma, [q, q]) WI = sp.random.uniform(-tau, tau, q) U, L, V = svd(W) smin = L[-1] smax = L[0] L2 = sp.zeros_like(L) smins = sp.linspace(smin, 0.4, 40) mcs = sp.zeros_like(smins) for si, new_smin in enumerate(smins): L2 = stretch_min(L, new_smin, smin, smax) W2 = sp.dot(U, sp.dot(sp.diag(L2), V)) mc = memory_capacity(W2, WI, memory_max=2*q, iterations_coef_measure=1000, iterations=1000, use_input=use_input, target_later=target_later) mcs[si] = sum(mc) plt.plot(smins, mcs) plt.grid(True) plt.xlabel("new $s_{min}$") plt.ylabel("memory capacity") try_save_fig() try_save_fig(ext='pdf') plt.show()
def replot(): xs = range(ORTHO_ITERATIONS + 1) ax1 = plt.subplot(311) plt.plot(xs, mc_gon, label="orthogonalization") plt.plot(xs, mc_nor, label="orthonormalization") plt.grid(True) plt.legend(loc=legend_location) #plt.xlabel("iteration") plt.ylabel("memory capacity") plt.setp(ax1.get_xticklabels(), visible=False) # eigenvalues ax2 = plt.subplot(312, sharex=ax1) plt.plot(xs, eigenvaluesG, c='blue', label="gon") plt.plot(xs, eigenvaluesN, c='green', label="norm") plt.grid(True) #plt.legend(loc=legend_location) #plt.xlabel("iteration") plt.ylabel("abs(eigenvalues)") plt.setp(ax2.get_xticklabels(), visible=False) # singular values ax3 = plt.subplot(313, sharex=ax1) plt.plot(xs, singular_valuesG, c='blue', label="gon") plt.plot(xs, singular_valuesN, c='green', label="norm") plt.grid(True) #plt.legend(loc=legend_location) plt.xlabel("iteration") plt.ylabel("singular values") try_save_fig("figures/figure") try_save_fig("figures/figure", ext="pdf") plt.show()
def r(): """ replot the values """ bar_width = 1 def barit(where, what, label, c): av = np.average(what) plt.bar([where], [av], bar_width, yerr=[np.std(what)], label=label, color=c) plt.text(where + 0.5, av + 2, str(np.round(av, 2)), ha='center') barit(bar_width*0, mcs_jaeger, "jaeger", 'r') barit(bar_width*1, mcs_boedecker, "boedecker", 'b') barit(bar_width*2, mcs_ja, "me", 'g') barit(bar_width*3, mcs_other, "other", 'y') # plt.bar([0], [np.average(mcs_jaeger)], bar_width, yerr=[np.std(mcs_jaeger)], label="jaeger") # plt.bar([bar_width] , [np.average(mcs_boedecker)], bar_width, yerr=[np.std(mcs_boedecker)], label="boedecker") # plt.bar([bar_width*2] , [np.average(mcs_ja)], bar_width, yerr=[np.std(mcs_ja)], label="ja") # plt.bar([bar_width*3] , [np.average(mcs_other)], bar_width, yerr=[np.std(mcs_other)], label="other") plt.legend(loc=3) plt.grid(True) plt.title("$\\tau={tau}$".format(tau=tau)) try_save_fig(ext="png") try_save_fig(ext="eps") plt.show()