Placeholder Image

字幕列表 影片播放

  • hi and welcome to coding Tensorflow, a show where we focus on coding machine learning and AI ai applications.

  • I'm Laurence Maroney, a developer advocate for tensorflow, and in this episode we're going to look at using JavaScript for machine learning in the browser.

  • In the previous episode, we looked at creating a very basic machine learning scenario in the browser.

  • You took data that had a linear relationship on Built, a basic model that could predict future values.

  • Based on that relationship, it might have looked a little strange and how you fed the data into the model when you were training it with one tensor of the X values and another for the Y values.

  • That's because one of the core concepts that you need to learn as a tensorflow developer is all about that.

  • How to shape your data on how to get it ready for training.

  • This process is a major part of data science, and today we'll look at a more complex program on how you can get your data ready for training a machine learn model with it.

  • So instead of a simple linear arrangement which you don't really need machine learning for, let's consider a classification problem, and this is when there are multiple items of data about a thing, and then there's something about how they're related that determines the classifications off that thing.

  • So, for example, in the E mail might be a spam if it's from a particular sender or contains particular key words or pictures, an animal might be a doggie if it has four paws and acute wet nose.

  • Now it's very difficult to program traditional if then type code for these scenarios on this is why machine learning can be such a powerful tool.

  • So let's take a look at some public data on.

  • We'll use that to build a classification system.

  • We're going to use the well known Irish data set, which collects data points from 150 different samples of flour taking petal length and width as well a C pull lengthen with These measurements are then associated with one of three types of iris.

  • By training a neural network with these measurements telling it the values and then the classes of flower that correspond to those values, you could then build a neural network that can unfair from a new measurement.

  • What type of flower they represent.

  • So let's take a look at the data, and here it is, and you might typically get data like this as a bunch of comma separated values.

  • As you can see, each entry has five values.

  • The four measurements that I mentioned earlier and then a value 01 or two In the final column indicating the category of flower that the data represents, Consider the 1st 4 values to be your ex is on the last one is your Why.

  • Thus, given a set of four exes, you'd want to predict or classify the Y.

  • So now that you have the data, you can use it to train a model.

  • To do that, you'll use tensor is for the training axes and 10 Tsar's for the training wise.

  • In addition to that, you can use some of your data to test your model.

  • So what you should do is you take a percentage of your data for training the model and then with the remainder, compare the predicted value with their actual value, and from there you can determine how well your model is behaving.

  • So let's take a look at the code that we used to prepare this data for training.

  • First of all, we'll split the data into different A raise for each of the classes.

  • This four loop ITA rates through the iris classes dot length on it creates to raise one for the data of that class on one for the values for that class.

  • If you then look at the data, you'll see that there are three classes, so we'll have three of each array.

  • The data by costs will contain the four measurements on the targets by class will contain 01 or two based on the flower type.

  • Once we've created these arrays, we can now iterated through the data and sort the values into the array based on the target.

  • So the data for Class zero will get loaded into data by class zero on the targets for class.

  • Aargh.

  • Likewise, etcetera, etcetera.

  • If I now log these erase of the console, I convey you them in my developer tools.

  • The next step will be to convert these values into 10 Tsar's with four sets of 10 Tsar's and X for training and expert test.

  • Ah, wife or training on a wife or test.

  • We do this according to the tests split, which is a parameter that we pass into the function in this demo, I said It's a point, too, so that 80% of my data is used for training and 20% for testing.

  • The war course here is the convert to Tense Ear's function.

  • This takes the data the targets on the split on loads, all this value into 10 Tsar's, splitting them into training and test sets, respectively.

  • Let's take a look at that.

  • Next.

  • Here is the convert to Tense Ear's function.

  • It calculates the number of test examples by rounding the sample size by the splits on the number of training.

  • Examples will just be the remainder and then creates a two dimensional tensor of the data, as you can see here on a one hot and coding off the label data.

  • Now, one hot encoding is a way of helping a machine understand how your data is being classified.

  • So instead of the flowers being 01 or two, what happens is you get an encoded array where instead of a flower for zero, you would get 100 and that array instead of one.

  • You get a 010 etcetera, etcetera.

  • The idea is this that that this array will just map to your output neurons.

  • Once you've done that, the data will be sliced into the four arrays based on the size determined by the test split.

  • The last step is just having a nice, clean, linear set of 10 Tsar's to feed into the training instead of the two D one that you have right now.

  • This is achieved using t f dot com cat along access zero.

  • Let's take a look at the code for this, and here's the code you can see I set the Kong Cat access to be zero on.

  • Then I'll return my set of 4 10 Tsar's, where I'm contaminating them into a one dimensional tensor.

  • As an example.

  • If I log the ex trains against the contaminated ex trains, you'll see the difference.

  • This has the effect of reducing the overall complexity of the data being fed into the model.

  • It doesn't have to try and figure out multiple dimensions on.

  • This makes training quicker and more accurate.

  • Congratulations.

  • You've now taken raw data on you've learned how to pre process it into 10 Tsar's that make for efficient training, including howto one heart and code.

  • The output data.

  • This is a massive part of designing any machine learning system.

  • Getting your data right in the next video will train a neural network.

  • With this data on, we'll see how you could design that network on, then how you could do classifications.

  • Given the train model, you can find that right here on the tensorflow YouTube channel.

  • So don't forget to hit that subscribe button right now.

hi and welcome to coding Tensorflow, a show where we focus on coding machine learning and AI ai applications.

字幕與單字

單字即點即查 點擊單字可以查詢單字解釋

B1 中級

為機器學習準備你的數據集(TensorFlow編碼)。 (Prepare your dataset for machine learning (Coding TensorFlow))

  • 2 0
    林宜悉 發佈於 2021 年 01 月 14 日
影片單字