-
Notifications
You must be signed in to change notification settings - Fork 0
/
plots.py
60 lines (51 loc) · 2.18 KB
/
plots.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import numpy as np
import matplotlib.pyplot as plt
def plots(fpath):
# Loading data
nash_calls = np.loadtxt(fpath+'nash-calls.txt')
gda_calls = np.loadtxt(fpath+'gda-calls.txt')
nash_Gx_norm = np.loadtxt(fpath+'nash-Gx_norm.txt')
gda_Gx_norm = np.loadtxt(fpath+'gda-Gx_norm.txt')
rate_Gx_norm = np.loadtxt(fpath+'rate-Gx_norm.txt')
# nash_Gz_norm_all = np.loadtxt(fpath+'nash-Gz_norm_all.txt')
# gda_Gz_norm_all = np.loadtxt(fpath+'gda-Gz_norm_all.txt')
nash_gap = np.loadtxt(fpath+'nash-gap.txt')
gda_gap = np.loadtxt(fpath+'gda-gap.txt')
# Plotting Gx norm
plt.plot(nash_calls, nash_Gx_norm,color='red',linewidth=2)
plt.plot(gda_calls, gda_Gx_norm,color='blue',linewidth=2)
plt.plot(nash_calls, rate_Gx_norm,color='grey',linewidth=2)
# plt.xscale('log')
plt.yscale('log')
plt.ticklabel_format(style='sci', axis='x', scilimits=(0,0))
plt.legend(['FastNash','FastGDA','Theory'])
plt.title('Primal gradient norm over primal iterations')
plt.show()
# Plotting total gradient norm in-between restarts
# coeff = np.ceil(len(gda_Gz_norm_all)/len(nash_Gz_norm_all))
# ts = [coeff * ts for ts in range(len(nash_Gz_norm_all))]
# plt.plot(ts,nash_Gz_norm_all,color='red',linewidth=2)
# plt.yscale('log')
# plt.ticklabel_format(style='sci', axis='x', scilimits=(0,0))
# plt.legend(['FastNash'])
# plt.title('Full gradient norm over oracle calls (in two nested loops)')
# plt.show()
#
# plt.plot(gda_Gz_norm_all,color='blue',linewidth=2)
# plt.yscale('log')
# plt.ticklabel_format(style='sci', axis='x', scilimits=(0,0))
# plt.legend(['FastGda'])
# plt.title('Full gradient norm over oracle calls')
# plt.show()
# Plotting objective gap
#rate = [L*(R**2)*(t+1)**(-2) for t in range(T+1)]
plt.plot(nash_calls, nash_gap, color='red',linewidth=2)
plt.plot(gda_calls, gda_gap, color='blue',linewidth=2)
# plt.xscale('log')
plt.yscale('log')
plt.ticklabel_format(style='sci', axis='x', scilimits=(0,0))
plt.legend(['FastNash','FastGDA'])
plt.title('Objective gap over primal iterations')
plt.show()