How to get weights in tf.layers.dense?

前端 未结 7 745
悲哀的现实
悲哀的现实 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:40

    The weights are added as a variable named kernel, so you could use

    x = tf.dense(...)
    weights = tf.get_default_graph().get_tensor_by_name(
      os.path.split(x.name)[0] + '/kernel:0')
    

    You can obviously replace tf.get_default_graph() by any other graph you are working in.  

提交回复
热议问题