How to get weights in tf.layers.dense?

前端 未结 7 698
悲哀的现实
悲哀的现实 2020-12-29 07:25

I wanna draw the weights of tf.layers.dense in tensorboard histogram, but it not show in the parameter, how could I do that?

7条回答
  •  北海茫月
    2020-12-29 07:36

    I came across this problem and just solved it. tf.layers.dense 's name is not necessary to be the same with the kernel's name's prefix. My tensor is "dense_2/xxx" but it's kernel is "dense_1/kernel:0". To ensure that tf.get_variable works, you'd better set the name=xxx in the tf.layers.dense function to make two names owning same prefix. It works as the demo below:

    l=tf.layers.dense(input_tf_xxx,300,name='ip1')
    with tf.variable_scope('ip1', reuse=True):
        w = tf.get_variable('kernel')
    

    By the way, my tf version is 1.3.

提交回复
热议问题