1.图片可视化
并排可视化几张图片:
if torch.cuda.is_available():
edge_predic_X_binary = edge_predic_X_binary.cuda()
edge_gt_X_binary = edge_gt_X_binary.cuda()
concatloss = vutils.make_grid(torch.cat((edge_predic_X_binary,edge_gt_X_binary,edge_predic_X_binary-edge_gt_X_binary),0))
writer.add_image('edge_predic_X_binary and edge_gt_X_binary',
concatloss,
global_step=1)
前后可视化几张图片
#在‘I1 and I2’窗口中连续显示两张图片,I1_ori_img和I2_ori_img_fig
if glob_iter % 100 == 0:
I1_ori_img = cv2.normalize(I.cpu().detach().numpy()[0, 0, ...], None, 0, 255, cv2.NORM_MINMAX, cv2.CV_8U)
I2_ori_img_fig = cv2.normalize(I2_ori_img.cpu().detach().numpy()[0, 0, ...], None, 0, 255, cv2.NORM_MINMAX,cv2.CV_8U)
writer.add_image('I1 and I2',I1_ori_img,global_step=1, dataformats='HW')
writer.add_image('I1 and I2',I2_ori_img_fig, global_step=2,dataformats='HW')
查看某些层数据的分布和梯度的分布
for name, layer in net.named_parameters():
if layer.requires_grad == True:
writer.add_histogram(name + '_grad', layer.grad.cpu().data.numpy(), glob_iter)
writer.add_histogram(name + '_data', layer.cpu().data.numpy(), glob_iter)
查看某些标量
一个窗口绘制多个saclar的变化,或者只绘制一个scalar的变化
writer.add_scalars('Loss_group', {'feature_loss': loss_feature.item()}, glob_iter)
writer.add_scalars('Loss_group', {'L1_loss': l1_loss.item()}, glob_iter)
writer.add_scalar('learning rate', scheduler.get_lr()[0], glob_iter)
参考:https://github.com/microsoft/tensorwatch
参考https://blog.csdn.net/qq_27825451/article/details/96856217
官网:https://github.com/szagoruyko/pytorchviz/blob/master/examples.ipynb
权重可视化,特征图可视化,卷积核可视化:参考https://zhuanlan.zhihu.com/p/54947519