从检查点获取TensorFlow模型的详细信息



我需要从保存的检查点(索引和数据文件(中提取详细信息信息类似:

  • 哪个优化器算法
  • 哪个学习率…等等

如何从python TensorFlow或Linux获得这些详细信息。

我不知道您想要的所有信息是否都保存在您所引用的检查点中(其中一些信息必须明确要求存储,请参阅此(。

无论如何,关于检查点的TF文档都做得很好。

您可以通过提取信息

reader = tf.train.load_checkpoint('./tf_ckpts/')
shape_from_key = reader.get_variable_to_shape_map()
dtype_from_key = reader.get_variable_to_dtype_map()
sorted(shape_from_key.keys())

并获取要查看的字典密钥,例如

key = 'optimizer/learning_rate/.ATTRIBUTES/VARIABLE_VALUE'
print("Shape:", shape_from_key[key])
print("Dtype:", dtype_from_key[key].name)

相关内容

最新更新