Tuning the Hyperparameter thus automating Deep Learning model
Original Source Here
Tuning the Hyperparameter thus automating Deep Learning model
ML model to train ML model… sounds cool..?
Introduction
This is the era where every Computer Science Student is looking forward to be a Data Scientist. Their job heavily involves using the data to make predictions. But there is a lot of manual things which needs to be done like hyperparamater tuning. So why not just automate it?
This blog contains automation of hyperparameter tuning using python and devops idea.
What are Hyperparameters ?
Hyperparameters are the variables which determines the network structure (Eg: Number of Hidden Units) and the variables which determine how the network is trained (Eg: Kernel Size). Hyperparameters are set before training (before optimizing the weights and bias).
Now Since we are aware with the objective of the main objective of the blog, let us continue.
Here the blog is divided into 5 separate jobs that will do the work for us, so let’s get started.
Job 1: Get the data from the GitHub Repository.
Whenever the developer pushes any code to GitHub repository, with the help of GitHub plugin installed on Jenkins we will be able to monitor the changes in the repository and thus if any change is found we copy the code from remote to our local directory. The technique used is Poll SCM that keeps on monitoring the remote repository at every minute.
Job 2: Check the type of model and launch the appropriate container.
Using a python script, we will we check what type of model is to be trained and accordingly we will launch a container that has the requirements satisfied. Once the container is launched the model will be trained and we predict its accuracy. The accuracy predicted by the model will be saved in CSV file named as realrecords.csv with all the hyperparamaters provided initially by a input.txt file.
Job 3: Check the accuracy — predict new input parameters.
A python script named CheckAccuracy.py checks on the accuracy of the last trained model’s accuracy, if desired is attained then the model runs a python script name SuccessEmail.py and sends the Success Mail to the client. And if the desired accuracy is not attained then a container will be launched with Predict_Model_Test.py. On running this container, a pretrained model that I had created earlier on the dataset (generated by me) will be loaded and will predict the new hyperparameters with accuracy and these values will be stored a CSV file named labtest.csv. And when a accuracy comes greater than that of the accuracy given be the Deep Learning model then we give these parameters as an input to that Original model.
Job 4: Change the input parameters.
A python script reads the last row from the labtest.csv file i.e. the new hyperparameters and thus changes the content of input.txt file.
Job 5: Push the input file.
When all the above jobs are built successfully the input.txt file is pushed to remote repository.
As soon as the change in some file is detected at the GitHub repo by Jenkins it again copies the files to local repo and all the process from job 1 repeats in a loop till the desired accuracy is achieved. The loop will break when no change is observed in input.txt file.
So, basically an ML model is being used to train another ML model.
Thank you guys for reading this post.
GitHub Link for the above codes: https://github.com/a19singh/MlopsTrain
AI/ML
Trending AI/ML Article Identified & Digested via Granola by Ramsey Elbasheer; a Machine-Driven RSS Bot
via WordPress https://ramseyelbasheer.io/2021/05/31/tuning-the-hyperparameter-thus-automating-deep-learning-model/