TensorFlow2.0-Examples icon indicating copy to clipboard operation
TensorFlow2.0-Examples copied to clipboard

How to save the model file in yolov3 project.

Open jasonhai18 opened this issue 6 years ago • 2 comments

I just write one line: model.save("./yolov3") in for epoch in range(cfg.TRAIN.EPOCHS): for image_data, target in trainset: train_step(image_data, target, epoch) for image_data, target in valset: validate_step(image_data, target, epoch) model.save_weights("./yolov3") model.save("./yolov3")

without any sess.run saver.save?

jasonhai18 avatar Nov 16 '19 06:11 jasonhai18

In Tensorflow 2.0, you can simply save whole model like keras API by using

model.save('mymodel.h5').

For example;

`

Create and train a new model instance.

model = create_model() model.fit(train_images, train_labels, epochs=5)

Save the entire model to a HDF5 file.

The '.h5' extension indicates that the model shuold be saved to HDF5.

model.save('my_model.h5')

Recreate the exact same model, including its weights and the optimizer

new_model = tf.keras.models.load_model('my_model.h5')

Show the model architecture

new_model.summary() `

Check Tensorlfow 2.o tutorial for details: https://www.tensorflow.org/tutorials/keras/save_and_load

rashidch avatar Nov 19 '19 14:11 rashidch

in this code i can not save .h5 only save ckpt why?

pp1bb avatar Jun 04 '20 06:06 pp1bb