airoldilab / sgd

An R package for large scale estimation with stochastic gradient descent
62 stars 18 forks source link

generalize to sgd with mini batches #93

Open dustinvtran opened 7 years ago

dustinvtran commented 7 years ago

From an e-mail exchange with Kamal Hamidieh:

First of all, thank you for the SGD package. Just a quick question: Is there a setting in the command sgd where I can force sgd to perform batch gradient descent? I know the purpose of the package is to do the stochastic version but I like to know if this is possible.

gradient always does data subsampling with one data point, e.g., see below:

https://github.com/airoldilab/sgd/blob/master/src/model/glm_model.h#L44

the gradient function can be generalized to do mini batches. alternatively, another way to write it is to write the mini-batch loop in the sgd methods:

https://github.com/airoldilab/sgd/blob/master/src/sgd/explicit_sgd.h#L25