首页 > 解决方案 > 如何获得与 TF 中隐藏层相关的权重?

问题描述

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

我尝试使用 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?

标签: tensorflow

解决方案


推荐阅读