スキップしてメイン コンテンツに移動

ヘッセ行列

Introduction


今日は、ヘッセ行列を用いたテイラー展開について書こうと思います。
これは最適化を勉強するにあたって、とても大事になってくるので自分でまとめて残しておくことにしました。とくに、機械学習では最適化を必ず行うため、このブログのタイトルにもマッチした内容だと思います。
.

概要

  • ヘッセ行列の定義
  • ベクトルを用いたテイラー展開
  • 関数の最適性

ヘッセ行列の定義

仮定

f は次のような条件を満たす関数です。.
  • f はn次元ベクトルから実数値を出力します。
    このベクトルは次のように表せます。
    \[x = [x_1,x_2,,,,x_n]\]
  • \(\forall x_i , i \in {1,2,,,n}\), f は二回偏微分可能です。

定義

ヘッセ行列は \(\frac{\partial^2}{\partial x_i \partial x_j}を (i,j)要素に持ちます。\)
よってヘッセ行列は次のように表せます。
\[ H(f) = \left( \begin{array}{cccc} \frac{\partial^ 2}{\partial x_1^2} & \frac{\partial^2 f}{\partial x_1 \partial x_2} & &\ldots \frac{\partial^2 f}{\partial x_1 \partial x_n} \\ \frac{\partial^ 2 f}{\partial x_1 \partial x_2} & \frac{\partial^ 2 f}{\partial x_2^ 2} & \ldots & \frac{\partial^2 f}{\partial x_2 \partial x_n} \\ \vdots & \vdots & \ddots & \vdots \\ \frac{\partial^ 2 f}{\partial x_n \partial x_2} & \frac{\partial^ 2 f}{\partial x_n \partial x_2} & \ldots & \frac{\partial^2 f}{\partial x_n^2} \\ \end{array} \right) \]

ベクトルを用いたテイラー展開

テイラー展開を二次の項まで行った式を与えます。
\[f(a+h) = f(a) + \nabla f(a) h + \frac{1}{2} h^T \nabla f(a) h + R_3\]
ただし、 \(H=\nabla ^2 f\) はヘッセ行列です。
大事なのは二次の項までで止めていることです。理由は最適化できるようにです。

関数の最適性

定置性

  • \(n \times n\)行列A が 正定置
    \(\forall x \in\)n次元ベクトル空間、\(z^T A z > 0\)
  • \(n \times n\)行列A が 負定置
    \(\forall x \in\)n次元ベクトル空間、\(z^T A z < 0\)
  • \(n \times n\)行列A が 半正定置
    \(\forall x \in\)n次元ベクトル空間、\(z^T A z => 0\)
  • \(n \times n\)行列A が 半不定値
    \(\forall x \in\)n次元ベクトル空間、\(z^T A z <= 0\)
\(z^T A z\) は二次形式と呼ばれています。

最適性

もちろん上記で書いた二次の項までのテイラー展開の式は二次形式を含みます。
よって関数の最適性は次のように考えられます。
  • H(a)(ヘッセ行列) が正定置\(\implies\)f(a) は極小値.
  • H(a)(ヘッセ行列) が負定置\(\implies\) f(a) は極大値

Reference

https://ja.wikipedia.org/wiki/%E3%83%98%E3%83%83%E3%82%BB%E8%A1%8C%E5%88%97
http://www2.kaiyodai.ac.jp/~takenawa/optimization/resume10-1.pdf
http://www.dais.is.tohoku.ac.jp/~shioura/teaching/mp04/mp04-8.pdf
http://tau.doshisha.ac.jp/lectures/2008.calculus-II/html.dir/node43.html

コメント

このブログの人気の投稿

Rolle’s theorem

Introduction 日本語 ver This post is written Rolle’s theorem. The mean-value theorem is proved by Rolle’s theorem. I will write Mean-value theorem at a later. I introduce Maximum principle because proving Rolle’s theorem need Maximum principle. Maximum principle It is very easy. f is continuous function on bounded closed interval.\(\implies\)** f have max value.** Proof This proof is difficult. I write this proof in other posts. Maximum Principle Rolle’s theorem f is continuous function on [a,b] and differentiable function on (a,b). \[f(a) = f(b) \implies \exists ~~c ~~s.t~~ f'(c) = 0 , a<c<b\] Proof f(x) is constant function \[\forall c \in (a,b) , f'(c) = 0\] else when \(\exists t ~~s.t~~f(a) < f(t)\), \(\exists c ~~s.t~~ \max f(x) = f(c)\) by Maximum principle I proof \(f'(c)=0\) f is differentiable on \(x = c\) and \(f(c) >= f(c+h)\). Thus \[f'(c) = \lim_{h \rightarrow +0} \frac{f(c+h) - f(c)}{h} \leq 0\] \[f'(c) = \lim...

MAP推定

Introduction English ver 今日はMAP推定(事後確率最大化法)について書きました。MAP推定ではベイズの定理を使います。データが少ないとき、最尤推定の結果をあまり信用できない話は、最尤推定の時に書きました。この時、MAP推定では自分の事前に持っている情報を取り入れることができます。 概要 ベイズの定理 MAP推定 共役分布 MAP推定の例 ベイズの定理 ベイズの定理は $$P(A|B) = \frac{P(B|A)P(A)}{P(B)}$$ です。 ただし、 $P(A|B)$ はBが起こった時のAの起こる確率です。 詳しくは  http://takutori.blogspot.com/2018/04/bayes-theorem.html  を見てください。 Map推定 MAP推定ではベイズの定理を使います。MAP推定は事後確率が最大になるようなパラメータを選びます。 いま、$x_1,x_2,...,x_n$というデータを$\theta$というパラメータを持つ分布から得られたとする。この時$P(\theta|x_1,x_2,...,x_n)$を求めたい。 ここで、ベイズの定理を使う。 $$P(\theta|x_1,x_2,...,x_n) = \frac{P(x_1,x_2,...,x_n | \theta ) P(\theta)}{P(x_1,x_2,...,x_n)}$$ ここで、$P(\theta)$は$\theta$の事前分布である。 $x_1,x_2,...,x_n$はそれぞれ独立であるので、 $$P(x_1,x_2,...,x_n | \theta ) = \Pi_{i=1}^n P(x_i|\theta)$$. よって、マップ推定は $$\theta^{\star} = \arg \max_{\theta} \frac{\Pi_{i=1}^n P(x_i|\theta) P(\theta)}{P(x_1,x_2,...,x_n)}$$ となる。 $P(x_1,x_2,...,x_n)$という値は$\theta$には依存しない。よって、定数であり、最適化に定数は関係ないので、排除すると、MAP推定は次のようになる。 $$\th...