This is not an answer, just a workaround.
This too, is not an answer, (images taken from there).
I am looking for an answer with code in in pytorch-lightning.
I want to create graphs like this one
but without causing spam like this
All I could find was this answer, which explains only either how to plot such a multi-scalar graph with spam, or avoid spam while splitting the graphs.
How can I just get multiple scalars into a single graph?
Code (using pytorch lightning):
tb = self.logger.experiment # This is a SummaryWriter
label_ind_by_names = {
"A": 0,
"B": 1,
"C": 2,
"D": 3,
"E": 4,
"F": 5,
"G": 6,
"H": 7,
"I": 8,
"J": 9,
}
computed_confusion = np.random.randint(low=0, high=100, size=(10, 10))
per_class_accuracy = computed_confusion.diagonal()/(computed_confusion.sum(1) + np.finfo(float).eps)
drs = {names: per_class_accuracy[label_ind_by_names[names]] for names in label_ind_by_names.keys() if any("is_damaged_True" in n for n in names)}
fas = {names: 1.0 - per_class_accuracy[label_ind_by_names[names]] for names in label_ind_by_names.keys() if any("is_damaged_False" in n for n in names)}
code for separate graphs:
for names, dr in drs.items():
tb.add_scalar(f"dr/{str(names)}", dr, self.current_epoch)
for names, fa in fas.items():
tb.add_scalar(f"fa/{str(names)}", fa, self.current_epoch)
and for united graphs which disorganize the plot list
tb.add_scalars(
"DR", {
str(k): v for k, v in drs.items()
},
self.current_epoch
)
tb.add_scalars(
"FA", {
str(k): v for k, v in fas.items()
},
self.current_epoch
)
from How to plot multiple scalars in Tensorboard in the same figure without spamming the experiment list?
No comments:
Post a Comment