TensorFlow Tutorial 10 - Saving and Loading Models

Поділитися
Вставка
  • Опубліковано 24 гру 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!

  • @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

  • @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

  • @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.

  • @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.

  • @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

  • @jamesang7861
    @jamesang7861 3 роки тому

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

  • @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

  • @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 3 роки тому

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

  • @anonemoose102
    @anonemoose102 4 роки тому

    Do you have a tutorial on your pycharm setup

  • @badar847
    @badar847 4 місяці тому

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

  • @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.

  • @hossamalzomor3311
    @hossamalzomor3311 3 роки тому

    Is it possible to save the model with different name?

  • @라봉한-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?

  • @furqanahmed2339
    @furqanahmed2339 5 місяців тому

    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 2 місяці тому

      Did you get it? I havr the same issue

    • @furqanahmed2339
      @furqanahmed2339 2 місяці тому

      @@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.

  • @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()`.

  • @ArunKumar-sg6jf
    @ArunKumar-sg6jf 4 роки тому +1

    🔥🔥🔥

  • @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