Internet of Things Optimization

Siraj Raval · Intermediate ·🎮 Reinforcement Learning ·7y ago

Key Takeaways

The video discusses optimizing electricity consumption in smart homes using reinforcement learning and Monte Carlo methods, with applications in Internet of Things (IoT) devices and smart homes. It covers Markov decision processes, Monte Carlo tree search, and model-free techniques for learning optimal policies.

Full Transcript

hello world it's Suraj and the internet-of-things it's definitely a buzzword these days but it's a real thing and I'll demonstrate how to use reinforcement learning to optimize electricity consumption amongst multiple devices in a smart home mark and driessen's quote that software is eating the world still rings true today more and more devices are coming prepackaged with internet access that wouldn't normally be that includes smart soul-shakers smart rectal thermometers smart mugs smart chairs the list goes on and because these devices have a connection to the world wide web they can communicate with the outside world and each other sharing information and even learning from one another this internet of physical things is becoming increasingly common across the globe whether it's a smart home a fleet of self-driving cars or a pipeline of assets as they are shipped across the globe having a web of interconnected physical devices has a huge range of use cases in our modern world for businesses and consumers but a major concern regarding these devices is the amount of energy they'll need to consume silicon chips need electricity and the more devices we have the higher our energy cost will be it turns out that we can use reinforcement learning to create a system that will minimize our electricity costs substantially this can apply to a whole range of industries where an interconnected system of devices is required to perform a task agriculture manufacturing and even a personal home which will be our demo google recently used RL to reduce the amount of energy they used in their data center by up to 40 percent just like a laptop generates Heat their massive racks of servers generate a lot of heat but too much heat can damage the servers so a cooling system is necessary to help maintain a certain temperature and because it's such a dynamic environment a learning system is required to set that temperature a whole host of unforeseen scenarios like changes in weather and power outages can occur also humans interact with the equipment in unexpected ways regularly probably doing the floss dance on them and each data center has a unique architecture and environment so their system needed to be able to adapt to multiple unique environments last week we introduced the fundamental way of framing the reinforcement learning problem where an agent is interacting with an environment to maximize a reward the Markov decision process the goal of an agent is to learn a policy so it knows given a state the best action to take in order to maximize a reward and in a complete Markov decision process where all of the environment variables are known we can use dynamic programming to learn an optimal policy but what if we don't know all the environment variables beforehand give up no then it'd be considered not model-based RL but model free RL in model free RL the first variable we miss is a transition model so we won't know what's going to happen after each action we take beforehand this tells us the probabilities associated with various state changes the second thing we miss is the reward function which gives the agent the reward associated with a particular state beforehand so when we don't know either of these Markovian variables dynamic programming won't work we need to instead use a different type of method called Monte Carlo Monte Carlo methods are a broad class of algorithms that rely on repeated random sampling to obtain numerical results the key word here is random Monte Carlo methods make use of randomness to solve problems which turns out to be very useful in mathematics and physics Stanislaw ulam invented it in the late 1940s while working on a nuclear bomb as part of the Manhattan Project then john von neumann decided he liked it and programmed a machine to do those same calculations they decided to name the codebase Monte Carlo as every super-secret project should be named Coulomb's uncle happened to be losing lots of money in the monte carlo casino in Monaco so that's why uncle's in fact deep mines alphago used what's called a Monte Carlo tree search to help it play against the reigning go champion resulting in move thirty seven more on that at the end of the course Monte Carlo techniques have several advantages over dynamic programming first they allow for learning optimal behavior directly from interaction with the environment without needing the transition or reward function defined beforehand second it's easy and computationally efficient to focus MC methods on a small subset of the total states and third MC can be used with simulations so let's say we have a home that consists of a bunch of Internet of Things devices we've got a smart TV a smart fridge a smart dog and a smart giant server in our room all of this equipment requires a lot of electricity to run but it also requires cooling or else my room would get too hot so I have a cooling system now let's say that we have access to our electricity usage logs thanks to partnering with a data friendly provider and our smart thermostat can set a temperature accordingly depending on the type of system we build we can imagine electricity flowing into all of these devices creating a closed loop system and this constant stream of electricity data it can definitely be utilized it's giving us the electricity price cooling demand and electricity consumption as variables using this we can construct our Markov decision process the goal of our system is to minimize our electricity bills more money for GPUs lamelle our agent will perform an action in this environment that action will be to either increase or decrease the temperature by one degree Celsius my fellow Americans most of this audience uses the metric system the state then that our agent can be in will be a measure of both how much cooling demand there is as well as the price of electricity the reward can tell us whether we are saving money or not by switching states by calculating the total electricity consumption multiplied by the price of electricity and depending on if that's greater or less than what exists at the time step before we know whether or not that is a positive or negative reward there exists an optimal policy here such that if we were to give it a state in this case that would be the cooling demand and the electricity price it would know exactly what temperature the thermostat should be set at such that we are optimally saving money on electricity by cooling our room as much as necessary when necessary our adaptive real time reward based system needs to learn this optimal policy and since we don't know the reward function or the transition function beforehand we have to compute our rewards and transitions as they happen in real time we'll want to use a model free technique like Monte Carlo to learn the optimal policy the basic idea is to calculate the value function of each state backwards with the reward received after the end of the episode there has to be an ended then the task has to be considered an episodic task for us to use Monte Carlo in our case we can say that an episode lasts a full eight hours while I'm away at my office working diligently if we move from the initial state to the terminal state according to the given policy will receive a reward at each time step we'll remember all of those rewards and when we get to the terminal state will loop back and calculate the value function of each state in the case that there are multiple episodes then Monte Carlo just averages all of the returns we know that the return is the sum of the discounted reward in the context of Monte Carlo though we switch it up to obtain the state value function we take instead the expectation of the returns not the sum we can define a state s to be a discrete random variable which can assume all the stats with a certain probability every time our agent reaches a state it's like we are picking a value for the random variable s for each state of each episode we can calculate the return and store it in a list repeating this process a lot is guaranteed to converge on the true state value function in Monte Carlo RL we are estimating the value function for each state based on the return of each episode and the more episodes we take into account the more accurate or estimation will be notice though that a possible problem could occur what if we visit the same state twice in a single episode well there are actually two types of Monte Carlo policy evaluation first visit and every visit will focus on first visit in this video first visit only recognizes the first visited state every second visit does not count the return for that state visit and the return is calculated separately for each visit Monte Carlo includes randomness because when it updates every episode depending on where it originated from it's a different result depending on which action we take in the same state because it contains these random elements Monte Carlo has a high variance when we graph a simulation of our agent solving a problem we'll see that eventually the policy will converge and then our system will know exactly what temperature to set our room based on the electricity related variables there are different kinds of Monte Carlo techniques that can do all sorts of cool things but we'll talk about those later on three points to remember from this video in model free reinforcement learning as opposed to model based we don't know the reward function and the transition function beforehand we have to learn them through experience a model free learning technique called Monte Carlo uses repeated random sampling to obtain numerical results and in first visit Monte Carlo the state value function is defined as the average of the returns following the agent's first visit to s and set of episodes please subscribe for more programming videos and for now I've got to try a new sample so thanks for watching

