Aiyaaa..Everyone Should Know A.I. In 2023
- Speaker : Gabby Liau
- Time : 3.00pm - 4.00pm
- Date : 26th October 2022, Wednesday
Artificial Intelligence (A.I.) – An emerging technology that has started to become popular since 2010. But, do you know that the idea of A.I. was actually being proposed very early in 1950’s? After the efforts of so many years, A.I. technology has became mature enough to be implemented into many application scenarios in our daily life.
In our upcoming session, we will talk about:
(1) Use cases of A.I. in our daily life,
(2) Overall flow of developing an AI model,
as developing an AI model is not just a single-step process, but a multi-stage process that requires the use of different techniques to complete.
(3) Easy-to-understand Python programming that builds an AI model.
From data collection to model evaluation, we will understand some basic ideas of some core techniques that we can utilize to earn a good AI model.
Who should attend?
AI beginners.
Why should attend?
After the session, participants will get to know more about some AI application scenarios and the core concepts of AI development.
Ms. Gabby Liau
Trainer at Infosyte, Huawei and Microsoft Certified Trainer
Gabby – the leading Infosyte trainer on futuristic technology in the company who specialises in Artificial Intelligence and Cloud services. She has delivered over many classes to trainees from different parts of the world including Malaysia, Singapore, Hong Kong, Indonesia, South Africa, Thailand and many more!
Click for Full Video:
Today’s session features a very interesting topic that we will be discussing. As you may have seen from our title, we will be talking about AI. In 2022, everyone should be familiar with AI, which stands for artificial intelligence. Our speaker, Gabby, who is one of our in-house trainers specializing in AI technology, will explain more about AI and how it has impacted our lives and technology. We will also cover the definition of AI and its applications. At the end of our session, Gabby will demonstrate how to construct a simple deep neural network model to detect images using Python.
During the first part of our session, we will discuss daily examples of AI applications. Often, we use AI without even realizing it. Later, we will talk about the definition of AI, what it can do, where it can be applied, and the process flow of constructing an AI model, starting with data collection. Our session will also include a Q&A session with prizes and exciting promotions to be shared at the end. Without further ado, I will pass the floor to Gabby. Thank you, Leo, and good afternoon, everyone.
Daily example (1) – Personalized Recommendation
You can see that one of the daily examples of AI is personalized recommendations. I believe that all of us use online shopping platforms, and for example, as shown in the slide, when you go to Shopee, they will recommend products that you might like. Similarly, when you go to Netflix, they recommend movies based on your previous watch history. Additionally, when you use Facebook, they recommend people you may know. All of these are examples of AI applications as they use AI to analyze your previous browsing history or data to provide you with relevant recommendations. Therefore, personalized recommendations are a common example of AI applications in our daily lives.
Daily example (2) – Autonomous Driving
As you can see, one of the daily examples is personalized recommendations. I believe that every one of us goes to online shopping platforms. For example, as shown in the slides, when you go to Shoppie, the online shopping platform, they will recommend products that you might like. Similarly, when you use Netflix or Facebook, they also recommend movies or people you may know. These are all examples of AI applications as they use AI to analyze your previous browsing or searching history to provide recommendations. This is just one example of how AI is used in our daily lives.
Apart from recommendation systems, we also have autonomous driving. You might have heard about it before. With this system, vehicles can drive themselves on the road. Detectors like smart cameras, radar, and ultrasound sensors are embedded around the car, enabling it to perceive its surroundings. These detectors help the car to collect data about the surrounding environment, and this data is fed to the processor. The processor uses an AI model to calculate results based on this data. The vehicle control system then determines the car’s speed, whether it should slow down, stop, turn left, or right, based on the model prediction. For example, if a smart camera detects a person trying to cross the road at a distance of around 10 meters ahead of the car, the image will be sent to the AI model. Once the person is detected, the model will return a result that can make the car slow down and ultimately stop before hitting the person. This is how AI is used in autonomous driving.
Another example of an AI application is impersonation, which I believe many of you have seen before. This technique involves replacing a person’s face with someone else’s or overlaying expressions onto another person’s face. This is achieved through a technique called deep fake. Let me show you a video on YouTube to demonstrate the amazing capability of this technique. In the video, Tom Cruise’s face has been replaced with another person’s face using deep fake technology, which has become a viral hit on TikTok.
Chris, a VFX and AI artist, explains in the video that a deep fake is a video where someone’s face has been changed into another. Chris uses deep fake to overlay Tom Cruise’s face onto Miles Fisher’s in his videos. To create a deep fake video, Chris trains a computer model with thousands of images of a certain character’s expressions and angles. In the end, he has one big model that contains all of Tom Cruise’s emotions.
Although deep fake technology has been misused to create fake videos, it can also be used creatively to make videos more interesting. This is another example of how AI is integrated into our daily lives.
In case you are wondering how deep fake videos are created, the working principle behind this technique is actually straightforward.
If we look at the working principle behind this technique, they use an AI algorithm called an Autoencoder. An Autoencoder is an algorithm that consists of two parts: an encoder and a decoder. Together, they make up the Autoencoder. It is a type of algorithm.
With this algorithm, swapping the faces of two people, such as Tom Cruise and Brad Pitt, is simple. All you need are two autoencoders. First, fit the images of the faces you want to swap into their respective encoders. The encoder algorithm will then summarize the key features of each person’s face into latent space. Next, you can take the features from one person’s latent space and fit them into the decoder of the other person. The decoder will then use those features to reconstruct the face of the other person with the features of the first person. This process can be done in reverse to create the other face with the features of the first person. By using the autoencoder and generative adversarial network (GAN) algorithms together, developers can create even more realistic results. This is an example of how AI technology, such as autoencoders, can be used in various scenarios to enhance videos and images.
After discussing the various examples, let us now return to the definition of AI. AI is a technology that aims to simulate human intelligence in machines. The goal is to make machines work and behave similarly or even better than humans. We achieve this by simulating human intelligence into machines. For instance, in autonomous driving, we simulate human visual intelligence into the machine, such as our vehicle, so it can see what appears on the road, just like how humans do it. Another example is virtual assistants like Apple Siri, Microsoft Cortana, and others, where we simulate human verbal intelligence so that they can understand and respond to our language and interactions, just like humans do. Depending on our goals and targets, we can design AI systems with different or multiple simulated intelligence to perform tasks like humans or even better. This is the definition of AI: simulating human intelligence into machines.
These are the four very important elements of AI. When we want to construct an AI system, we must use these four elements and get them right because without any one of them, we cannot have a good AI system. The first element is the scenario. You have to determine the scenario first before you can know what kind of AI system you have to build. For example, if your company wants to come up with an electronic attendance system, you will need to come up with a facial recognition system that can help with that. Based on the scenario, you will try to collect relevant data for your AI prediction. If you want to build a model for facial recognition, you will need to collect image data from your colleagues and bosses. Then you will use this data to train your algorithm. With the data and algorithm, of course, you need to support all the processing using sufficient computing power. Only with sufficient computing power, can you run everything here in a faster way. For example, something that can run in three minutes may take three hours or sometimes three days to complete the entire processing process if you do not have enough computing power. That’s why these four elements are very important in AI, and we have to get all of them accurately and in the best way possible so that we can construct our AI system in the best possible manner.
When we talk about AI, we often hear terms such as machine learning and deep learning. However, many people don’t understand the differences between these terms or their relationship with AI. AI is a broad field that involves simulating human intelligence in machines. Machine learning is a technique for finding the best algorithms for our AI system. It’s a subset of AI that focuses on the study of algorithms. Deep learning is a type of algorithm that can learn more complex patterns from data than other machine learning algorithms, such as decision trees or linear regression. Deep learning is popular because it can perform complex tasks that other algorithms cannot handle. Therefore, deep learning is often the preferred algorithm for complex tasks in AI systems. In conclusion, AI is a big scope, and machine learning is a subset of AI that focuses on finding the best algorithms for an AI system. Deep learning is a type of machine learning algorithm that is often preferred for complex tasks due to its ability to learn more complex patterns from data.
Process of Building AI Model
As we can see from this flow, the overall process of building an AI model involves several steps. First, we need to identify the scenario that we want the AI model to address. Once we have identified the scenario, we can start collecting and cleansing the relevant data. Then, we can move on to building and training the AI model, followed by evaluating its performance and making necessary adjustments. Finally, we can deploy the AI model into active production. This process ensures that the AI model is constructed and optimized in a systematic manner, allowing it to effectively address the intended scenario.
If you look at each step of the process one by one, the first step is to collect data. You can collect data from multiple different sources using various techniques, and you need to ensure that the data you collect is of sufficient quality and quantity to train your model later. It doesn’t matter which technique you use to collect the data. The slide shows that there are multiple methods for collecting data, including web scraping, using your own dataset, and collecting live data by implementing sensors in a target environment. All of these are common techniques that people can use to collect data.
After collecting the data, the next step is to perform data cleansing because sometimes the data contains dirty data such as missing values, invalid data, or data in the wrong format. It’s important to clean the data before using it to train the model to ensure that the data quality is good and there are no outliers in the data set that can confuse the model. This is because if you feed dirty data into the model, it may learn wrongly from the outlier data, which can affect the accuracy of the model. Therefore, it’s crucial to ensure that the data is of good quality by performing data cleansing.
After data cleansing, the next step is to extract and select features from the dataset. A feature is a piece of information that describes the data, such as the area, distance from the school, color, number of windows, and rooms of a house in a housing dataset. These features help us understand the data and its relationship with what we want to predict. For example, if we want to predict house prices based on the features of the house, we need the model to learn the relationship between the features and the house price.
However, not all features are relevant to the prediction. For instance, the color of the house is not related to its price as it can be changed easily. Therefore, we need to make sure that only relevant features are included in the dataset to train the model. Eliminating irrelevant features is crucial to building an accurate model. After selecting the relevant features, we can then use the dataset to train the model.
To ensure that this little boy becomes the best player in town, he needs to figure out the best distance from the basket, speed, and angle to shoot successfully. These are all parameters that he needs to adjust during his training process. Similarly, for a model, the parameters in the algorithm need to be optimized for the best model performance. Therefore, during the training process, the optimal parameter values need to be found.
In a typical AI algorithm or model, you will usually find three core elements: output, parameters, and input. For example, if we want to predict house prices based on features such as the house area, distance from school, and the number of rooms, we can use these as the inputs. To calculate the house price, we would fit this information into the algorithm and multiply the input values with the parameters W1, W2, and W3. These parameters are essential in getting the correct prediction.
Incorrect parameter values would lead to a wrong prediction, as they directly affect the prediction outcome. Therefore, finding the optimal parameter values is crucial during model training to ensure accurate results.
Alright, so not every AI algorithm will look similar to typical AI algorithms. However, there are some common algorithms that we use frequently, such as polynomial regressions, logistic regressions, softmax, and even deep neural networks. While these different algorithms may appear very distinct, they all share three core elements: input, output, and parameters. Therefore, it is necessary to identify the appropriate parameter values for any algorithm you use, regardless of its type.
Before improving the model, we need to substitute the parameters with some values to see if they provide good results or not. After training the model, we must evaluate its predictive capabilities by comparing its predictions with the actual values. The difference between the predicted and actual values is called the loss value. A larger loss value indicates a poorer model, while a smaller loss value indicates a better one. During model training, we aim to find the best parameters that will minimize the loss value, indicating a model that predicts values very close to the actual ones. Therefore, we will try to optimize the model to minimize the loss value after training.
After evaluating the model, if we find that it is not performing well and the predictions are inaccurate, we need to optimize it. To optimize the model, we use an optimization algorithm called an optimizer to recalculate the parameters and minimize the loss. We calculate the loss value based on the evaluation step and then use it to compute the gradient value using differentiation techniques. From the gradient value, we can recalculate the new parameter values and adjust them gradually until we achieve the minimum loss. This is the optimization step.
The gradient value is a magical tool because it helps determine the direction to adjust the parameter values. For example, if a parameter value of 0.1 is not giving good results, we need to adjust it, but we don’t know whether to increase or decrease it. The gradient value tells us the direction to follow, just like a person standing in the middle of a hill blindfolded, trying to get to the bottom. The person would follow the steepest gradient to reach the bottom. Similarly, the gradient value tells us in which direction to adjust the parameter values to find the best ones. Using an optimizer, we can calculate the gradient value and adjust the parameters until we reach the minimum loss. This is the process we follow during model optimization.
So, after we have optimized the model, we can deploy it into production if we are satisfied with its predictions. We store the data and the model in the repository, and we implement a model-serving framework. When a client makes a request to make some predictions, they send the data to the model-serving framework. This framework retrieves the valuable model from the repository and processes the data with the model. Finally, it returns the result to the client. This is like a middleman that we use to serve the model for prediction in the production environment. This is how we deploy the model.
So this is the overall view of our AI model in production. The code is just one part of it, and of course, we need to have other elements like data collection mechanisms, monitoring system jobs to help us monitor our production applications, and service infrastructure to help us serve this model to the production environment. This is the overall view of our AI deployment in production.
Since we only have 10 minutes left, I’ll quickly demonstrate how to construct an AI model for image recognition. Imagine we have handwritten numbers, where each person’s handwriting is different. For instance, my number two may look different from yours. Given these variations, how can we train a model to recognize different handwriting? I’ll use the example of recognizing handwritten digits, such as the number seven, one, zero, or five. In this demo, I’ll show you how we can train a model to differentiate between these digits. This process is called handwritten digit recognition.
So it’s very simple, remember this process that I have mentioned previously. You know, starting from data collection all the way until we have our model deployed.
The steps we need to go through to get to this model are as follows:
First, we need to prepare the tools, which include importing commonly used modules such as OS, input, and TensorFlow. These modules will help us to construct our model.
After we have our tools prepared, we need to import the dataset. We can use the ‘dataset. madness. learn data’ module to load the data from the Google repository so that we can use it to train our model later. We have both the training and testing datasets.
After we have loaded the dataset with the module, we can check the shape of our data. We are going to train this model with image data, so we need to understand the nature of the data first. We can print the shape of the training and testing data to understand that there are 60,000 image data points for training and 10,000 data points for testing, and the dimensions of the data are 28 by 28.
Besides understanding the data’s dimension, we can also use the ‘plot’ module to visualize the data. This will help us to know how to work with the data.
The next step is to ensure that the data quality is good and that the data format fulfills the model requirements. To do this, we will modify the data, such as resetting the dimensions, sharpening the data, changing the type of data, and normalizing it.
After preprocessing the data, we can start constructing the model, which will be a deep neural network with multiple layers. We can define each layer one by one, starting with the first layer and adding additional layers.
Once we have constructed the model, we can fit the training data into it and start training the model. We can run this training 10, 15, or 20 times, depending on the model’s size and other parameters. After each training, the model’s performance will be calculated with a loss value, which indicates how well the model is performing.
As we train the model more, the performance improves, but there are limitations to this improvement. So, we need to balance the training time with the model’s accuracy to get the best possible results.