From f2db24b50575fa99e0f3525c832cd73d9b3526e2 Mon Sep 17 00:00:00 2001 From: Vladimir Chalupecky Date: Tue, 10 Nov 2015 15:16:29 +0900 Subject: [PATCH] Clean up docs for GradientDescent --- gradientdescent.go | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/gradientdescent.go b/gradientdescent.go index fdb72f0..948a616 100644 --- a/gradientdescent.go +++ b/gradientdescent.go @@ -6,25 +6,27 @@ package optimize import "github.com/gonum/floats" -// GradientDescent is a Method that performs gradient-based optimization. -// Gradient Descent performs successive steps along the direction of the -// gradient. The Linesearcher specifies the kind of linesearch to be done, and -// StepSizer determines the initial step size of each direction. If either -// Linesearcher or StepSizer are nil, a reasonable value will be chosen. +// GradientDescent implements the steepest descent optimization method that +// performs successive steps along the direction of the negative gradient. type GradientDescent struct { + // Linesearcher selects suitable steps along the descent direction. + // If Linesearcher is nil, a reasonable default will be chosen. Linesearcher Linesearcher - StepSizer StepSizer + // StepSizer determines the initial step size along each direction. + // If StepSizer is nil, a reasonable default will be chosen. + StepSizer StepSizer ls *LinesearchMethod } func (g *GradientDescent) Init(loc *Location) (Operation, error) { - if g.StepSizer == nil { - g.StepSizer = &QuadraticStepSize{} - } if g.Linesearcher == nil { g.Linesearcher = &Backtracking{} } + if g.StepSizer == nil { + g.StepSizer = &QuadraticStepSize{} + } + if g.ls == nil { g.ls = &LinesearchMethod{} }