Original Description

The Internet of things lives! More and more devices are coming prepackaged with internet access that wouldn’t normally be. That includes everything from smart salt shakers to smart tabletops. And because these devices have a connection to the world wide web, they can communicate with the outside world and each other, sharing information and even learning from one another. In this video, I'll explain how to use a reinforcement learning technique called "Monte Carlo" to optimize electricity consumption and cooling demands for a smart home. Enjoy! Code for this video: https://github.com/llSourcell/Internet_of_Things_Optimization Please Subscribe! And like. And comment. That's what keeps me going. Want more education? Connect with me here: Twitter: https://twitter.com/sirajraval Facebook: https://www.facebook.com/sirajology instagram: https://www.instagram.com/sirajraval The School of AI: https://www.theschool.ai Github Syllabus: https://github.com/llSourcell/Move_37_Syllabus More learning resources: https://www.kth.se/social/files/58b941d5f276542843812288/RL04-Monte-Carlo.pdf https://courses.cs.washington.edu/courses/csep573/12au/lectures/18-rl.pdf https://stat.ethz.ch/education/semesters/ss2016/seminar/files/slides/RL_MCM_heinzer_profumo.pdf https://medium.com/deep-math-machine-learning-ai/ch-12-1-model-free-reinforcement-learning-algorithms-monte-carlo-sarsa-q-learning-65267cb8d1b4 http://www-edlab.cs.umass.edu/cs689/lectures/RL%20Lecture%205.pdf https://github.com/dennybritz/reinforcement-learning/tree/master/MC Join us in the Wizards Slack channel: http://wizards.herokuapp.com/ And please support me on Patreon: https://www.patreon.com/user?u=3191693 #InternetOfThings #IOT #SirajRaval Signup for my newsletter for exciting updates in the field of AI: https://goo.gl/FZzJ5w Hiring? Need a Job? See our job board!: www.theschool.ai/jobs/ Need help on a project? See our consulting group: www.theschool.ai/consulting-group/ Hit the Join button above to sign up t
Watch on YouTube ↗ (saves to browser)
Sign in to unlock AI tutor explanation · ⚡30

Playlist

Uploads from Siraj Raval · Siraj Raval · 0 of 60

