(original) Stanford machine learning (by Andrew NG)---(week) Large scale machine learning & Application Example

Source: Internet
Author: User

This section is from the machine learning course, which is explained by Andrew Ng, and mainly introduces the large-scale machines learning and its application. Including random gradient descent method, dimensional batch gradient descent method, convergence of gradient descent method, online learning, map reduction and application examples: Photo OCR. The course address is: https://www.coursera.org/course/ml

(i) Large-scale machine learning

From the previous course we know that if our system is high variance, then increasing the number of samples will improve our system, assuming now we have 1 million training samples, imagine, if using gradient descent method, then each iteration to calculate the error of the 1 million training set, The calculation cost is obviously very large. So is there any way to solve it?

Random gradient descent (Stochastic gradient descent)

The previous batch gradient descent method defines the cost function as the error for all training samples and:

In contrast to the previous gradient descent method, we redefine the error of the cost function as a single training sample:

Algorithm Flow:

First, the training set randomly "shuffle", let the training data disorderly sequence;

Each iteration computes only a single error and then updates θ, so that not every step is the "right" direction, so the algorithm will "approach" the global minimum, but may just hover around the minimum value, as shown in:

Micro-Batch Gradient descent method (Mini‐batch gradient descent)

The micro-batch gradient descent method is between the batch gradient descent and the random gradient descent, and each iteration calculates the error of the B training samples.

PS: usually makes B between 2-200.

Stochastic gradient descent convergence (Stochastic gradient descent convergence)

In batch gradient descent, we can determine convergence by plotting the function of the number of J and iteration. But in large-scale machine learning, the computational cost is too great.

In a random gradient descent, the cost (θ, (x (i), Y (i)) is calculated before each iteration, for example, the average of cost (θ, (x (i), Y (i)) is plotted for every 1000 iterations.

    • Sometimes, we get a bumpy but not noticeably reduced image (left), which allows the image to be flattened by increasing the iteration interval (such as 2000 iterations of the average), and if the function graph is still improved, the model has errors.
    • Sometimes, we get a constantly rising image (right), which can be solved by reducing the learning rate α.

In addition, we can reduce the learning rate α as the number of iterations increases, using the following equation:

So when we approach the minimum point, through the learning rate, we can make the algorithm converge, as shown in:

elearning (Online learning)

Suppose we run a logistics company, and when a user asks for a courier fee from A to B, we give a quote and the user may accept (Y=1) or Decline (y=0). Now we are going to build models to predict the likelihood that users will accept the offer.

In online learning, many websites have a constant flow of users, and when we build a model, we learn about a single instance, and once that instance has finished learning, it can be discarded. This allows our models to adapt and update the user's propensity.

Map Reduce and parallel operations (data parallelism)

If we have multiple computers (or a multi-core computer), let each computer (or each CPU of the computer) process a subset of the data and then sum the results so that the learning algorithm can be accelerated. The calculation flow is as follows:

For example, with 400 training samples and 4 computers, we can use the batch gradient descent method to divide the data into these 4 computers:

(ii) Application examples (Photo OCR)

Problem Description:The goal of photo OCR is to recognize text from a single image.

Algorithm steps:

    • Text detection (text detection)
    • Word segmentation (Character segmentation)
    • Character classification (Character classification)

Each of these tasks is the responsibility of a separate team, the following process:

Sliding window (Sliding windows)

1. Through the sliding window can extract objects from the image, such as to identify pedestrians in, you can select the previously trained pedestrian's picture size to cut the graph, and then identify the slices to determine whether they are pedestrians.

2. The following text segmentation, the text is divided into a single character, training set is a single character picture and two connected characters between the picture.

3. Finally, character recognition can be achieved through our previous neural network and logistic regression algorithm.

Get data (Getting lots of data:artificial data synthesis)

For the high variance problem, we need to get more training data, so how to get the data under limited conditions?

In the OCR problem, we can download a variety of fonts, and then with different backgrounds to create some training data, in addition, we can also use the existing data to modify it, such as the character picture deformation, rotation, blur and other processing, resulting in a large number of training data.

What should I do next? (Ceilinganalysis)

In some applications of machine learning, which often requires multiple steps to achieve the final prediction, should we devote our energies to improving that part?

Take the OCR problem as an example, the process is as follows:

We can select a part of each process, manually provide 100% of the correct output, and then see the overall lift effect. Assuming that the overall effect of our model is 72%, if the text detection output is correct, the model effect is 89%, and if the output of the other character segmentation is correct, the model effect is 90% (that is, only 1% is raised). This means that we should devote more effort to the text detection.

Practice

This is the last lesson of this course, there is no homework, here is a list of some practice topics:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.