TensorFlow Tutorial 10 - Saving and Loading Models

แชร์
ฝัง
  • เผยแพร่เมื่อ 4 ธ.ค. 2024

ความคิดเห็น • 37

  • @AladdinPersson
    @AladdinPersson  4 ปีที่แล้ว +11

    I was inspired and learned the basics of TensorFlow after I completed the TensorFlow specialization on coursera. Personally I think these videos I created give a similar understanding but if you wanna check it out you can. Below you'll find both affiliate and non-affiliate links, the pricing for you is the same but a small commission goes back to the channel if you buy it through the affiliate link which helps me create more future videos.
    affiliate: bit.ly/3JyvdVK
    non-affiliate: bit.ly/3qtrK39
    One thing I did not mention in this video is using callbacks to save the model during training. This is because I'm going to make a completely separate video for callbacks which has a lot of different features and saving the model with some frequency (like every epoch or so) is just one of many. Anyways if you're interested to check it out before I make a video on it you can check out the docs here: www.tensorflow.org/api_docs/python/tf/keras/callbacks/ModelCheckpoint

  • @mortenrobinson5421
    @mortenrobinson5421 3 ปีที่แล้ว

    Great! Now I can do during loooong training sessions and terminate the process from time to time without worrying that I lose everything. I can just pick it up where I left it.

  • @jongcheulkim7284
    @jongcheulkim7284 3 ปีที่แล้ว

    Thank you so much. This is very helpful.

  • @zaurr.2622
    @zaurr.2622 4 ปีที่แล้ว +2

    Thank you for great video. I switched to PyTorch after working with tf/keras for a while. My problem was that it was impossible or very hard to save and load models with custom losses. It was a pain even in tf2.0 as 9 out 10 times a model would not load. Not sure if things have changed. A video on that topic (saving/loading with custom losses) would be very useful. Thanks again!

    • @zaurr.2622
      @zaurr.2622 4 ปีที่แล้ว +1

      To add: having a keras layer with lamba function would also prevent a model from being loaded, even though it was training and saving just fine.

    • @AladdinPersson
      @AladdinPersson  4 ปีที่แล้ว +2

      I'll look into that, right now I have never worked with custom losses in TensorFlow

    • @zaurr.2622
      @zaurr.2622 4 ปีที่แล้ว

      Aladdin Persson thank you!

  • @riis08
    @riis08 4 ปีที่แล้ว +1

    @Aladdin Persson: thanks again for these contents..... suggestion for future videos, tf.data, callbacks, serving etc.

    • @AladdinPersson
      @AladdinPersson  4 ปีที่แล้ว +1

      Thank you for the suggestions, I have plans to cover tf.data, callbacks but I'm not too familiar with TF Serving. Will look into that

  • @dawi9840
    @dawi9840 3 ปีที่แล้ว +1

    Thanks for teaching. I want to use the weights to Android Studio, but I have no idea about how to use the ".pb" or ".tflite" models weights to be use in Android Studio details. Would you like to share about this part ? That helps me a lot. :D

  • @jamesang7861
    @jamesang7861 3 ปีที่แล้ว

    What's the difference between model.save_weights and tf.train.checkpoint? When do we use which?

  • @amitsaurabh9948
    @amitsaurabh9948 4 ปีที่แล้ว +2

    Can you please make videos on the remaining ML solutions for Machine Learning with Andrew Course.

    • @AladdinPersson
      @AladdinPersson  4 ปีที่แล้ว

      My love for that course is strong and is one of the best courses I've ever taken but I don't really have time to do that for now. If it helps I do have a Github repository with solutions to the others assignments that you could read if you get stuck: github.com/AladdinPerzon/Courses/tree/master/MOOCS/Coursera-Machine-Learning

    • @amitsaurabh9948
      @amitsaurabh9948 4 ปีที่แล้ว

      @@AladdinPersson It's ok. Thanks mate

  • @PaulAcademy
    @PaulAcademy 3 ปีที่แล้ว

    So helpful video. How can I convert the subclass model into TF-Lite? Can you please help me out? Thanks in advance.

  • @jadejamig4112
    @jadejamig4112 3 ปีที่แล้ว +1

    If you load a model and trained it again, will it start its training from 0 again or will it retain its previous training state

    • @naimshant7129
      @naimshant7129 3 ปีที่แล้ว +1

      if it starts from 0, what's the need of saving of saving the model.
      Of course, it's going to retain its previous weights

  • @badar847
    @badar847 4 หลายเดือนก่อน

    model.save() without an extension no longer works. You have to use a .keras or .h5 extension I believe

  • @benvoland
    @benvoland 4 ปีที่แล้ว +5

    For some reason, after loading the model and trying to make a test, the accuracy of the second test is a lot lower. For example, the test with the before saved model i got acc of 75% but after testing the loaded model the acc was down to 25%. I will be glad if someone knows and would tell me what the heck is going on
    TY

    • @zaidmohammed5981
      @zaidmohammed5981 3 ปีที่แล้ว

      I have the same problem, got an accuracy of 98% before saving the model but it dropped to 36% after loading it.

    • @kanzapervaiz6572
      @kanzapervaiz6572 3 ปีที่แล้ว

      I am having the same issue,did you guys find any solution

    • @run4ever102
      @run4ever102 2 ปีที่แล้ว

      This is due to overfitting, model is trained enough so don’t bother retraining!

  • @knowledgeengr4005
    @knowledgeengr4005 4 ปีที่แล้ว +1

    I am using sub-classes functional API for my deep learning model. I have saved the model successfully but when reload the same it asks for configuration which was not saved and also unable to predict_classes. How can i define these 2 methods in my Python BiLSTM based class.

  • @anonemoose102
    @anonemoose102 3 ปีที่แล้ว

    Do you have a tutorial on your pycharm setup

  • @fauzisafina1827
    @fauzisafina1827 4 ปีที่แล้ว +1

    Sir, if we have saved the model as described above, how can we convert it to the TensorflowLite model so that it can be used in Android Studio, I have tried but using the Tensorflow Model Maker. I want to know how to be able to convert from saveModel to .tflite

    • @AladdinPersson
      @AladdinPersson  4 ปีที่แล้ว +1

      I haven't studied this yet so I'm not sure, have you read this article: www.tensorflow.org/lite/convert

  • @라봉한-h8f
    @라봉한-h8f 2 ปีที่แล้ว

    in the part defining MyModel. in self.dense1 there's already activation='relu'. but why we have to use tf.nn.relu in call function again?
    isn't it going through relu two times?

  • @hossamalzomor3311
    @hossamalzomor3311 3 ปีที่แล้ว

    Is it possible to save the model with different name?

  • @jerijeesalhassan5643
    @jerijeesalhassan5643 3 ปีที่แล้ว

    please i am working on NMT with attention using tensorflow , i want to save the model and the entire architecture into my google drive , i am using colab notebook.

  • @anonemoose102
    @anonemoose102 3 ปีที่แล้ว

    Im getting this error. Unable to restore custom object of type _tf_keras_metric currently. Please make sure that the layer implements `get_config`and `from_config` when saving. In addition, please use the `custom_objects` arg when calling `load_model()`.

  • @furqanahmed2339
    @furqanahmed2339 4 หลายเดือนก่อน

    model.save_weights('saved_model/Sequential_API_Weights') any can guide why am i receiving an error when i try it this way. The rest of the code is same. The error says to use .h5 file and i just dont want to because i this gives me headaches of not being able to find recourses online to get my weights from .h5 format.

    • @jyothysankar7560
      @jyothysankar7560 หลายเดือนก่อน

      Did you get it? I havr the same issue

    • @furqanahmed2339
      @furqanahmed2339 หลายเดือนก่อน

      @@jyothysankar7560 it gives an error but still saves it and you can load separately. What I have noticed is that using tensorflow in python gives a lot of errors but the code runs either way.

  • @kanzapervaiz6572
    @kanzapervaiz6572 3 ปีที่แล้ว

    how to use designed neural network in another code for prediction, can anyone please help or any example?

    • @hananxh
      @hananxh 3 ปีที่แล้ว

      are u refering to tranfer learning?

    • @kanzapervaiz6572
      @kanzapervaiz6572 3 ปีที่แล้ว

      No when I reload my neural network to another python code just by load.model command,the accuracy decreases of the same model

  • @ArunKumar-sg6jf
    @ArunKumar-sg6jf 4 ปีที่แล้ว +1

    🔥🔥🔥