← Previous Next →
1 What is Bitcoin?
What is Bitcoin?
Siraj Raval
2 5 Ways to Use Bitcoin
5 Ways to Use Bitcoin
Siraj Raval
3 BTC Fever - Siraj [Music Video]
BTC Fever - Siraj [Music Video]
Siraj Raval
4 5 Reasons to Build Decentralized Apps
5 Reasons to Build Decentralized Apps
Siraj Raval
5 The Interplanetary File System
The Interplanetary File System
Siraj Raval
6 How to Build a Dapp in 3 min
How to Build a Dapp in 3 min
Siraj Raval
7 Life Before Smartphones
Life Before Smartphones
Siraj Raval
8 4 Ways to Use Smart Contracts
4 Ways to Use Smart Contracts
Siraj Raval
9 3 Dapps You HAVE to See
3 Dapps You HAVE to See
Siraj Raval
10 Char's Life as a BitTorrent Engineer
Char's Life as a BitTorrent Engineer
Siraj Raval
11 4 Reasons AlphaGo is a Huge Deal
4 Reasons AlphaGo is a Huge Deal
Siraj Raval
12 Build a Neural Net in 4 Minutes
Build a Neural Net in 4 Minutes
Siraj Raval
13 Sentiment Analysis in 4 Minutes
Sentiment Analysis in 4 Minutes
Siraj Raval
14 The Hackathon Life
The Hackathon Life
Siraj Raval
15 Your First ML App - Machine Learning for Hackers #1
Your First ML App - Machine Learning for Hackers #1
Siraj Raval
16 Build an AI Composer - Machine Learning for Hackers #2
Build an AI Composer - Machine Learning for Hackers #2
Siraj Raval
17 Build a Game AI - Machine Learning for Hackers #3
Build a Game AI - Machine Learning for Hackers #3
Siraj Raval
18 Build a Movie Recommender - Machine Learning for Hackers #4
Build a Movie Recommender - Machine Learning for Hackers #4
Siraj Raval
19 Build an AI Artist - Machine Learning for Hackers #5
Build an AI Artist - Machine Learning for Hackers #5
Siraj Raval
20 Build a Chatbot - ML for Hackers #6
Build a Chatbot - ML for Hackers #6
Siraj Raval
21 Build an AI Reader - Machine Learning for Hackers #7
Build an AI Reader - Machine Learning for Hackers #7
Siraj Raval
22 Build an AI Writer - Machine Learning for Hackers #8
Build an AI Writer - Machine Learning for Hackers #8
Siraj Raval
23 Build a Chatbot w/ an API - ML for Hackers #9
Build a Chatbot w/ an API - ML for Hackers #9
Siraj Raval
24 One-Shot Learning - Fresh Machine Learning #1
One-Shot Learning - Fresh Machine Learning #1
Siraj Raval
25 Generative Adversarial Nets - Fresh Machine Learning #2
Generative Adversarial Nets - Fresh Machine Learning #2
Siraj Raval
26 Tone Analysis - Fresh Machine Learning #3
Tone Analysis - Fresh Machine Learning #3
Siraj Raval
27 Generate Rap Lyrics - Fresh Machine Learning #4
Generate Rap Lyrics - Fresh Machine Learning #4
Siraj Raval
28 Build an Autoencoder in 5 Min - Fresh Machine Learning #5
Build an Autoencoder in 5 Min - Fresh Machine Learning #5
Siraj Raval
29 Build a Self Driving Car in 5 Min - Fresh Machine Learning #6
Build a Self Driving Car in 5 Min - Fresh Machine Learning #6
Siraj Raval
30 Build an Antivirus in 5 Min - Fresh Machine Learning #7
Build an Antivirus in 5 Min - Fresh Machine Learning #7
Siraj Raval
31 TensorFlow in 5 Minutes (tutorial)
TensorFlow in 5 Minutes (tutorial)
Siraj Raval
32 Build a Recurrent Neural Net in 5 Min
Build a Recurrent Neural Net in 5 Min
Siraj Raval
33 Build a Simulation in 5 Min
Build a Simulation in 5 Min
Siraj Raval
34 Build a TensorFlow Image Classifier in 5 Min
Build a TensorFlow Image Classifier in 5 Min
Siraj Raval
35 Tensorboard Explained in 5 Min
Tensorboard Explained in 5 Min
Siraj Raval
36 Generate Music in TensorFlow
Generate Music in TensorFlow
Siraj Raval
37 Build a Game Bot (LIVE)
Build a Game Bot (LIVE)
Siraj Raval
38 Deep Learning Frameworks Compared
Deep Learning Frameworks Compared
Siraj Raval
39 Introduction - Learn Python for Data Science #1
Introduction - Learn Python for Data Science #1
Siraj Raval
40 Build a Neural Network (LIVE)
Build a Neural Network (LIVE)
Siraj Raval
41 Twitter Sentiment Analysis - Learn Python for Data Science #2
Twitter Sentiment Analysis - Learn Python for Data Science #2
Siraj Raval
42 Recommendation Systems - Learn Python for Data Science #3
Recommendation Systems - Learn Python for Data Science #3
Siraj Raval
43 Predicting Stock Prices - Learn Python for Data Science #4
Predicting Stock Prices - Learn Python for Data Science #4
Siraj Raval
44 Pong Neural Network (LIVE)
Pong Neural Network (LIVE)
Siraj Raval
45 Deep Dream in TensorFlow - Learn Python for Data Science #5
Deep Dream in TensorFlow - Learn Python for Data Science #5
Siraj Raval
46 Visualizing Data with D3.js (LIVE)
Visualizing Data with D3.js (LIVE)
Siraj Raval
47 Genetic Algorithms - Learn Python for Data Science #6
Genetic Algorithms - Learn Python for Data Science #6
Siraj Raval
48 Enter Siraj [Music Video]
Enter Siraj [Music Video]
Siraj Raval
49 Build a Web Scraper (LIVE)
Build a Web Scraper (LIVE)
Siraj Raval
50 Why is P vs NP Important?
Why is P vs NP Important?
Siraj Raval
51 How to Make a Neural Network (LIVE)
How to Make a Neural Network (LIVE)
Siraj Raval
52 How to Make an Amazing Tensorflow Chatbot Easily
How to Make an Amazing Tensorflow Chatbot Easily
Siraj Raval
53 How to Make an Amazing Video Game Bot Easily
How to Make an Amazing Video Game Bot Easily
Siraj Raval
54 How to Make a Tensorflow Neural Network (LIVE)
How to Make a Tensorflow Neural Network (LIVE)
Siraj Raval
55 How to Make a Simple Tensorflow Speech Recognizer
How to Make a Simple Tensorflow Speech Recognizer
Siraj Raval
56 Joel Shor - Really Quick Questions with an Awesome Google Engineer
Joel Shor - Really Quick Questions with an Awesome Google Engineer
Siraj Raval
57 How to Make a Path Planning Algorithm Easily (LIVE)
How to Make a Path Planning Algorithm Easily (LIVE)
Siraj Raval
58 The Best Way to Prepare a Dataset Easily
The Best Way to Prepare a Dataset Easily
Siraj Raval
59 Catherine Olsson - Really Quick Questions with an OpenAI Engineer
Catherine Olsson - Really Quick Questions with an OpenAI Engineer
Siraj Raval
60 How to Make a Tic Tac Toe Neural Network Easily (LIVE)
How to Make a Tic Tac Toe Neural Network Easily (LIVE)
Siraj Raval

