Skip to content

Commit

Permalink
Visu logs: add loggings
Browse files Browse the repository at this point in the history
  • Loading branch information
EmmaRenauld committed May 13, 2024
1 parent ba5a84a commit d430d79
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
9 changes: 9 additions & 0 deletions dwi_ml/viz/logs_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,12 @@ def visualize_logs(logs_data: Dict[str, Dict[str, np.ndarray]],
c_norm = colors.Normalize(vmin=0, vmax=len(exp_names))
scalar_map = cmx.ScalarMappable(norm=c_norm, cmap=jet)

logging.info("Figures will be plotted for epochs 0 - {}.\n"
"Experiments' number of epochs:".format(xlim))
any_graph = graphs_logs[0][0]
for i, n in enumerate(exp_names):
logging.info("- {}: {}".format(n, len(logs_data[n][any_graph])))

# Separating graphs in figures:
nb_plots_left = len(graphs_logs)
current_fig = -1
Expand All @@ -128,6 +134,8 @@ def visualize_logs(logs_data: Dict[str, Dict[str, np.ndarray]],
# Prepare figure and axes
fig_title = ""
next_nb_plots = min(nb_plots_left, nb_rows)

logging.info("New figure:")
fig, axs = plt.subplots(nrows=next_nb_plots)
if fig_size is not None:
fig.set_figheight(fig_size[0])
Expand All @@ -138,6 +146,7 @@ def visualize_logs(logs_data: Dict[str, Dict[str, np.ndarray]],

# For each subplot in this figure
for ax in range(next_nb_plots):
logging.info(" - New plot: {}".format(graphs_titles[i]))
i += 1
fig_title += "_{}".format(
graphs_titles[i].replace(" ", "").replace("'", ""))
Expand Down
1 change: 1 addition & 0 deletions scripts_python/dwiml_visualize_logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ def _load_all_logs(parser, args, logs_path, previous_graphs):
logging.debug("Loading all logs for that experiment.")
files_to_load = list(logs_path.glob('*.npy'))
_graphs = [f.stem for f in files_to_load]
_graphs = np.sort(_graphs)

if previous_graphs is None:
# Using the first experiment to set the list of expected logs.
Expand Down

0 comments on commit d430d79

Please sign in to comment.