如何获得与TF中的隐藏层关联的权重?

时间:2019-10-26 17:26:29

标签: tensorflow

我需要提取模型中每个隐藏层的权重。

我尝试使用tf.get_variable,但遇到错误。

#hidden layer 1
h1= tf.layers.dense(x,1024, kernel_initializer="he_normal", activation = "relu")

#get weights
with tf.variable_scope("h1", reuse=tf.True):
    weights_h1 = tf.get_variable("kernel")

这是我得到的错误:

ValueError: Variable h1/kernel does not exist, or was not created with tf.get_variable(). Did you mean to set reuse=tf.AUTO_REUSE in VarScope?

0 个答案:

没有答案