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 and Load a Trained Model #20

Closed
Thilakraj1998 opened this issue Sep 29, 2021 · 3 comments
Closed

Save and Load a Trained Model #20

Thilakraj1998 opened this issue Sep 29, 2021 · 3 comments
Assignees
Labels
enhancement New feature or request good first issue Good for newcomers Hacktoberfest For participants in Hacktoberfest

Comments

@Thilakraj1998
Copy link
Contributor

Thilakraj1998 commented Sep 29, 2021

Add functionality to save and load a trained model by using pickle or Keras function for appropriate model type, i.e. either Sci-kit learn model or Tensorflow model .

file to refer : https://github.com/blobcity/autoai/blob/main/blobcity/store/Model.py

Add function save and load in the Model.py file
Required functionality for save function:

  1. takes single string argument, which is path to save model, along with filename for example:

         save("path/filename")   
    
  2. If path not specified in argument, utilize default path and default name to save in working directory. And print/log of absolute path for the file.

  3. identify type of model saving strategy to use, i.e. whether use pickle or Keras to save model.

Required functionality for load function:

  1. takes single string argument, which is path of saved model file:

          load("path/filename.pkl")   or  load("path/filename.h5") 
    
  2. on the basis of file extension use appropriate loading strategy either pickle or Keras load functions

  3. return the model.

@Thilakraj1998 Thilakraj1998 added enhancement New feature or request good first issue Good for newcomers Hacktoberfest For participants in Hacktoberfest labels Sep 29, 2021
@Thilakraj1998 Thilakraj1998 self-assigned this Sep 29, 2021
@sreyan-ghosh
Copy link
Contributor

sreyan-ghosh commented Sep 29, 2021

Hi, can you assign this to me, please?

I'm hoping a simple pickle.dumps('my_model.pkl') does the job. The final addition would look something like this:

def save(self, path_pref='./'):
  final_path = os.path.join(path_pref, 'my_model.pkl')
  pickle.dump(self.model, open(final_path, 'wb'))
  # print(final_path)
  return final_path

Is this fine?

sreyan-ghosh added a commit to sreyan-ghosh/autoai that referenced this issue Sep 29, 2021
@sanketsarang sanketsarang changed the title Model Save Save and Load a Trained Model Sep 29, 2021
@aadityasinha-dotcom
Copy link
Contributor

Can I work on this issue?

@sreyan-ghosh
Copy link
Contributor

sreyan-ghosh commented Sep 29, 2021

Hi, I have updated my fork of this repo as per the changes made to the issue. I have done it using pickle and h5 files and also included type checking for Keras models in the case of .h5 files.

Also, a doubt, I don't see TensorFlow or Keras in the requirements.txt so how do we load the .h5 file? Should I add TensorFlow to the requirements.txt file?

sreyan-ghosh added a commit to sreyan-ghosh/autoai that referenced this issue Sep 29, 2021
Thilakraj1998 added a commit that referenced this issue Oct 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers Hacktoberfest For participants in Hacktoberfest
Projects
None yet
Development

No branches or pull requests

3 participants