简体   繁体   English

恢复预训练模型的Tensorflow检查点文件

[英]Restoring Tensorflow checkpoint files of a pre-trained model

I have downloaded a pre-trained TF-Slim model from MobileNet checkpoint file and I am trying to see what weights were associated with the layers. 我已经从MobileNet检查点文件中下载了经过预训练的TF-Slim模型,并且试图查看与图层相关的权重。

As an example, I have three files: 例如,我有三个文件:

67903136 Jun 14 00:15 mobilenet_v1_1.0_224.ckpt.data-00000-of-00001
19954 Jun 14 00:15 mobilenet_v1_1.0_224.ckpt.index
4319476 Jun 14 00:15 mobilenet_v1_1.0_224.ckpt.meta

First Method: 第一种方法:

I use tensorboard directly: 我直接使用tensorboard

tensorboard --logdir=${CHKPNT_DIR}

it runs locally ( http://127.0.0.1:6006/ ), but does not show anything: 它在本地运行( http://127.0.0.1:6006/ ),但未显示任何内容:

No dashboards are active for the current data set.
Probable causes:

You haven’t written any data to your event files.
TensorBoard can’t find your event files.

Second Method: 第二种方法:

I use the backend method Event_Accumulator : 我使用后端方法Event_Accumulator

import tensorflow as tf
from tensorboard.backend.event_processing.event_accumulator import EventAccumulator
event_acc = EventAccumulator('${CHKPNT_DIR}')
event_acc.Reload()

# Show all tags in the log file
print(event_acc.Tags())

Interestingly, all the Tags are empty: 有趣的是,所有标签都是空的:

{'scalars': [], 'histograms': [], 'meta_graph': False, 'images': [], 'graph': False, 'audio': [], 'distributions': [], 'tensors': [], 'run_metadata': []}

So this is the dir : 所以这是dir

>>>dir(event_acc)
['Audio', 'CompressedHistograms', 'FirstEventTimestamp', 'Graph', 'Histograms', 'Images', 'MetaGraph', 'PluginAssets', 'PluginTagToContent', 'Reload', 'RetrievePluginAsset', 'RunMetadata', 'Scalars', 'SummaryMetadata', 'Tags', 'Tensors', '_CheckForOutOfOrderStepAndMaybePurge', '_CheckForRestartAndMaybePurge', '_CompressHistogram', '_ConvertHistogramProtoToTuple', '_MaybePurgeOrphanedData', '_ProcessAudio', '_ProcessEvent', '_ProcessHistogram', '_ProcessImage', '_ProcessScalar', '_ProcessTensor', '_Purge', '__class__', '__delattr__', '__dict__', '__doc__', '__format__', '__getattribute__', '__hash__', '__init__', '__module__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', '_compression_bps', '_first_event_timestamp', '_generator', '_generator_mutex', '_graph', '_graph_from_metagraph', '_meta_graph', '_plugin_to_tag_to_content', '_tagged_metadata', '_tensor_summaries', 'accumulated_attrs', 'audios', 'compressed_histograms', 'file_version', 'histograms', 'images', 'most_recent_step', 'most_recent_wall_time', 'path', 'purge_orphaned_data', 'scalars', 'summary_metadata', 'tensors']

Then, how are we supposed to view an already pre-trained network? 然后,我们应该如何查看一个已经预先训练的网络? These checkpoint files must contain some sort of Google Protobuf data. 这些检查点文件必须包含某种Google Protobuf数据。

Running TF 1.3.0 on Mac OS 10.12.4. 在Mac OS 10.12.4上运行TF 1.3.0。

saver = tf.train.import_meta_graph("path/your/meta/file")
saver.restore("path/to/data/file")

graph = tf.get_default_graph()
writer = tf.summary.FileWriter("path/to/write/graph")
writer.add_graph(graph)

then 然后

tensorboard --logdir="path/to/write/graph"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用Github和CheckPoint文件中预先训练的Tensorflow模型进行推理 - How to run inference using pre-trained Tensorflow model from their Github and CheckPoint file 无法加载预训练的 model 检查点与 TensorFlow Object 检测 ZDB974238714CA8DE634A7ACE1 - Unable to load pre-trained model checkpoint with TensorFlow Object Detection API Tensorflow Python未加载预训练的模型 - Tensorflow python not loading the pre-trained model 如何在TensorFlow中使用预训练模型 - How to use pre-trained model in TensorFlow 预训练张量流模型的烧瓶 - flask with pre-trained tensorflow model 如何在 tensorflow 中使用预训练的 model 进行预测? - how to predict with pre-trained model in tensorflow? 运行 run_squad.py 以微调 Google BERT 模型(官方 tensorflow 预训练模型)时无法加载(恢复)TensorFlow 检查点 - Failed to load(restore) TensorFlow checkpoint when running run_squad.py to fine-tune the Google BERT model(official tensorflow pre-trained model) Tensorflow如何修改保存为检查点的预训练模型 - Tensorflow how to modify a pre-trained Model saved as checkpoints 如何访问和可视化预训练的 TensorFlow 2 模型中的权重? - How to access and visualize the weights in a pre-trained TensorFlow 2 model? 改进预训练的 tensorflow object 检测 model - Improving a pre-trained tensorflow object detection model
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM