adanet icon indicating copy to clipboard operation
adanet copied to clipboard

How to import the saved/trained model to test on a testing dataset?

Open Smallyolk2024 opened this issue 6 years ago • 6 comments

Hi, @cweill I have trained a model on my datasets with NASNet-A as the subnetwork, and have saved some checkpoints. If I want to import the saved model (model.ckpt**) again to test on a testing dataset, what should I do?

Smallyolk2024 avatar Mar 18 '19 05:03 Smallyolk2024

@SmallyolkLiu: Did you find the answer to your original question?

cweill avatar Mar 19 '19 15:03 cweill

@cweill Not yet, I have an more interesting issue instead, that is , if the program suddenly breaks down, how to rerun it based on the saved results previously? For the case of NASNet as a subnetwork, many many training steps (hundreds of thousands) are necessary, it will a problem in the absence of an effective solution to multi-GPU training.

Smallyolk2024 avatar Mar 21 '19 12:03 Smallyolk2024

If you want to use the latest checkpoint, just recreate the same adanet.Estimator with the same model_dir. When you call Estimator#predict it will load the variables from the latest checkpoint.

If you want to load a previous checkpoint, there is a checkpoint file created automatically in your model_dir.

It should look something like:

model_checkpoint_path: "model.ckpt-400000"
all_model_checkpoint_paths: "model.ckpt-270000"
all_model_checkpoint_paths: "model.ckpt-280000"
all_model_checkpoint_paths: "model.ckpt-290000"
all_model_checkpoint_paths: "increment.ckpt-3"
all_model_checkpoint_paths: "model.ckpt-300000"
all_model_checkpoint_paths: "model.ckpt-310000"
all_model_checkpoint_paths: "model.ckpt-320000"
all_model_checkpoint_paths: "model.ckpt-330000"
all_model_checkpoint_paths: "model.ckpt-340000"
all_model_checkpoint_paths: "model.ckpt-350000"
all_model_checkpoint_paths: "model.ckpt-360000"
all_model_checkpoint_paths: "model.ckpt-370000"
all_model_checkpoint_paths: "model.ckpt-380000"
all_model_checkpoint_paths: "model.ckpt-390000"
all_model_checkpoint_paths: "model.ckpt-400000"

Just update model_checkpoint_path to point to the checkpoint you want the Estimator to read and continue from.

cweill avatar Mar 21 '19 17:03 cweill

@cweill Thanks.

Smallyolk2024 avatar Mar 22 '19 09:03 Smallyolk2024

My problem is not mainly loading the estimator, actually it is creating it properly and using it I tried to do what is suggested here https://github.com/tensorflow/adanet/issues/22#issuecomment-437567652, but my generator is empty. Can you please explain this the correct approach to make prediction on test data in the tutorial, that will help alot? Big thanks

AAbusnina avatar Mar 22 '19 13:03 AAbusnina

May be it is simpler if you can tell how to load a saved model?

AAbusnina avatar Mar 22 '19 16:03 AAbusnina