This video teaches how to optimize electricity consumption in smart homes using reinforcement learning and Monte Carlo methods. It covers the basics of Markov decision processes and model-free reinforcement learning, and provides examples of applications in IoT devices and smart homes. By watching this video, viewers can learn how to implement reinforcement learning algorithms and use Monte Carlo methods for policy evaluation.

Key Takeaways
  1. Use reinforcement learning to optimize electricity consumption in smart homes
  2. Implement Markov decision processes to frame the reinforcement learning problem
  3. Apply Monte Carlo methods to learn optimal policies
  4. Use Monte Carlo policy evaluation to estimate the value function for each state
  5. Construct a model-free technique like Monte Carlo to learn the optimal policy
💡 Monte Carlo methods can be used to learn optimal behavior directly from interaction with the environment without needing the transition or reward function defined beforehand.

Related Reads

📰
It Takes 8 Tokens: Weak-to-Strong Off-Policy RL via Auxiliary Branches
Learn how to improve off-policy reinforcement learning with auxiliary branches, enhancing reasoning in large language models
ArXiv cs.AI
📰
A Practical Guide to Implementing the REINFORCE Algorithm in Python (Part 5)
Implement the REINFORCE algorithm in Python using PyTorch and Gymnasium for reinforcement learning tasks
Medium · Machine Learning
📰
Gimitest: A Comprehensive Tool for Testing Reinforcement Learning Policies
Learn how to test reinforcement learning policies with Gimitest, a comprehensive tool for ensuring reliability and safety
ArXiv cs.AI
📰
RLVP: Penalize the Path, Reward the Outcome
Learn how to implement RLVP, a new reinforcement learning approach that prioritizes outcome over path, and apply it to real-world problems with costly interactions
ArXiv cs.AI
Up next
How Netflix Uses Reinforcement Learning to Recommend Movies #ai #coding #machinelearning #netflix
Ascent
Watch →