I am a newer to tensorflow. I have trained a CNN model , and get
checkpoint files.
Then,I freeze the checkpoint files to "pb" proto. Referenced the website:https://blog.metaflow.fr/tensorflow-how-to-freeze-a-model-and-serve-it-with-a-python-api-d4f3596b3adc#.nxb8t2ylh
Next,I load graph from pb file,and predict with it .But, the result is different at each predict(for example:the same picture may got 1,1.04,1.2,1.3 these scores) , why? Did I miss save some variables?
Related
What I tried so far:
pre-train a model using unsupervised method in PyTorch, and save off the checkpoint file (using torch.save(state, filename))
convert the checkpoint file to onnx format (using torch.onnx.export)
convert the onnx to tensorflow saved model (using onnx-tf)
trying to load the variables in saved_model folder as checkpoint in my tensorflow training code (using tf.train.init_from_checkpoint) for fine-tuning
But now I am getting stuck at step 4 because I notice that variables.index and variables.data#1 files are basically empty (probably because of this: https://github.com/onnx/onnx-tensorflow/issues/994)
Also, specifically, if I try to use tf.train.NewCheckpointReader to load the files and call ckpt_reader.get_variable_to_shape_map(), _CHECKPOINTABLE_OBJECT_GRAPH is empty
Any suggestions/experience are appreciated :-)
I want to do very simple task. Let us assume that I have executed a model and saved multiple checkpoints and metada for this model using tf.estimator. We can again assume that I have 3 checkpoints. 1, 2 and 3. While I am evaluating the trained results on the tensorboard, I am realizing that checkpoint 2 is providing the better weights for my objective.
Therefore I want to load checkpoint 2 and make my predictions. What I want to ask simply is that, is it possible to delete checkpoint 3 from the model dir and let the estimator load it automatically from checkpoint 2 or is there anything I can do to load a specific checkpoint for.my predictions?
Thank you.
Yes, You can. By default, Estimator will load latest available checkpoint in model_dir. So you can either delete files manually, or specify checkpoint file with
warm_start = tf.estimator.WarmStartSettings(ckpt_to_initialize_from='file.ckpt')
and pass this to estimator
tf.estimator.Estimator(model_fn=model_fn,
config=run_config,
model_dir='dir',
warm_start_from=warm_start)
The latter option will not mess tensorboard summaries, so it's generally cleaner
I have checkpoint file from a resnet model.
resnet_v1_101.ckpt
Now, I need to find the number of layers in this checkpoint file and detailed information about the layers.
How can I do that in tensorflow?
A checkpoint file doesn't have graph information. Therefore, you cannot get detailed information about the layers. However, if you saved your model by tf.train.Saver().save(...) and you didn't specify write_meta_graph=False, you should have a file like "resnet_v1_101.ckpt.meta". That is the MetaGraphDef file. You can import it like this:
tf.train.import_meta_graph('./resnet_v1_101.ckpt.meta')
You can now visualize the graph in tensorboard or use your own way to get information about the graph.
I have trained a model with TensorFlow, and the training time cost me weeks. Now, I want to add new layer to the current model and continue training based on the trained weights. However, if I restore checkpoint an error like "xxx not found in checkpoint" will occur.
So how can I restore from checkpoint to a modified model in TensorFlow?
I have implemented the sequence to sequence model in Tensorflow for about 100,000 steps without specifying the summarizing operations required for TensorBoard.
I have the checkpoint log files for every 1000 steps. Is there any way to visualize the data without having to retrain the entire model i.e. extract the summaries from the checkpoint files to feed to TensorBoard?
I tried running TensorBoard directly on the checkpoint files, which obviously said no scalar summaries found. I also tried inserting the summary operations in code but it requires me to completely retrain the model for the summaries to get created.