In machine learning, hyperparameter optimization or tuning is the problem of choosing a set of optimal hyperparameters for a learning algorithm. A hyperparameter is a parameter whose value is used to control the learning process. By contrast, the values of other parameters (typically node weights) are learned.
The same kind of machine learning model can require different constraints, weights or learning rates to generalize different data patterns. These measures are called hyperparameters, and have to be tuned so that the model can optimally solve the machine learning problem.
So, instead of manually tuning our Hyperparameters, We are giving this job to Jenkins for Automation.
- Git and Github- for version control and hosting our repository.
- Jenkins- to automate various jobs.
- Rhel8- as a base os for running services like httpd, jenkins,ngrok.
- Docker- to run our python model.
I am using Fashion MNIST dataset for my deep learning model. Fashion-MNIST is a dataset of Zalando’s article images — consisting of a training set of 60,000 examples and a test set of 10,000 examples. Each example is a 28×28 grayscale image, associated with a label from 10 classes.
Steps For Automation-
- Create a container image that’s has Python3 ,Keras ,numpy and all the required libraries installed using dockerfile
- When we launch this image, it should automatically starts train the model in the container.
- Create a job chain of job1, job2, job3, job4 and job5 using build pipeline plugin in Jenkins
- Job1 : Pull the Github repo automatically when some developers push repo to Github.
- Job2 : By looking at the code or program file, Jenkins should automatically start the respective machine learning software installed, Interpreter install image container to deploy code and start training( eg. If code uses CNN, then Jenkins should start the container that has already installed all the softwares required for the cnn processing).
- Job3 : Display the Accuracy in webbrowser (locally connected)
- Job4 : if metrics accuracy is less than 88% , then tweak the machine learning model architecture.
- Job5: Retrain the model or notify that the best model is being created.
- Job6: Will notify the developer that tweaking is started as model accuracy is less than required.
- Create One extra job job7 for monitor : If container where app is running. fails due to any reason then this job should automatically start the container again from where the last trained model left
Lets Begin The Work-
- Setting our local git repository-
First, I have created an empty Github repository named MachineLearning_Automation. Then by using the basic git commands i have uploaded my codes to that Repo.
I have configured a post-commit script which will automatically push my code whenever I commit any new change.
- To do this you have to go to your code folder where you have set your .git
- then using [$cd /.git/hooks ] go to the hooks directory
- then using [$cat > post-commit] create a script that will push your code when you commit
- in post-commit write what’s in the image below and press ctrl+d to save it.
- then goto your main code folder and try to commit
2. Setting Tunnel for private ip in Rhel-
We have to set web-hooks in Github repo in Step-3, I am using private ip but Github is on Public World and Github needs access to our private ip on which Jenkins is running. Here comes the concept of Tunnel which will help us.
We set up ngrok software for the port and protocol Jenkins is running. In my case Jenkins is running on port 8080 and using http protocol. Use command-
]#./ngrok http 8080
We will use this ip provided by ngrok in setting up our web-hooks in Github repo.
3. Setting Web-hooks in Github Repo-
We will be needing web-hooks for our Jenkis JOB1 which will detect any change in the Github repo and send it to our Rehl Os at the specified location
- To set Web-hooks we have to go to our git hub repository and then
->Settings ->in Options ->Webhooks ->Add Webhook ->Enter your password ->In payload url enter [ngrok_ip/github-webhook/] ->Change Content type to [application/json] ->then Save the Webhook
4. Create JOB1 in Jenkins-
JOB1 will automatically pull the Github repo to a specified directory in our Rhel Os whenever developer pushes any new code.
If everything work perfectly then we will have –
5. Creation Our Own Docker Image-
To run our ML code named machinelearning_code.py in Docker container we have to create our own Docker Image with Centos as the base and all the required libraries and python36 installed within it.
- To create Docker image first create a new folder named ws using-
]# mkdir ws/
- Then create a docker file in ws directory using
- in Dockerfile write-
- after saving docker file come to parent directory
- run command to create image-
]#docker build -t machinelearning:v1 /root/Desktop/ml-automation /ws/
- after build completion we will see –
6. Creating JOB2 in Jenkins-
JOB2 has a task By looking at the code or program file, automatically start the respective machine learning software installed, Interpreter install image container to deploy code and start training( eg. If code uses CNN, then Jenkins should start the container that has already installed all the softwares required for the cnn processing) ie Run Docker Container from the Docker Image created in *Step 5*.
- you can see checking.py from here –checking.py
- After successful build of JOB2, Console output must be like this-
7. Creating JOB3 in Jenkins-
JOB3 has a task to copy the [show_output.html] file from Parent Directory to /var/www/html which is the default directory for webpages in Apache Webserver.
This [show_output.html] file will show us The hyperparameters used and the Accuracy of our model.
- Before going in Jenkins run following command to start httpd server in rhel-
]#systemctl start httpd
- JOB3 configurations-
Set Build Triggers to ->Build after other Projects are build->put JOB2 in it. After that do –
- After successful build of JOB3, We can see show_output.html file in our local web-browser.
8. Creating JOB4 in Jenkins-
JOB4 will monitor the accuracy of Model and if the accuracy of model is less then 98%. It will launch the tweaker.py program which will add extra Convolution Layers and Run JOB2 again to train model and JOB6 to send Email to the Developer “That accuracy is low, Running the Tweaker program”.
And if the Model Acheived required accuracy JOB5 will run as JOB4 will get terminated by [exit 0] command.
- JOB4 configuration-
- as JOB4 will run again and again until desired accuracy is not acheived, Our show_display.html file will also get changed by JOB3 and will show different accuracies and hyperparameters from each run of JOB2 model.
9. Creating JOB5 in Jenkins-
After getting the desired accuracy from JOB2 model, JOB4 will get terminated and JOB5 will run. This job will run model_success_mail.py and send the notification of PROJECT COMPLETION to the developer.
- JOB5 configurations-
- Python file to send email, edit this code in Rhel using gedit and put your own Credentials in this-
10. Creating JOB6 in Jenkins-
when JOB2 model does not acheived the desired accuracy, Then JOB4 will run JOB2 and JOB6. JOB6 will send the message of unsuccess and running the tweaking code by running model_lessaccuracy_mail.py.
- JOB6 configurations-
- Python code for this-
11. Creating JOB7 in Jenkins-
JOB7 will run Every Hour and check If Container where model is running, Fails due to any reason then this job should automatically start the container again from where the last trained model left.
- Configuring Poll SCM schedule for one hour-
- Execute shell command-
- console output if container is running fine-
Voila!!!! That’s how you can automate machine learning model using jenkins.
GITHUB REPO- https://github.com/Harasis/MachineLearning_Automation
Original post: https://medium.com/analytics-vidhya/automation-of-deep-learning-model-using-jenkins-79c2e732445b
41 comentários em “Automation of Deep Learning Model using Jenkins”
I’m the manager of JustCBD Store brand (justcbdstore.com) and I am currently looking to expand my wholesale side of business. I am hoping someone at targetdomain share some guidance 🙂 I considered that the most ideal way to accomplish this would be to talk to vape companies and cbd retailers. I was really hoping if anyone could recommend a reliable site where I can buy Vape Shop B2B Sales Leads I am presently taking a look at creativebeartech.com, theeliquidboutique.co.uk and wowitloveithaveit.com. Not sure which one would be the most suitable solution and would appreciate any assistance on this. Or would it be much simpler for me to scrape my own leads? Suggestions?
I am the co-founder of JustCBD Store company (justcbdstore.com) and I am currently aiming to broaden my wholesale side of business. I am hoping anybody at targetdomain can help me . I thought that the best way to accomplish this would be to reach out to vape stores and cbd retailers. I was hoping if anyone could recommend a reputable site where I can buy Vape Shop Business Sales Leads I am currently taking a look at creativebeartech.com, theeliquidboutique.co.uk and wowitloveithaveit.com. On the fence which one would be the very best option and would appreciate any assistance on this. Or would it be simpler for me to scrape my own leads? Ideas?
Hello there, I do believe your blog could possibly be having internet browser compatibility issues. When I look at your blog in Safari, it looks fine however, if opening in Internet Explorer, it’s got some overlapping issues. I just wanted to give you a quick heads up! Besides that, wonderful blog!
Right here is the right site for everyone who hopes to understand this topic. You realize a whole lot its almost tough to argue with you (not that I really would want to…HaHa). You certainly put a brand new spin on a topic that has been written about for many years. Great stuff, just excellent!
After looking at a handful of the articles on your web site, I seriously appreciate your technique of blogging. I saved it to my bookmark website list and will be checking back in the near future. Take a look at my website too and tell me how you feel.
Pretty! This was a really wonderful post. Many thanks for supplying this information.
It’s hard to come by well-informed people in this particular topic, however, you seem like you know what you’re talking about! Thanks
It’s difficult to find well-informed people on this topic, however, you seem like you know what you’re talking about! Thanks
An outstanding share! I have just forwarded this onto a coworker who has been conducting a little homework on this. And he actually ordered me breakfast simply because I found it for him… lol. So allow me to reword this…. Thanks for the meal!! But yeah, thanks for spending the time to talk about this subject here on your internet site.
Everything is very open with a precise explanation of the issues. It was really informative. Your site is extremely helpful. Thanks for sharing!
I simply want to tell you that I’m all new to weblog and seriously savored you’re web page. Very likely I’m want to bookmark your site . You certainly come with impressive articles. With thanks for revealing your website page.
Does your site have a contact page? I’m
having problems locating it but, I’d like to shoot you an email.
I’ve got some creative ideas for your blog you might be interested
in hearing. Either way, great blog and I look forward to seeing it develop over
It’s nearly impossible to find educated people about this subject, but you sound like you know what you’re talking about! Thanks
I’m amazed, I have to admit. Seldom do I come across a blog that’s both equally educative and interesting, and let me tell you, you have hit the nail on the head. The issue is something that too few men and women are speaking intelligently about. Now i’m very happy I found this in my search for something concerning this.
Hi, I do believe your site could possibly be having browser compatibility problems. When I take a look at your site in Safari, it looks fine but when opening in IE, it’s got some overlapping issues. I just wanted to give you a quick heads up! Other than that, great website!
Greetings! Very useful advice within this post! It’s the little changes that produce the largest changes. Many thanks for sharing!
Achieving your fitness goal does not have to require a certified personal trainer or an expensive gym memberships, especially if you have the budget and the space to consider practically every workout machine on the market.
The very next time I read a blog, I hope that it doesn’t fail me as much as this one. After all, Yes, it was my choice to read, but I actually believed you’d have something interesting to talk about. All I hear is a bunch of moaning about something that you could fix if you were not too busy looking for attention.
You’ve made some decent points there. I checked on the net for additional information about the issue and found most individuals will go along with your views on this site.
Hi there! This post couldn’t be written any better! Looking at this article reminds me of my previous roommate! He continually kept preaching about this. I’ll forward this article to him. Pretty sure he’ll have a great read. Thank you for sharing!
Having read this I thought it was really enlightening. I appreciate you finding the time and effort to put this information together. I once again find myself personally spending a significant amount of time both reading and leaving comments. But so what, it was still worth it!
This is a topic that’s near to my heart… Best wishes! Where are your contact details though?
You’ve made some really good points there. I checked on the net to learn more about the issue and found most individuals will go along with your views on this website.
I was extremely pleased to uncover this page. I want to to thank you for your time due to this fantastic read!! I definitely appreciated every little bit of it and i also have you book marked to check out new information in your site.
Good post. I learn something new and challenging on blogs I stumbleupon every day. It’s always helpful to read through articles from other writers and use a little something from other websites.
You made some really good points there. I checked on the net for more info about the issue and found most individuals will go along with your views on this web site.
Great article! We are linking to this particularly great post on our site. Keep up the good writing.
There is definately a lot to learn about this issue. I like all the points you’ve made.
This web site really has all the info I wanted about this subject and didn’t know who to ask.
I blog quite often and I truly appreciate your information. Your article has truly peaked my interest. I am going to bookmark your site and keep checking for new information about once a week. I opted in for your Feed too.
This is the right blog for anybody who wishes to understand this topic. You understand a whole lot its almost tough to argue with you (not that I actually will need to…HaHa). You certainly put a brand new spin on a subject that’s been discussed for years. Wonderful stuff, just wonderful!
This is the perfect website for anyone who wishes to find out about this topic. You know a whole lot its almost tough to argue with you (not that I really would want to…HaHa). You definitely put a fresh spin on a subject which has been discussed for many years. Excellent stuff, just excellent!
Hello every one, here every one is sharing such familiarity, therefore it’s fastidious to read this weblog, and I used to visit
this website everyday.
Hello to every body, it’s my first pay a quick visit of this blog;
this weblog carries amazing and truly good stuff for visitors.
Hey there! Quick question that’s completely off
topic. Do you know how to make your site mobile friendly?
My weblog looks weird when viewing from my apple iphone.
I’m trying to find a template or plugin that might be able to resolve this
issue. If you have any recommendations, please
share. Many thanks!
Hi Dear, are you genuinely visiting this web site on a regular basis, if so afterward you will absolutely get fastidious experience.
Have you ever thought about including a little bit more than just your articles?
I mean, what you say is important and all. Nevertheless imagine if you added some great visuals or videos to give your posts more, “pop”!
Your content is excellent but with pics and video clips, this blog could definitely
be one of the best in its field. Very good blog!
Simply desire to say your article is as astonishing.
The clearness for your publish is simply
cool and that i could assume you’re a professional on this subject.
Fine with your permission allow me to seize your RSS
feed to keep updated with impending post. Thanks one million and please carry
on the enjoyable work.
bookmarked!!, I love your web site!
Greetings from Carolina! I’m bored at work so I decided to
check out your website on my iphone during lunch break.
I really like the information you provide here and can’t wait to take a look when I get home.
I’m shocked at how quick your blog loaded on my mobile ..
I’m not even using WIFI, just 3G .. Anyhow, awesome site!
It’s in reality a great and useful piece of info.
I’m happy that you just shared this helpful info with us.
Please keep us informed like this. Thanks for sharing.