MindSpore
  • mindspore
  • mindspore.ops
  • mindspore.nn
  • mindspore.mint
  • mindspore.common.initializer
  • mindspore.amp
  • mindspore.train
  • mindspore.parallel
  • mindspore.runtime
  • mindspore.device_context
  • mindspore.communication
  • mindspore.dataset
  • mindspore.numpy
  • mindspore.scipy
  • mindspore.multiprocessing
  • mindspore.utils
  • mindspore.experimental
  • mindspore.ops.primitive
  • mindspore.boost
  • mindspore.nn.probability
  • mindspore.rewrite
  • mindspore.hal
  • Environment Variables
  • PyTorch and MindSpore API Mapping Table
MindSpore
  • »
  • API »
  • mindspore.scipy »
  • mindspore.scipy.optimize.line_search
  • View page source

mindspore.scipy.optimize.line_search

View Source On Gitee
mindspore.scipy.optimize.line_search(f, xk, pk, jac=None, gfk=None, old_fval=None, old_old_fval=None, c1=1e-4, c2=0.9, maxiter=20)[source]

Inexact line search that satisfies strong Wolfe conditions.

Algorithm 3.5 from Wright and Nocedal, 'Numerical Optimization', 1999, pg. 59-61

Note

line_search is not supported on Windows platform yet.

Parameters
  • f (function) – function of the form f(x) where x is a flat Tensor and returns a real scalar. The function should be composed of operations with vjp defined.

  • xk (Tensor) – initial guess.

  • pk (Tensor) – direction to search in. Assumes the direction is a descent direction.

  • jac (function) – the gradient function at x where x is a flat Tensor and returns a Tensor. The function can be None if you want to use automatic credits.

  • gfk (Tensor) – initial value of value_and_gradient as position. Default: None .

  • old_fval (Tensor) – The same as gfk. Default: None .

  • old_old_fval (Tensor) – unused argument, only for scipy API compliance. Default: None .

  • c1 (float) – Wolfe criteria constant, see ref. Default: 1e-4 .

  • c2 (float) – The same as c1. Default: 0.9 .

  • maxiter (int) – maximum number of iterations to search. Default: 20 .

Returns

LineSearchResults, results of line search results.

Supported Platforms:

GPU CPU

Examples

>>> import numpy as onp
>>> from mindspore.scipy.optimize import line_search
>>> from mindspore import Tensor
>>> x0 = Tensor(onp.ones(2).astype(onp.float32))
>>> p0 = Tensor(onp.array([-1, -1]).astype(onp.float32))
>>> def func(x):
...     return x[0] ** 2 - x[1] ** 3
>>> res = line_search(func, x0, p0)
>>> print(res.a_k)
1.0
Previous Next

© Copyright MindSpore.

Built with Sphinx using a theme provided by Read the Docs.
OSZAR »