[0:00]What's going on guys? John Elder here from codemy.com and in this video, we're going to start to look at Pi torch for deep learning.
[0:09]Now guys, like I said, in this video we're going to start to look at Pi torch for deep learning, but before we start, if you like this video, want to see more like it, be sure to smash like button below, subscribe to the channel, give me a thumbs up for the YouTube algorithm. And check out codemy.com where I have dozens of courses with thousands of videos to teach you to code. Use coupon code YouTube and get 50% off lifetime membership. It's all my courses, videos and books for one time fee, which is insanely cheap. All right, we are starting a new playlist here on the channel, Pi torch for deep learning. So we've already looked at NumPy, we've looked at Pandas, we've looked at a little bit of Psy kit learn for machine learning. In this playlist, we're going to focus on deep learning. Now, deep learning is a subset of machine learning, so the things we've learned for machine learning, things with NumPy arrays and things like that are going to be a little bit useful here, at least for foundational understanding of some things. But we're going to move forward and learn specifically deep learning. And of course, when you think deep learning, you think neural networks and that's what we're going to be focusing on. And neural networks are great. They're great for predicting and classifying and doing all kinds of great things. We see language models, you know, chat GPT uses all kinds of stuff like this and it's going to be really interesting and fun. And in this playlist, we're going to be using Pi torch. And a little bit of history, very quickly, back in the day, there was something called Tensor flow. Tensor flow still exists, and it was the big deep learning machine learning platform, but Pi torch is the new cool thing. And it's very Pythonic in nature, Pi torch, Python torch, so we can use Python throughout this, which is great. And Pi torch is really just destroyed Tensor flow. I mean, it's like night and day, everybody is using Pi torch now. And I'm not just saying that if you look at GitHub repositories with AI and deep learning projects on them, you could see which ones are using Pi torch and which ones are using Tensor flow. And Tensor flow used to be like up, up, up, up, Pi torch was released and then kind of plateaued and then just dropped off the planet. So everybody now is using Pi torch, so if you're using Tensor flow for your deep learning, keep doing it, that's great if you like that, that's fine. But just everybody's using Pi torch, so that's what we're going to be using in this. And Pi torch is a library or framework that allows you to do all kinds of deep learning things very, very easily. And I think you're going to be surprised just how quick and easy it is to get up and doing some pretty powerful stuff with Pi torch. Using pretty sophisticated neural networks. So in this video, we're going to be talking about and setting up our development environment. We're going to be using Google Colabs, which is fantastic for this. It's completely free. Everybody can use it, it works on everybody's computer and it's uh, really, really cool. But before we get into that, I want to spend just a very quick couple of minutes, and really just a couple of minutes talking about neural networks. Because if you're brand new to this, you have no idea what this is, and you need to have a very basic understanding, at least visually what these things are before we get into it. So a neural network is a way to learn with machines, it's machine deep learning. And it's very similar to a brain with neurons and how humans learn and that's sort of how they developed this a machine way to learn like humans learn. So if we head over to Google and let's just type in uh, neural network. And I just want to find a picture very quickly of a diagram so we can sort of visualize this and and talk about exactly what's going on here. So you can see all these things. These are all pretty good. Oh, that's not very big at all.
[3:31]So we could just use this one right here. So this is basically a neural network and it starts out here, this green layer, this is the input layer. And here you're just putting in random inputs. And we'll talk about this stuff in greater detail going forward, but just a very high level understanding of what's going on, you have some sort of inputs, right? They come into the green layer and then they come out over here in the red layer, they output, right? So inside of here is where you're learning and think of these as layers of neurons. So each of these little circles is a neuron. And if you studied psychology at all in college, you've learned about neurons and how electricity goes through them and things happen. Uh, same thing here. So, you have a layer, your inputs come in, they hit this first layer. These layers have different weights. So probabilistic weights, if you know statistics at all. We're not going to get into the math in this playlist very deeply because you can deep dive way into the math on this stuff. And it's really cool if you're a math nerd. I have an economics degree, which basically means I have a calculus degree because economics is just calculus pretty much. So I'm a huge math nerd, but it's very, very easy to very quickly go off the deep end in the math of this stuff and get bogged down. And we don't want to get bogged down, we want to start building models to make predictions, creating neural networks that actually do things, classify images, uh, do language models, all the cool things you could do. And you really don't need a huge math understanding for that. You you need basic math, addition, subtraction, multiplication. We don't necessarily need to understand the algorithms involved, the huge equations and all the Greek letters and all that stuff. Now, you can learn all that stuff and it's great and if you're going to do this for a career, I recommend you do that, but if you're just trying to learn this stuff and get into this, we don't want to get bogged down with the math, so we're not going to in this playlist. But to keep this simple, there are some weights and these random numbers get weighted and then learning happens here. And then it goes to the next layer and it learns a little more and it goes to the next layer and it learns a little more. Depending on the type of neural network, it might ping pong back and forth between layers. It might go from this layer down to here or up to here or down to there, back over to here. You can see in this diagram, it's going all over the place. Eventually, it learns enough and it boom, comes out with an output and it says, hey, this picture is a cat, right? So you might, you know, put a picture in here and boom, boom, boom, learns, you're asking, hey, is this a cat or a dog? Comes out, it's a cat or hey, it's a dog. So, input, learning, output. That's it. That's all a neural network is. This is very simple stuff at a high level understanding. Right, obviously this is complicated, you know, the math involved is crazy, but that's really all a neural network is. You have some inputs, boom, boom, boom, you learn, boom, you output. That's it. And the thing about neural networks is back in the day, you had to write code for everything, right? So, if you wanted to have a chatbot, for instance, you needed to have answers to every single question that somebody might ask. So, the the code would be if the person asked, what's your name, answer with this. If the person asked what color is the sky, answer with that. And you had to have code for each of these things, right? So, that would take a huge amount of code to do something as simple as a chatbot. Neural networks allow you to work without code. You're not specifying an answer for every single thing. The neural network is learning itself and then making a determination without code to answer how it thinks it should, and it does that through all these learning layers. So, very, very interesting stuff, very fun. You know, if you guys have looked at chat GPT or some of the other AI tools out there recently, you can see that this is just exploding. This is a great thing to learn and a great time to learn it and that's what we're going to be doing in this playlist. So, that's a high-level understanding of a neural network. We're not going to We're going to get into more details of what it is, but for now just understand you have some inputs, you have layers of learning and then it spits out an output. And that's it. That's all you need to learn right now. So, let's get started here and this is just the Pi torch website, this is going to be your friend, the documentation is fantastic. We're going to be looking at the documentation as we go along because sometimes it's better than what I could tell you. And I'll walk you through it, but sometimes we're just going to look at the documentation. And this stuff changes all the time, so you're always going to be going to the documentation to look things up, so it's important that you understand how to do that, so we'll do that a lot in this course or in this playlist.
[10:04]So, what we're going to be using to do all of our work in this playlist is Google Collab. So we could just type in Google Collab. And this is completely free and it's basically a cloud hosted Jupiter notebook. So in our last Pandas playlist, we used Jupiter notebooks. I think we did in the Nump playlist as well. So this is basically a Jupiter notebook, it's just up in the cloud and that's fantastic for lots of different reasons. But we can come over here and let's just come down here and create a new notebook. And I'm going to come up here and I'm going to call this uh, intro to Collab, I guess. Whatever. And you can see this looks just like a Jupiter notebook, so we can go two plus two. We could do all the Python stuff we normally do, and you'll notice this works very slowly because this is the free version and the free version works very slowly. For $9.99 a month, or $9.95, something like that, you can get the Pro version. And I recommend you do that if you're into this stuff because it's money well spent because this will speed up and it also will allow you uh, better GPUs. And we'll get into what a GPU is, a CPU versus a GPU, uh, graphics card, graphics acceleration allows us to do all this stuff much quicker.
[11:51]So you can see two plus two equals four. Pi torch, if we want this, we're going to use Pi torch, so we would import torch. And just shift enter to run this thing, and boom, that should work. Now, you can see even this has taken a long time, sometimes it just does, it just depends how many people are using this, how busy they are, what time of day it is, whatever. But one thing we could do to speed this up and we're going to because all of our neural network models are going to require faster processing or else it's going to take forever for them to run. We can come up here to runtime and click change runtime type. And then we can click on hardware accelerator here and we can pick a GPU. And you get a free GPU with Google Collab and that is huge because if you've tried to buy a graphics card, good ones are a couple of thousand dollars. And then you have to install them in your computer, you have to configure them a very certain and specific way in order to use them for our deep learning. It's a huge hassle and Google is giving us a GPU for free. Now you can see right here, we just get the standard with the free version, but we can save this. And when we do, now you can see up here, it's connecting and initializing and do we want to delete our previous runtime? Yeah, sure, fine, whatever. And now, if we click on this, you can see we're on using Python 3 with a back end GPU, which is fantastic. We can see the usage right now, it's not being used at all because we're not running anything, but this is awesome and very, very cool. So, let me close this out here. One thing you might want to do is run pip, uh, you could do freeze or pip list to see the versions of things that are currently installed here. Now, you want usually the latest version of Pi torch and I think they do have the latest version as of today, but you never know, so you always kind of want to check here. And we can just type in pip list and shift enter to run this thing.
[14:23]And you can see there's all kinds of stuff already installed, which is nice. We don't have to install most of the stuff that we're going to use and if we come down here and look for torch, we can see 2.0.0 plus CUDA 118. The CUDA is the C U thing, that is the thing that allows us to use the GPU very well. It's an Nvidia driver or something like that that allows us to use GPU stuff in our models very, very quickly. So, we want to make sure that's that's on there and it looks like this is the latest version, so we're good to go. If you need to update this, you can head over to Google and just type in Pi torch, uh, Collab or Google Collab. And you'll get some instructions here. Let's see. Yeah, you want the Pi torch documentation. Running tutorials in Google Collab. Yeah, right up here at the top, it gives you instructions for pip uninstalling and then reinstalling Pi torch. Don't recommend that you do this right now because when you do this, using these two commands, the torch version that gets installed is the one without the Cuda. So if we look through here again, yeah, right here, you'll just get 2.0.0 without this Cuda. We want the Cuda thing. So, uh, as of right now, we don't need to update this at all. This is great. This is exactly what we need and we're good to go. So, very quickly, one more thing I want to do is sort of connect this to GitHub so that you can look at my code going forward in this playlist very easily. And maybe you want to save this to your own GitHub repository, how do we do that? Well, head over to GitHub and log into your account, this is my account over at github.com/flat planet. No, I do not think the world is flat, I just find it hilarious that some people do, so that's my username. And we just come over here and create a new repository and name this anything you want. I'm going to call this Pi torch tutorial, YouTube, maybe, something like that. And then let's create a repository. And when we do that, we get this screen. Now, normally, we would type these things into our terminal, right? But we don't have a terminal now, so what I'm going to do is kind of a hacky thing. Come up here to actions, click on that, and let's just create a suggested, let's just create a very simple main branch repository. So, uh, just click this configure. It's going to add this file, so I'm going to start the commit. Click this green button right here. It says commit, we want to give it a little commit message. I'm just going to call this initial commit. And then we'll commit this new file. Now, when we come back to our repository here, you can see it has this directory. And we're going to delete that in just a second, but for now, we can use this repository, this flat planet support/ Pi torch tutorial/ YouTube to save our code here. So remember up here, yeah, so remember up here, we named this intro to Collab, this notebook, intro to Collab. We want to save this whole thing to our GitHub repository. We can just come up here to file and click on save a copy in GitHub. And when it does, well, it's already asking me for something. It's going to show a little something different for you. Um, let's see.
[18:38]What we want to do, what you're going to want to do is click on, maybe file open. Yeah, to get this screen here, click on GitHub. And the first time this little included private, this little include private repos check thing will be unchecked. So what you want to do right away when this screen pops up is click this. And you should get a little popup that allows you to authorize Collab in GitHub, right? So be sure you're logged into your GitHub. And then when it, when that box pops up, it'll just be there, you'll click okay, authorize, it'll authorize and then you'll be good to go. As of right now, I'm already authorized, so it's not giving me that popup. So what we could do is come back over to our notebook, click file, save a copy in GitHub. And it'll ask what repository. So we want to click on here and I've got too many repositories, but we want the Pi torch-tutorial-YouTube. Of course, you select whichever repository you named your repository. And then the branch is main. And then here we type a little commit message. That's fine, we'll just leave it like this. We want to include a link to Collab and I'll show you why that's important. I mean you don't need to, but it's probably good to do that. Click okay. Now it's creating a copy. It should pop up and and do it. If it doesn't, you might, you can see right here, we've got a popup blocker here, so I'm going to go ahead and allow that. Boom, this will pop up and now you can see two plus two equals four, import Pi torch and pip list is in our repository. And if we click on this repository, we've got the file right here. We've also got this directory, we created a couple of minutes ago. I'm going to click on that and delete it. We just come up here, we don't need this at all, so I'll just click delete. Commit the change, boom, boom. Now we come back over here to our repository and it just has that one file. So, very cool. Now, if we click on this, we'll see this little link when this pops up right here. This says open in collab, which is really kind of cool. That's that link thing we just looked at. When we pushed this and if we do that, boom, it will open this right up into Collab from now on, which is very, very cool. Now this is a public repository. I that's because that's what I wanted. You could make it a private repository as well, just whenever you create the repository, click on private instead of public and you're good to go. So that's really all I wanted to talk about in this very, very introductory video. In the next video, we're going to dive in and start learning all about neural networks. We're going to be learning about tensors and uh, all kinds of great things. And this is going to be a lot of fun. If you're into artificial intelligence, this will be a great intro playlist to get you started. Hopefully, I'll give you all the background stuff you need in order to start doing deep learning with Pi torch and it should be a lot of fun. So, that's all for this video. If you liked it, be sure to smash like button below, subscribe to the channel, give me a thumbs up for the YouTube algorithm. And check out codemy.com, we can use coupon code YouTube 50 to get 50% off lifetime membership. That's access to all my courses, almost 60 courses, thousands of videos and the PDS of all my best selling coding books. Join over 160,000 students learn to code just like you. My name is John Elder from codemy.com and I'll see you in the next video.



