Skip to content

Commit

Permalink
noshow -> show
Browse files Browse the repository at this point in the history
  • Loading branch information
ljk628 committed Oct 22, 2018
1 parent 72ea026 commit d9306da
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
3 changes: 1 addition & 2 deletions plot_1D.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ def plot_1d_loss_err(surf_file, xmin=-1.0, xmax=1.0, loss_max=5, log=False, show
print('------------------------------------------------------------------')
print('plot_1d_loss_err')
print('------------------------------------------------------------------')
print("loading surface file: " + surf_file)

f = h5py.File(surf_file,'r')
print(f.keys())
x = f['xcoordinates'][:]
assert 'train_loss' in f.keys(), "'train_loss' does not exist"
train_loss = f['train_loss'][:]
Expand Down Expand Up @@ -122,7 +122,6 @@ def plot_1d_loss_err_repeat(prefix, idx_min=1, idx_max=10, xmin=-1.0, xmax=1.0,
if show: pp.show()



if __name__ == '__main__':
parser = argparse.ArgumentParser(description='Plott 1D loss and error curves')
parser.add_argument('--surf_file', '-f', default='', help='The h5 file contains loss values')
Expand Down
18 changes: 9 additions & 9 deletions plot_2D.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,7 @@


def plot_2d_contour(surf_file, surf_name='train_loss', vmin=0.1, vmax=10, vlevel=0.5, show=False):
"""Plot 2D contours and 3D surface."""
print('------------------------------------------------------------------')
print('plot_2d_contour')
print('------------------------------------------------------------------')
print("loading surface file: " + surf_file)
"""Plot 2D contour map and 3D surface."""

f = h5py.File(surf_file, 'r')
x = np.array(f['xcoordinates'][:])
Expand All @@ -31,8 +27,12 @@ def plot_2d_contour(surf_file, surf_name='train_loss', vmin=0.1, vmax=10, vlevel
elif surf_name == 'train_err' or surf_name == 'test_err' :
Z = 100 - np.array(f[surf_name][:])
else:
print('%s is not found in %s' % (surf_name, surf_file))
print ('%s is not found in %s' % (surf_name, surf_file))

print('------------------------------------------------------------------')
print('plot_2d_contour')
print('------------------------------------------------------------------')
print("loading surface file: " + surf_file)
print('len(xcoordinates): %d len(ycoordinates): %d' % (len(x), len(y)))
print('max(%s) = %f \t min(%s) = %f' % (surf_name, np.max(Z), surf_name, np.min(Z)))
print(Z)
Expand Down Expand Up @@ -79,7 +79,7 @@ def plot_2d_contour(surf_file, surf_name='train_loss', vmin=0.1, vmax=10, vlevel
if show: plt.show()


def plot_trajectory(proj_file, dir_file, noshow=True):
def plot_trajectory(proj_file, dir_file, show=False):
""" Plot optimization trajectory on the plane spanned by given directions."""

assert exists(proj_file), 'Projection file does not exist.'
Expand All @@ -103,8 +103,8 @@ def plot_trajectory(proj_file, dir_file, noshow=True):
if show: plt.show()


def plot_contour_trajectory(surf_file, dir_file, proj_file, surf_name='train_loss',
vmin=0.1, vmax=10, vlevel=0.5, noshow=True):
def plot_contour_trajectory(surf_file, dir_file, proj_file, surf_name='loss_vals',
vmin=0.1, vmax=10, vlevel=0.5, show=False):
"""2D contour + trajectory"""

assert exists(surf_file) and exists(proj_file) and exists(dir_file)
Expand Down

0 comments on commit d9306da

Please sign in to comment.