SummaryWriter().add_histogram() does not log


I am trying to visualize neural network weights by adding weights to the histograms of tensorboard.

for name, weight in
self.writer.add_histogram(name, weight, global_step=step_id)

code itself runs without any errors, but in tensorboard I do not see the histograms(i don’t see any log).
I printed the name and weights to confirm they are not empty tensor.

Any help to resolve this is appreciated.

Thank you!

Do you use flush()? Generally, file size increase would indicate success on pytorch side. On browser side, chrome-based browser may be needed, and density plots are on separate page.

No, I did not quite understand what you are saying. Can you please provide more information?
Thank you!

below works for me:

from torch import nn
from torch.utils.tensorboard import SummaryWriter

net = nn.Linear(8,8)
writer = SummaryWriter(DIR) #,flush_secs=120
for name, weight in net.named_parameters():
	writer.add_histogram(name, weight, global_step=1)
writer.flush() #to avoid delayed disk writes when inside a training loop
1 Like