Check out a free preview of the full Machine Learning in JavaScript with TensorFlow.js course

The "Pre-Trained Models Overview" Lesson is part of the full, Machine Learning in JavaScript with TensorFlow.js course featured in this preview video. Here's what you'd learn in this lesson:

Charlie explains that pre-trained models are already trained, tested, and ready for use in applications. These models include image recognition, text classification, and sentiment analysis. Factors that influence model selection include the quality/quantity of the training data and if you have access to the list of classes and labels within the model.

Preview
Close

Transcript from the "Pre-Trained Models Overview" Lesson

[00:00:00]
>> As I said, the first thing that we're gonna look into is pre-trained models. So if you've never heard what a pre-trained model is, it's a model that's already trained and tested and it's ready to be used. So whoever built that model had gathered the data and processed it and labeled it and then trained the model, picked the structure of the model that they wanted to use.

[00:00:22]
And they tested it for good accuracy and they're basically open sourcing it, or if you're doing it inside a company, they're just making it available for people to use. So as a user, all you need to do is to give it a new input of data and it will give you a prediction.

[00:00:37]
So it can be image recognition models, it could be text classification models. At the moment with the discussion of large language models, that's that, it's models trained with a lot of text data. And then when you ask it a question, it's able to make a correlation between everything that it's been trained with.

[00:00:57]
And you have also, yes, sentiment analysis models, where it's been given a lot of data with maybe labels of joy and happy and sad. So that would be more supervised learning. And when you're writing something, it's able to kinda make a correlation and give you a label of what you wrote was happy or sad and things like that.

[00:01:16]
So when you want to work with pre-trained models, there's different places where you can find them. One of them is Kaggle, and you can filter out to only use Tensorflow GIS models, but there's a lot of other models available, and some of them are available to work with more like Python.

[00:01:35]
And some models would probably be available with maybe a custom other library, but you can filter out to only get the TensorFlow.js ones, if you want. And then, if I open the link, there is actually, on GitHub, there is a specific repositories for all the models that you can use with TensorFlow.js.

[00:01:51]
And here, for example, pose detection, which is one that I use, but we can talk about that later. You can have face detection that we're going to use in one of the projects. And you can have a look here and have a bit of fun and try different models.

[00:02:05]
And then there's also hugging face, which is a popular platform where models are uploaded as well. So you can have a look at what's there. Some of them will be Tensorflow.js compatible and some of them you'll have to use another tool, maybe you write some Python. Once you feel a bit more comfortable with machine learning in general, then you can play around with different libraries.

[00:02:26]
And in terms of choosing the right model for you for what you wanna build, there's a few questions that I usually ask myself. And the first one is, what am I actually building? If I build something that uses images, then obviously, I'm going to use a model that was trained with images and not pieces of text.

[00:02:45]
But also, you have to think about the quality of the training data. And when I talk about quality as well, it's if you want to build an application where what you're recognizing is animals, then you maybe don't want to look at a machine learning model that was trained with images of cars, for example.

[00:03:03]
Because it's not gonna be able to actually predict an animal if it doesn't know what an animal is. And there's also the quantity of the training data. So the more data you have, usually it's better, but again, it's a mix of quantity and quality. If you have a lot of data but it's either poorly labeled or it's not at all what you're actually trying to predict, then it's not going to be helpful to you.

[00:03:25]
And then what I sometimes like to see is I can have access to the list of classes and labels that it was trained with. So for some models that are open sourced by Google, you can have access to the list of classes so you can see what it was trained with.

[00:03:38]
And then you can see if what you're trying to predict is in this class as well. And sometimes it's not available, so sometimes you have to do extra research and see if you have access to maybe the research paper that was written and then the open source, the code out of that.

[00:03:52]
But sometimes they don't give you the link to the classes that it was trained with. So if you have access to that, it's great. Otherwise, give it a try and see what happens.

Learn Straight from the Experts Who Shape the Modern Web

  • In-depth Courses
  • Industry Leading Experts
  • Learning Paths
  • Live Interactive Workshops
Get Unlimited Access Now