@@ -6,25 +6,27 @@ package optimize
6
6
7
7
import "github.com/gonum/floats"
8
8
9
- // GradientDescent is a Method that performs gradient-based optimization.
10
- // Gradient Descent performs successive steps along the direction of the
11
- // gradient. The Linesearcher specifies the kind of linesearch to be done, and
12
- // StepSizer determines the initial step size of each direction. If either
13
- // Linesearcher or StepSizer are nil, a reasonable value will be chosen.
9
+ // GradientDescent implements the steepest descent optimization method that
10
+ // performs successive steps along the direction of the negative gradient.
14
11
type GradientDescent struct {
12
+ // Linesearcher selects suitable steps along the descent direction.
13
+ // If Linesearcher is nil, a reasonable default will be chosen.
15
14
Linesearcher Linesearcher
16
- StepSizer StepSizer
15
+ // StepSizer determines the initial step size along each direction.
16
+ // If StepSizer is nil, a reasonable default will be chosen.
17
+ StepSizer StepSizer
17
18
18
19
ls * LinesearchMethod
19
20
}
20
21
21
22
func (g * GradientDescent ) Init (loc * Location ) (Operation , error ) {
22
- if g .StepSizer == nil {
23
- g .StepSizer = & QuadraticStepSize {}
24
- }
25
23
if g .Linesearcher == nil {
26
24
g .Linesearcher = & Backtracking {}
27
25
}
26
+ if g .StepSizer == nil {
27
+ g .StepSizer = & QuadraticStepSize {}
28
+ }
29
+
28
30
if g .ls == nil {
29
31
g .ls = & LinesearchMethod {}
30
32
}
0 commit comments