如何在TensorboardX中解释梯度和参数直方图?

问题描述

我在ImageNet数据库上运行AlexNet了3个时期,并在绘制grads / params时得到了它。 -

Params in epoch 2

Epoch 2 params

Epoch 2 params distribution

enter image description here

Grads in epoch 2

enter image description here

Epoch 2 grads distribution

enter image description here

Parameters over epochs

enter image description here

distribution of params over epochs

enter image description here

# Code for Epoch wise plot
# Add this to the training loop in the train_one_epoch function
for name,param in model.named_parameters():
           writer.add_histogram(
               tag=f"epoch_{epoch}_params/{name}",values=param,global_step=batch
           )
           writer.add_histogram(
               tag=f"epoch_{epoch}_grads/{name}",values=param.grad,global_step=batch
           )
# For run parameters - 
# Add this to end of epoch loop
for layer,(name,param) in enumerate(model.named_parameters()):
         writer.add_histogram(
             tag=f"run_params/{name}",global_step=epoch
         )

我在意以下问题-

  1. 这些图是什么意思,以及如何阅读它们?
  2. 我们可以推断模型是否使用epoch2或整个运行过程中的这些图学到了什么?如果可以,怎么办?
  3. 我们可以使用这些图表调试消失/爆炸梯度吗? (如果您可以分享一些示例,那将非常棒。)
  4. 最后,为此打破头绪还是有用的吗?

谢谢!

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)