Machine Learning Public Course notes (10): Large-scale machine learning

Source: Internet
Author: User

Batch gradient drop (batch Gradient descent)

For the example of linear regression, the formula for parameter updating with gradient descent algorithm is $$\theta_j=\theta_j-\alpha\frac{1}{m}\sum\limits_{i=1}^{m} (H_\theta (x^{(i)})-y^{(i)}) x_j^{(i)}$$ can see each parameter update once, the entire training set needs to be scanned once, so called batch gradient descent , this update method for a large set of parameters (such as m=100,000,000) run very slow, in order to speed up the algorithm run, A random gradient descent is proposed.

Random gradient descent (Stochastic Gradient descent)

The parameter $\theta$ is updated with only one example at a time, with linear regression as an example, and the random gradient descent algorithm

1. Randomly rearrange the entire training set (shuffle)

2. Repeat the following procedure multiple times (you can repeat 1~10 times when the data set is large)

For i = 1, ..., m {
$\theta_j=\theta_j-\alpha (H_\theta (x^{(i))-y^{(i)}) x_j^{(i)}$
}

Small batch gradient descent (Mini-batch Gradient descent)

Between the batch gradient descent and the random gradient descent, batch gradient processing uses all M example for parameter updating, and the random gradient descent only uses 1 example to update the parameters, while the mini gradient descent uses B (1<b<m) example for parameter updating. Still taking linear regression as an example, join us with m=1000 example, we can update the parameters with every b=10 example, for example:

Repeat {
For i = 1, 11, 21, ..., 991 {
$\theta_j=\theta_j-\alpha\frac{1}{10}\sum\limits_{k=i}^{i+9} (H_\theta (x^{(k)})-y^{(k)}) x_j^{(k)}$
}
}

Convergence of algorithms

Batch gradient processing can ensure that the algorithm converges to the minimum (if the selected learning rate $\alpha$ appropriate), you can plot cost function $j (\theta) $ with the number of iterations of the curve, if the curve is always falling, it can converge, conversely, the need to adjust the learning rate.

Random gradient descent does not guarantee that the algorithm converges to the minimum value, the final result may be to walk around the minimum value, in order to observe its convergence characteristics, can plot every 100 (1000) iterations of 100 example cost function function $\text{cost} (\theta, (x^{( i)}, y^{(i)}) $ of the average, if it is a downtrend, it can be convergent, otherwise you may need to adjust the increase or reduce the number of example (change 100 to 1000 or 10, etc.), reduce or increase the learning rate.

elearning (Online learning)

The previous algorithm has a fixed training set to train the model, when the model is well trained to classify and return the future example. Online learning is different, it updates the model parameters for each new example, so there is no need for a fixed training set, and the way to update the parameters is to use random gradient descent. The advantage of online learning is that the model parameters can be adjusted with the user's preference, with logistic regression as an example, the online learning method is as follows:

Repeat Forever {
1. Get current example (x, y)
2. Parameter update using (x, y): $\theta_j=\theta_j-\alpha (H_\theta (x)-y) x_j$
}

MapReduce and Data parallelization

This part of Andrew Ng does not speak much, it can be said that only a number of machine summation problems, such as how to solve 1+2+3+...+1000? Map process: Four machines calculate 1+2+...+250,251+252+...+500, 501+502...+750,751+752+...+1000, then reduce process: The result of summing four machines sum1,sum2,sum3, The sum4 is aggregated onto a single machine to calculate the SUM1+SUM2+SUM3+SUM4.

Machine Learning Public Course notes (10): Large-scale machine learning

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.