 So this talk being just half an hour, sorry, I'm repeating myself for those who have been here a bit before, is obviously it's a high-level presentation of what you can do with JavaScript and machine learning and what libraries are out there and what's, you know, can't libraries are trying to overcome. So there are things that you can do in JavaScript right now with pure JavaScript. First, you can do a cat recognition for those who like cats. So I'm just showing you up, insert, hopefully it will work. If it doesn't... Sorry, I need... Oh, here we go, and oh, it found a cat in the middle of the picture. I don't know if you... Here we go. So you can do digital recognition, which is a classic machine learning example. So here I'm going to draw a seven, really roughly. Recognize... Recognize here, it's rubbish. It's very rough. Obviously my handwriting is horrible, but yeah. Other interesting applications. So self-driving car simulations, obviously, you know, Tesla being in the media and stuff, but there is a... the MIT did a course on self-driving cars and so there was self-driving Tesla and to simulate how, you know, you need to recognize or adjust the parameters. They've done this simulation, which is on top of a famous JavaScript framework called ConfNet.js, and basically you can model your right car and see how it goes and how fast you can go. So in my presentation, I have all the links that you need if you want to experience these libraries. Image manipulation. So it's your file, here, lighthouse, and you can see how fast it is to actually manipulate the data. So grayscale the picture, draw the edges, flip the picture or resize it, zoom it, actually zoomed and flipped, actually a bit reverse. What else you can do, you know, for developers, that's interesting, the automatic logo generator. So I'm gonna try to do it live, so CamGS, and if you go down, you will see it generates different types of logos, like, you know, just to improve your creativity or add arrows to your creativity. The other thing, machine learning, you not only work with numbers, you can work with words as well. So classic example are spam filters, and email filtering. Or, you know, when you work, when you have a sari on your iPhone or search boxes, it's all about work processing, so it's called natural language processing. And there is also this project that I found on Github recently, it's AI for robots, so for those, I think Jessica, you talked about sensor, and Anna was talking about arduinos. So this combines, you know, artificial intelligence and arduino and robots, so you kind of have fun with everything, and all in Node.js and Node. Very high level, I'll try to expose the key concepts of machine learning. So we oppose supervised to unsupervised machine learning. So supervised is when you have a specific set of inputs and you know your output, you know what to expect at the end of the day. So you're trying to find a function, if you want, that will map all the X variables to the targeted output Y. So typical, there are two types, like classification, when it's a discrete set of outputs. So if you are, you know, let's say you have a set of colors, so you categorize, red or blue, or your emails, if it's spam or not spam, it's classification problems. Then you have regression problems. So regression is when the output variable is continuous. So it can be in dollars or weights. For instance, if you think of, let's say you wanted to do a study on property prices, and you would think of, well, what's the location? What's the square footage? How number of rooms? You know, does it have a garage, a swimming pool, all those features? And you try to have at the end of the day how much your property would be worse. So that's kind of regression problem. So examples of algorithms that support that, it's linear regression. Support vector machines and random forest. Random forest is like a tree, and basically, you do multiple trees randomly, you set up the parameters randomly, so that's why we call it random forest. Unsupervised learning is when you don't actually know the output, or you want actually to discover the different groupings and the different classifications out of the blue. So you have clustering problems and association problems. So clustering, given a certain set of data, it's used, for instance, in the medical world, like if you have a certain set of features, your sex, your age, your health habits, or in biology in general, like if you have a certain set of features, and you group them, what type of disease or what type of plants you come to. Associations is to discover the rules among this data. So really at the high level, it's supervised versus unsupervised. So that's a classic description of neural network, which is one of the main algorithms in machine learning. So you have a set of inputs. So as I said before, for instance, in the real estate example, the square footage, the number of rooms, that's your input layer. So you have the number of inputs as a number of features, and the output layer. So here you have two different outputs. It could be spam, not spam. It could be just one output, but a price. You have an output layer. And in between the input and the output layers, you can have hidden layers. And there can be, like it can be from one to n number of layers, depending on the complexity. And here it is where it's more an art than a science to decide which number of hidden layers are in a network. But this might not appeal to everybody in terms of understanding of a neural network. I find sometimes it's easier to have this kind of representation, like a typical tabular representation. So the features are, you know, from, you can see in terms of widths of the data set. And the number of examples are like the height of x in that example. And so it's obviously, it looks like a matrix. And you try to arrive at the, for each example, you know which output you're going to get. So it's, you try to approximate the y, the column y, next to the matrix. So you're trying to find out the function or the weights that you apply to your data set, the x. And this approximation gives you a, it's called a y hat, which is, you know, what outputs give an current model. So in mathematical terms, it would be just, it's f of x gives you a y and you try to minimize y hat compared to y. I don't know if it makes sense to everybody. Yes. This one is, looks easier for you. But it's, I saw, maybe the second representation makes you more, I understand that, you know, you, you have all this number of examples, the output that you expect, the y. And we are trying, the game is really to try to minimize y and y hat. Okay. And we are, and to basically to do that, you adjust, you, you adjust the w, which has a weight that you apply to the number of features. Y hat, it's basically the result of your model of w times the x, if you want, the different weights that you apply to your data set. So basically this thing called perceptron is just one part of, let's say, what I showed in the picture with perceptron is just this one. So you have a different number of inputs, you apply a number of weights in the middle and you activate them and you have one neuron in your network. So the, in terms of calculations, if you apply to your inputs, different weights, you sum them like in multi linear regression and you activate them, making them like, you know, binary, is it zero or one? Do you accept it in your model or not? And so this perceptron is, or all the hidden layers and the output layers are calculated in that manner. You apply a different set of weights between the input and the hidden layers and a different set of weights between hidden layer and output layer and you, at the end of the day, you try to compare the output layer to the calculations from your weights and the different layers to the output layer and you try to minimize this error between what you've calculated and what is actual. Does it make sense? Does it make sense? So another key concept and it was discovered relatively recently, recently in that case, means in the last 15 years, is the concept of back propagation. So you can do these calculations about weights in one way, but really for it to improve. And so the network learns, you have this concept of back propagation. So you back the errors that you found out at the way that you calculate at the end of the day between the calculated output and the real output. You try to integrate it backwards into the weights, into the weights that are between the hidden and output layer and between the input and hidden layer. So how, so you reintegrate the error and it's an iterative process until your error is close to zero or as close to zero as possible. And that can be done basically thanks to, because we all know the properties of the activation functions. So this is possible to go backwards or to back propagate your error thanks to the derivatives. So activation, these are examples of activation functions. So really you have to think of activation functions as trying to squeeze a number in this case for the logistic functions between zero and one. You know that everything between infinity and minus infinity and plus infinity will be squeezed between zero and one. Ten, I don't know how to say it in English. Ten. Ten h. Ten h, okay. It's, you squeeze every number from minus infinity to plus infinity between minus one and plus one. And we can back propagate and do this iterative process because actually mathematically we know what the derivative of these, of these different functions are. And I don't know if you have recollection from when you were doing linear algebra and maybe in high school or encouraged. So most cost functions have a convex feature. And so you know what convex is? Like it looks like a U basically. And when you want to minimize, so to go to the bottom, to find the local minimum on a convex function, you use the derivative and try to go to the zero basically. So you use a slope of the curve in the convex function to try to reach the minimum as a local minimum. So that's how we achieve back propagation. And that's how we can achieve the whole iterative process of improvement. So you calculate a certain output. You calculate the cost error and back propagate it into the weights. And then there is a learning rate which makes it improve every time. So these are the classic cost functions. I guess the most known one in terms of statistics is the mean square error. But you have a number of different types of errors. Okay. Enough maths for today. So obviously all these calculations, you know, at the end of the day, you need performance from your computer to realize this. And the browser obviously is not the lowest level you can do your calculations. And most libraries would be in C++, I don't think there are any assembly to my knowledge, but they would be in a very much more low level language. However, when you handle calculations, it's often done in Python. And Python is just a wrapper around these C++ libraries. That being said, if we are just doing Python versus JavaScript performance comparisons, most of the time JavaScript with the improvements of the V8 engine and, you know, the different browser engines, it's actually faster than Python. It's just that when you do deep learning networks, that when you do like image recognition and not just of cats, because here it was a bit cheating, the cat was recognized because we could find two ears, like, you know, the sign of... So that was a shortcut. But if you want to do it at a production level, like, you know, at Google size, you need really like a lot of GPUs to do that. And why GPU is because coming from the gaming world, that's where most calculations for refreshing screens come from. And so they are very much used to all the vectors and matrix calculations that are actually used in machine learning. So the leader in that field is NVIDIA, or when you have NVIDIA GPU, they have actually also created libraries that enable you advance mathematical operations. So in the JavaScript world, we are used to the simplest way to do that is array of arrays. But it's actually not the most performant way to do that. For accessing a particular item, you would do what, you know, given a matrix A, an array of arrays, you access your elements by, you know, A, I, J, which, you know, I'm sure everybody would be able to do. But it's not, if you want to iterate over that or access or transpose or this matrix, it won't be very fast. One faster way to do that is to use typed arrays, which is my second example. And it's faster, but the thing is here, you can see this, so this is the same matrix as this one, but it's just flat. It has been flattened. And here the index is, so as you can see, it's three rows and three columns matrix. And here you can see that the index has been fixed. So one, so it's very fast using typed arrays, but to access the different elements when you want to do higher order operations is a bit cumbersome. So there is a compromise where this index, the three in my example here is actually, it's a general, you know, function. So here this formula basically becomes to that. So here you can really switch rows and columns very quickly. You can transpose numbers in your matrix much quicker. And there's been a library that has used this idea of striated arrays and which is NDRS. It's used in a number of low-level and high-level libraries, NMGS, which is a kind of NumPy for those who are familiar with Python that tries to use the same kind of functions that NumPy or MATLAB have. Keras takes the name of a famous library which is a higher order library, a higher-level library on top of TensorFlow or Tiano, which are more lower-level or matrix calculations. So Keras, it would be easier to do artificial neural network, recurrent neural network. It's good for prototyping machine learning models. The only thing, the Keras JavaScript model, you can only, in a way, do forward propagation. You can only do what's called inference and not back propagation. So the training of your models won't be done in JavaScript, it would be done in Python. And then once you have your model, you use JavaScript to visualize these things. So TensorFlow is the latest library. It uses NDRS, but it also uses WebGL under the hood. So, other ways to do calculations on the CPU is using WebAssembly. There are fewer examples of that and they are less mature, but it's certainly avenues to explore to improve the speed of calculations on the CPU. And also to increase the parallelism of calculations in browsers, you can use service workers. That being said, there is a cost of transferring your data from your browser straight to the service workers and back. So there will be a slight delay compared to pure CPU. So, as I mentioned, you can do calculations leveraging your CPU or you can leverage WebGL. So a number of libraries have emerged. And the latest one being TensorFlow, which was sold on Twitter like two weeks ago. So it's really recent, but they haven't, for the moment, open source code. So, as I said, I found NPM library, but I couldn't find a GitHub. Basically, it leverages JLSL, so the language that is used with WebGL. You can use also leverage your GPU differently using OpenCL or WebGPU, but then I guess it will be a different setup. It will be using a node rather than purely the browser. And usually, it's restricted to a certain number of browsers. It's not cross-browser compatible. Right. So that was my high level in terms of concepts from machine learning. I wanted to explore a number of blogs and libraries that you can use in JavaScript or courses if you are interested in the area. So, this black camber did an old blog in machine learning addressing not neural network, but a lot of unsupervised learning algorithm. And the second one is that I mentioned here, is quite interesting because this guy is relatively famous. He developed one of the first deep learning library in JavaScript called ConfNet.js to do convolutional neural networks on pictures. And he used to work for, so he's from Stanford, and he used to do work for OpenNI. And recently he has been hired by Tesla to improve machine learning for cars. So there are a number of JavaScript specific resources. So ConfNet.js, unfortunately, is no longer maintained. TensorFlow, you have a nice TensorFlow playground to play with, which is here, you can add a number of hidden layers, different features. And you can, so it's nice to play around in terms of what you can achieve and how long it takes to improve your model. So it's TensorFlow playground. So it's a really, it's written in TypeScript, and it's only a very small set of the TensorFlow library. Do you know, actually, do people understand what a tensor is by any chance? No? Okay. So you should think of tensor as a container. Like a number, a scalar, would be a tensor of size 0, a vector. So I'm going to go to, so a vector would be a tensor of one dimension. A matrix with rows and columns would be a tensor of two dimensions. And a cube, so three dimensions would be a tensor of three dimensions. So you have to think of it as a container. So libraries, and if you are more interested, so you can get involved at different levels. Maybe some like to go into the lower level, so the matrix and vector calculations. Or you can go higher level and talk about different types of architecture and convert JS. And more recently, this one, Netaptic, which tries to do neural evolution. So neural evolution for those who don't know, it's kind of, it tries to, it's a kind of genetic algorithm, which means that they, let's say, you can't do randomly generate a number of examples. And basically, you try to eliminate those who don't work as much. So it's a very Darwinian process in a way. You generate a number of examples. You keep the ones who survive the longest. Then you regenerate a number of set of examples and so forth. So there has been a number of universities involved in to do machine learning in JavaScript. One, I would say, is more on the edges from the University of Tokyo, my LGS. They do libraries which are relatively very Japanese friendly like Sushi2, Tempura, Sukiaki. But they have like Sushi2 is for instance, for matrix calculation. Sukiaki is on top of Sushi2 to do different machine learning models. They do distributed computing. So they have created a framework where you have different browsers and basically you leverage the capabilities from, you know, maybe using WebSockets so you can connect different computers, different browsers, and you leverage the CPUs of these different browsers. You have two ones with university which, the other two universities are maybe less known or less marketed in a way. I learned just by chance that they existed and they have actually quite a few libraries on NPM or GitHub. The last one actually doesn't have NPM but it does have a GitHub. I asked them if you wanted to leverage NPM but the guy didn't see the point of using JavaScript with Node.js. I don't know, that's his point. But they have a nice online laboratory where you can actually download some files and you can, you know, use the most common machine learning libraries on it to, you know, try to create a model. Coursera. I personally, so I'm not an expert in the field. I'm still doing it actually. I recommend the Coursera course from Anduinji who is, who used to work at Google and Baidu. He was the chief machine learning or chief artificial intelligence guy from Baidu, the Chinese company. Jeffery Hinton, so his course on neural networks in Coursera. Jeffery Hinton is one of the leaders in machine learning and it's quite unique that you can find his course from him completely free on Coursera. Udacity proposes a number of nano degrees in the field. The examples that I showed you on deep traffic, the MIT course, a lot of people from the self-driving car engineer were involved in that. So I don't have networks, so unfortunately I won't be able, but basically they participated in this in this setup as well. There are lots of resources on the internet, blogs, which are not, most of the time, not JavaScript specific. The JavaScript ones are the, these ones that I mentioned. Yes, so you can get involved also to encourage getting involved. There is an AI grant for whatever projects and TensorFlow as the latest library that I mentioned, they participated in the AI grant competition and they won 5,000 from that when they created TensorFlow or Kaggle. Kaggle actually was co-founded by an Australian guy and it's a website where people can do machine learning competitions and there are open data sets and there is a forum where you share your tips and tricks to improve the accuracy of your models. Sorry, that was very fast and you know, very involved, but if you have any questions, happy, sorry. We need a copy of that for all the links. Yes, sure. Yeah, I will put this, yes. Yeah, so TensorFlow, I think you can try the the demos that they have on your mobile. I personally don't know, you know, the performance comparisons for that. The one other thing is, I guess the calculations would be, I mean, I don't think your GPU on the mobile is in terms of power, it's great, that great. So I don't think, you know, I mean, it will improve a bit in a way because it's parallelized, so it's, you know, in parallel to your CPU, but in terms of pure raw performance, I don't think it's great. That being said, I know that Google with TensorFlow has tried to, you know, democratize the use of its library and so they encourage it and they do Android apps on that, but I personally haven't tested it, so yeah. The weights, yes. How are the weights? So the weights, you have to say it's the same set of weights that you apply to any examples, okay? So we'll try to follow them. You can vary the output. Yeah, so obviously it's different set of inputs, but basically it's n, and you can see it's n, there are a number of features, n number of features, you multiply each feature by its weight. Okay, but I have a way, sorry, I didn't mean to determine the weight, you just experimentally. So first it's randomly generated and then, so first you randomly generate these weights, so then you do the calculations, so the like the matrix calculations, okay? You activate them using one of the functions that I showed you before, and you do that for every neuron, every layer, and give you y hat, the what comes from your weights, okay? So then you try to calculate a cost, you have a cost measure, so the most famous one is mean square error of comparing, but it's basically y minus y hat square, so I think there's another of examples, okay? So once you have that measure of error, okay, you by propagate this error into thanks to the derivatives of the activation functions, back to the initial input, okay? So it changes, and then it's an iterative process thanks to what's called a learning rate, where you add that, and at the end of the day you will mean, you will diminish the error that you can't create. Is that clear? It's sort of clear. I mean I'm happy to, we can go over a numerator example or a coding example if you want on a, you know, this afternoon or whenever you want. What kind of a place can you deal with? Because I feel like this model being like a linear regression can only deal with a certain number of places, like in terms of tensors, like the number of square dimensions that you can work on the problem. Is it just for like the two-dimension problem? And then anything after that, the error rates, you know, just can't really model it very well. So actually the fact that you have hidden layers and you have, so it improves if you want the non-linearity of your problem. So let me show you what I mean. So you're thinking of, given a set like that, you can see it's not linear. If you were just doing linear regression, it would be a straight line. Okay? So if you were doing just input outputs, that's what you would expect. It's a linear regression. But the fact that you implement a hidden layer in the middle improves the non-linearity of your model if you want. So I've done that example in JavaScript. So just logistic regression and just input output without hidden layers would give you a straight line. Okay? But if you had a hidden layer and I said, I mean, here the code is in Python, but I've done the same in JavaScript. You, the fact that you introduce the hidden layer that we find, you know, here, so you can see here, this is for hidden layer size three. You can see you add a non-linearity to your problem. So, and the more you add, basically the more precise in your non-linearity you can go. Okay? So then it's a complex, then there is, I mean, I didn't want to go or that, but you can overfit your data. So then in terms of, if you want to predict, you know, a set with your model, you have to be very careful that your model doesn't overfit your test data. Obviously, that's numerical complexities. I mean, I don't have the exact answer, but you know, it's adding a role. It's basically adding a few matrices to your calculations. So in terms of, I know computer scientists calculated in terms of all something, it would be at least in square, added square capacity. Any other questions?