python – Tensorboard权重直方图只有最后一层可见的变化

python – Tensorboard权重直方图只有最后一层可见的变化,第1张

概述我在网络中添加了TensorBoard可视化,并注意到只有外层变化很多.为什么网络的权重不会发生很大变化?这在叠加直方图中尤为明显. 直方图 相同但覆盖视图 我的模特 def neural_network_model(inputdata): """The blueprint of the network and the tensorboard information :pa 我在网络中添加了TensorBoard可视化,并注意到只有外层变化很多.为什么网络的权重不会发生很大变化?这在叠加直方图中尤为明显.

直方图


相同但覆盖视图

我的模特

def neural_network_model(inputdata):    """The blueprint of the network and the tensorboard information        :param inputdata: the placeholder for the inputdata        :returns: the output of the network?            """    W1 = tf.get_variable("W1",shape=[set.input,nodes_h1],initializer=tf.contrib.layers.xavIEr_initializer())    B1 = tf.get_variable("B1",shape=[nodes_h1],initializer=tf.random_normal_initializer())    layer1 = tf.matmul(inputdata,W1)    layer1_bias = tf.add(layer1,B1)    layer1_act = tf.nn.relu(layer1)    W2 = tf.get_variable("W2",shape=[nodes_h1,nodes_h2],initializer=tf.contrib.layers.xavIEr_initializer())    B2 = tf.get_variable("B2",shape=[nodes_h2],initializer=tf.random_normal_initializer())    layer2 = tf.matmul(layer1_act,W2)    layer2_bias = tf.add(layer2,B2)    layer2_act = tf.nn.relu(layer2)    W3 = tf.get_variable("W3",shape=[nodes_h2,nodes_h3],initializer=tf.contrib.layers.xavIEr_initializer())    B3 = tf.get_variable("B3",shape=[nodes_h3],initializer=tf.random_normal_initializer())    layer3 = tf.matmul(layer2_act,W3)    layer3_bias = tf.add(layer3,B3)    layer3_act = tf.nn.relu(layer3)    WO = tf.get_variable("WO",shape=[nodes_h3,set.output],initializer=tf.contrib.layers.xavIEr_initializer())    layerO = tf.matmul(layer3_act,WO)    with tf.name_scope('Layer1'):        tf.summary.histogram("weights",W1)        tf.summary.histogram("layer",layer1)        tf.summary.histogram("bias",layer1_bias)        tf.summary.histogram("activations",layer1_act)    with tf.name_scope('Layer2'):        tf.summary.histogram("weights",W2)        tf.summary.histogram("layer",layer2)        tf.summary.histogram("bias",layer2_bias)        tf.summary.histogram("activations",layer2_act)    with tf.name_scope('Layer3'):        tf.summary.histogram("weights",W3)        tf.summary.histogram("layer",layer3)        tf.summary.histogram("bias",layer3_bias)        tf.summary.histogram("activations",layer3_act)    with tf.name_scope('Output'):        tf.summary.histogram("weights",WO)        tf.summary.histogram("layer",layerO)    return layerO

我对训练过程的理解是,应该调整重量,这在图像中几乎不会发生.然而,损失已经完成.我已经训练了10000个时代的网络,所以我期望整体上有一点变化.特别是重量不足我不明白.有人可以详细说明吗?

解决方法 我的神经网络中的重量直方图遇到了类似的问题.尽管Relu确实处理了隐藏层的消失梯度问题,但您应该检查您的学习速率并确保每个变量的更新不会太小.这可能导致接近零的更新,导致随时间的变化无关紧要.您只需使用以下代码段检查每个图层的渐变:

def replace_none_with_zero(tensor):   return[0 if i==None else i for i in tensor]with tf.name_scope('GradIEnts'):   gradIEnt_for_variable_of_interest=replace_none_with_zero(                              tf.gradIEnts(loss,[variable_of_interest]))

然后通过调用渐变上的tf.summary.histogram来检查tensorboard中的渐变.

总结

以上是内存溢出为你收集整理的python – Tensorboard权重直方图只有最后一层可见的变化全部内容,希望文章能够帮你解决python – Tensorboard权重直方图只有最后一层可见的变化所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://www.54852.com/langs/1196335.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-06-03
下一篇2022-06-03

发表评论

登录后才能评论

评论列表(0条)

    保存