MindSpore

设计

  • 全场景统一
  • 函数式微分编程
  • 动静态图结合
  • 异构并行训练
  • 分布式并行
  • 中间表达MindIR
  • 高性能数据处理引擎
  • 图算融合加速引擎
  • 二阶优化
  • 可视化调试调优↗
  • 安全可信↗
  • 术语

规格

  • 基准性能
  • 网络支持
  • 算子支持
  • 语法支持

API

  • mindspore
  • mindspore.amp
  • mindspore.common.initializer
  • mindspore.communication
  • mindspore.dataset
  • mindspore.dataset.audio
  • mindspore.dataset.config
  • mindspore.dataset.text
  • mindspore.dataset.transforms
  • mindspore.dataset.vision
  • mindspore.mindrecord
  • mindspore.nn
  • mindspore.nn.probability
  • mindspore.nn.transformer
  • mindspore.numpy
  • mindspore.ops
  • mindspore.ops.functional
  • mindspore.parallel.nn
  • mindspore.scipy
    • mindspore.scipy.linalg
    • mindspore.scipy.optimize
      • mindspore.scipy.optimize.line_search
      • mindspore.scipy.optimize.minimize
    • mindspore.scipy.sparse.linalg
  • mindspore.boost
  • C++ API↗

API映射

  • PyTorch与MindSpore
  • TensorFlow与MindSpore

迁移指南

  • 概述
  • 准备工作
  • 网络脚本分析
  • 网络脚本开发
  • 网络调试
  • 精度调优
  • 性能调试
  • 推理执行
  • 网络迁移调试实例
  • 常见问题

FAQ

  • 安装
  • 数据处理
  • 执行问题
  • 网络编译
  • 算子编译
  • 第三方框架迁移使用
  • 性能调优
  • 精度调优
  • 分布式配置
  • 推理
  • 特性咨询

RELEASE NOTES

  • Release Notes
MindSpore
  • »
  • mindspore.scipy »
  • mindspore.scipy.optimize.line_search
  • View page source

mindspore.scipy.optimize.line_search

mindspore.scipy.optimize.line_search(f, xk, pk, gfk=None, old_fval=None, old_old_fval=None, c1=0.0001, c2=0.9, maxiter=20)[源代码]

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.

  • 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:

CPU GPU

Examples

>>> import numpy as onp
>>> from mindspore.scipy.optimize import line_search
>>> from mindspore.common 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.