Optimizing Plane Fitting Using Stochastic Gradient Descent

In summary, the conversation discussed fitting a plane to a data set using gradient descent. The objective function to be minimized was shown and the parameters to be found were w_1, w_2, and w_3. The iterative method for updating the parameters was also mentioned. The individual speaking wanted to confirm the validity of their solution and mentioned that it worked well when implemented in C++.
  • #1
zzmanzz
54
0

Homework Statement



Suppose I wish to fit a plane
[tex] z = w_1 + w_2x +w_3y [/tex]
to a data set [tex] (x_1,y_1,z_1), ... ,(x_n,y_n,z_n) [/tex]

Using gradient descent

Homework Equations



http://en.wikipedia.org/wiki/Stochastic_gradient_descent

The Attempt at a Solution



I'm basically trying to figure out the 3-dimensional version of the example on wiki.
The objective function to e minimized is:

[tex] Q(w) = \sum_{i = 1}^n Q_i(w) = \sum_{i = 1}^n (w_1 + w_2x_i + w_3y_i - z_i)^2 [/tex]
I want to find the parameters of [tex]w_1,w_2,w_3 [/tex]

The iterative method updates the parameters [tex]w^{(0)}_1,w^{(0)}_2,w^{(0)}_3 [/tex]
1-step in the iteration
[tex]
\left( \begin{array}{ccc}
w^{(1)}_1 \\
w^{(1)}_2\\
w^{(1)}_3 \end{array} \right) = \left( \begin{array}{ccc}
w^{(0)}_1 \\
w^{(0)}_2 \\
w^{(0)}_3 \end{array} \right) + \alpha \times \left( \begin{array}{ccc}
2(w^{(0)}_1 + w^{(0)}_2x_i + w^{(0)}_3 y_i - z_i) \\
2x_i(w^{(0)}_1 + w^{(0)}_2x_i + w^{(0)}_3 y_i - z_i) \\
2y_i(w^{(0)}_1+ w^{(0)}_2x_i + w^{(0)}_3 y_i - z_i) \end{array} \right) [/tex]

[tex]\alpha [\tex] is the step size.
 
Last edited:
Physics news on Phys.org
  • #2
Looks good. Whats your question?
 
  • #3
Just wanted to make sure that I didn't cheat or something in my solution. When I run it in c++ it works very well.
 

1. What is Stochastic Gradient Descent?

Stochastic Gradient Descent (SGD) is a popular optimization algorithm used in machine learning to minimize a cost function by iteratively adjusting the parameters of a model. It is a stochastic approximation of the Gradient Descent algorithm and is particularly useful for large datasets.

2. How does Stochastic Gradient Descent differ from Gradient Descent?

Unlike Gradient Descent which uses the entire dataset to calculate the gradient and update the parameters, Stochastic Gradient Descent randomly selects a subset of the data, known as a "mini-batch", to calculate the gradient and update the parameters. This makes SGD computationally more efficient and suitable for large datasets.

3. What is the learning rate in Stochastic Gradient Descent?

The learning rate in Stochastic Gradient Descent is a hyperparameter that controls the size of the steps taken towards the minimum of the cost function. It is usually a small value and needs to be carefully chosen to ensure the algorithm converges to the minimum without overshooting or getting stuck in a local minimum.

4. How can one ensure convergence in Stochastic Gradient Descent?

Convergence in Stochastic Gradient Descent can be ensured by carefully selecting the learning rate, using an appropriate number of iterations, and shuffling the data before each iteration. Additionally, using a decaying learning rate or momentum can also improve the convergence of the algorithm.

5. What are the advantages of using Stochastic Gradient Descent?

Stochastic Gradient Descent is computationally efficient and can handle large datasets, making it suitable for training deep learning models. It also converges faster compared to batch Gradient Descent. Additionally, SGD can escape local minima and can be used for online learning, where the model is updated with new data points as they become available.

Similar threads

  • Calculus and Beyond Homework Help
Replies
16
Views
1K
  • Calculus and Beyond Homework Help
Replies
6
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
553
  • Advanced Physics Homework Help
2
Replies
36
Views
2K
  • Linear and Abstract Algebra
Replies
3
Views
2K
  • Calculus and Beyond Homework Help
Replies
4
Views
842
  • Calculus and Beyond Homework Help
Replies
1
Views
1K
  • Calculus and Beyond Homework Help
Replies
12
Views
994
Replies
27
Views
940
  • Calculus and Beyond Homework Help
Replies
1
Views
1K
Back
Top