Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

save weight of the model #35

Open
Hochinghao opened this issue May 24, 2021 · 4 comments
Open

save weight of the model #35

Hochinghao opened this issue May 24, 2021 · 4 comments

Comments

@Hochinghao
Copy link

is there anyway to save the trained model?

@sajed-zarrinpour
Copy link

I think this article will help you out.
https://www.tensorflow.org/tutorials/keras/save_and_load

@Hochinghao
Copy link
Author

but it seens work for keras model but it is tensorflow model .

@sajed-zarrinpour
Copy link

I believe you can use the principle here. you can use a costume callback for the purpose as well. try tracing these variables: self.weights
self.biases
I think it will help.

@Mohamadrezash204
Copy link

Mohamadrezash204 commented Mar 4, 2024

is there anyway to save the trained model?

you can add this to model:

def save_model(self):
    saver = tf.train.Saver()
    save_path = "meltpool_model.ckpt"
    saver.save(self.sess, save_path)
    print(f"Model saved at {save_path}")

def load_model(self):
    saver = tf.train.Saver()
    save_path = "meltpool_model.ckpt"
    saver.restore(self.sess, save_path)
    print(f"Model loaded from {save_path}")    

To save the model you should call save_model after training. and when you want to use the saved model before the train call the load_model.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants