Python 3.x 获取Keras变量的列表
我想比较Keras模型中的变量和TensorFlow检查点中的变量。我可以得到如下的TF变量:Python 3.x 获取Keras变量的列表,python-3.x,tensorflow,keras,Python 3.x,Tensorflow,Keras,我想比较Keras模型中的变量和TensorFlow检查点中的变量。我可以得到如下的TF变量: vars\u in\u checkpoint=tf.train.list\u变量(os.path.join(“./model.ckpt”) 如何从我的model中获取要比较的Keras变量?您可以通过model.weights(tf.Variable实例列表)获取Keras模型的变量。要获取变量名称,您需要从模型层的weight属性访问它。大概是这样的: names=[weight.name代表模型中
vars\u in\u checkpoint=tf.train.list\u变量(os.path.join(“./model.ckpt”)
如何从我的
model
中获取要比较的Keras变量?您可以通过model.weights
(tf.Variable实例列表)获取Keras模型的变量。要获取变量名称,您需要从模型层的weight属性访问它。大概是这样的:
names=[weight.name代表模型中的层。layers代表层中的权重。weights]
为了得到重量的形状:
weights=[weight.shape表示模型中的权重。get_weights()]