 LFD Book Forum HW5 Q9: SGD and Epochs?

#1
 Ziad Hatahet Member Join Date: Apr 2013 Location: San Francisco, CA Posts: 23 HW5 Q9: SGD and Epochs?

I think I may be missing something concerning SGD. The description of the problems for Logistic Regression states that: An epoch is a full pass through the data points.

Does that mean that each of the given answers corresponds to 100x the number iterations (e.g. answer [a] is 350, so we make 3,500 iterations before converging?)

The way I am currently implementing SGD is as follows (pseudo-code):
Code:
```for each trial {
generate N points, with corresponding target function and Y
set weight vector to |0|
while true {
pick random point xn, and corresponding yn
calculate e = -yn*xn/(1 + exp(yn*wt*xn)
w(t+1) = w(t) - learning_rate*e
break if ||w(t+1) - w(t)|| < tolerance
}
use weight vector to calculate Eout = E[ln(1 + exp(-Y*w*X)], for M new points, and find the mean Eout
}```
In this case, I am taking the mean of the number of iterations in the inner while loop as the answer for Q9. Am I doing something wrong?

Thanks
#2 yaser Caltech Join Date: Aug 2009 Location: Pasadena, California, USA Posts: 1,477 Re: HW5 Q9: SGD and Epochs?

Quote:
 Originally Posted by Ziad Hatahet The description of the problems for Logistic Regression states that: An epoch is a full pass through the data points. Does that mean that each of the given answers corresponds to 100x the number iterations (e.g. answer [a] is 350, so we make 3,500 iterations before converging?)
Correct. You should average the number of epochs rather than the number of single-point SGD iterations. The termination criterion necessitates that you finish whole epochs.
__________________
Where everyone thinks alike, no one thinks very much
#3
 Ziad Hatahet Member Join Date: Apr 2013 Location: San Francisco, CA Posts: 23 Re: HW5 Q9: SGD and Epochs?

Quote:
 Originally Posted by yaser Correct. You should average the number of epochs rather than the number of single-point SGD iterations. The termination criterion necessitates that you finish whole epochs.
But if we will be making an entire pass over all data points in each iteration before checking the termination condition, how is this cheaper than batch GD?

Edit: I just saw the discussion here: http://book.caltech.edu/bookforum/showthread.php?t=458.

Thanks Prof. Yaser Thread Tools Show Printable Version Email this Page Display Modes Linear Mode Switch to Hybrid Mode Switch to Threaded Mode Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts BB code is On Smilies are On [IMG] code is On HTML code is Off Forum Rules
 Forum Jump User Control Panel Private Messages Subscriptions Who's Online Search Forums Forums Home General     General Discussion of Machine Learning     Free Additional Material         Dynamic e-Chapters         Dynamic e-Appendices Course Discussions     Online LFD course         General comments on the course         Homework 1         Homework 2         Homework 3         Homework 4         Homework 5         Homework 6         Homework 7         Homework 8         The Final         Create New Homework Problems Book Feedback - Learning From Data     General comments on the book     Chapter 1 - The Learning Problem     Chapter 2 - Training versus Testing     Chapter 3 - The Linear Model     Chapter 4 - Overfitting     Chapter 5 - Three Learning Principles     e-Chapter 6 - Similarity Based Methods     e-Chapter 7 - Neural Networks     e-Chapter 8 - Support Vector Machines     e-Chapter 9 - Learning Aides     Appendix and Notation     e-Appendices

All times are GMT -7. The time now is 12:18 PM.