可视化卷积层的权重

时间:2018-07-30 23:18:49

标签: tensorflow machine-learning data-visualization conv-neural-network

我正在尝试可视化我正在从头训练的Inception(v2)模型的第一层(conv2d)的权重,作为学习练习。我的目标是看到这样的东西:

enter image description here

训练48小时后,我的体重看起来像这样:

enter image description here

我意识到该模型尚未收敛,但给我的印象是我没有正确保存这些图像。将这些权重保存为图像的正确方法是什么?这就是7x7过滤器之一:

[[[-0.05254178 -0.32257697 -1.12509501]
[-0.0577225   0.05430533  0.36126333]
  [-0.60956329 -1.30094147 -0.94367725]
  [ 0.54475862 -0.59896839  0.15690225]
  [-0.97573054  1.32717788 -1.60333276]
  [ 0.15729432  0.75963998 -1.15895975]
  [ 0.44433147 -0.59633678  0.85462248]]

 [[-1.25177848 -0.22818488  0.59435815]
  [-0.33860862 -0.57336748 -0.98618352]
  [ 0.72633511 -1.13217747 -1.76324153]
  [ 0.51535034 -1.67747593  0.65356445]
  [-0.35212585  0.30183136 -0.56150651]
  [-0.76186991  0.82538754 -0.97745162]
  [-0.59434128  0.83723128  0.87456381]]

 [[ 1.45617723 -0.76524097 -0.86497647]
 [-1.26491678  0.17541747  1.15705132]
  [-1.08001506  0.85055047  0.85818022]
  [ 0.74638301  0.62615412  0.82004201]
  [-0.18160205 -1.20272303 -0.83150953]
  [ 0.10087592 -0.81851184 -0.42592993]
  [-0.55882829 -0.17606784  0.18895631]]

 [[ 0.3052578  -0.96171474 -1.50700831]
 [ 1.42404032  0.76130313 -0.76801056]
  [ 1.17354596 -0.95108169 -1.26256537]
  [-0.31658572 -1.77376604  0.51870042]
  [-1.15100074 -0.10693484  1.1963098 ]
  [-0.71053046 -0.0048219   0.04927144]
  [-0.54291326  0.53240746  0.07321835]]

 [[ 1.30089164 -0.80944502 -0.73323363]
 [-0.23359792  1.8435204   0.40987673]
  [-1.03293586 -0.47056404  1.50919926]
  [ 0.16482946 -0.70123744 -0.1847167 ]
  [ 0.8541984  -0.65718001 -0.72896409]
  [-0.35303     1.07880664 -0.47393021]
  [ 0.31868654 -0.32843634 -0.1771179 ]]

 [[ 0.51924646 -0.17256238  0.36290699]
  [ 1.49726737 -1.06288946  0.0867526 ]
  [-0.0572592   1.11176336  1.13637185]
  [-1.85817802 -0.77071941 -1.24363136]
  [ 1.39292431  0.80537623 -0.74663389]
  [ 0.78745258 -0.12404614  0.52013248]
  [-0.63301861 -0.09680288 -0.75839919]]

 [[ 0.53743452  0.40094584  1.37857044]
  [-1.42719209 -0.21600421  0.66738045]
  [-0.91122359  1.03506982  0.3147507 ]
  [-1.41389787  0.44936335 -0.55145448]
  [-1.85846198  0.33287755  0.19934106]
  [ 0.51051307 -0.62650138  0.7086826 ]
  [ 0.05585323  0.07293719 -1.15675306]]]

这是我保存它们的方法:

# Get weights from the model
weights = estimator.get_variable_value('Conv2d_1a_7x7/weights')

for index in range(64):
  plt.imsave('weights-{}.png'.format(path, index), weights[:, :, :, index])

0 个答案:

没有答案