判断:标量对于列向量的导数是行向量。
正确。
标量对于列向量的导数是一个行向量,也称为梯度。假设标量函数 f f f 依赖于一个 n n n 维列向量 x \mathbf{x} x,则 f f f 对于 x \mathbf{x} x 的导数为:
∂ f ∂ x = [ ∂ f ∂ x 1 ∂ f ∂ x 2 ⋯ ∂ f ∂ x n ] \frac{\partial f}{\partial \mathbf{x}} = \begin{bmatrix} \frac{\partial f}{\partial x_1} & \frac{\partial f}{\partial x_2} & \cdots & \frac{\partial f}{\partial x_n} \end{bmatrix} ∂x∂f=[∂x1∂f∂x2∂f⋯∂xn∂f]
其中每个偏导数 ∂ f ∂ x i \frac{\partial f}{\partial x_i} ∂xi∂f 表示 f f f 对于 x \mathbf{x} x 的第 i i i 个分量的导数。因此,导数是一个行向量,其中每个元素是一个偏导数。
对于标量函数 f ( x ) f(\mathbf{x}) f(x),其中 x \mathbf{x} x是列向量,它的导数是一个行向量,记作 ∂ f ( x ) ∂ x ⊤ \frac{\partial f(\mathbf{x})}{\partial \mathbf{x}^\top} ∂x⊤∂f(x)。
可以使用链式法则来计算这个导数。假设 x \mathbf{x} x是一个 n n n维列向量,即 x = [ x 1 x 2 ⋯ x n ] ⊤ \mathbf{x}=\begin{bmatrix}x_1 & x_2 & \cdots & x_n\end{bmatrix}^\top x=[x1x2⋯xn]⊤,其中 ⊤ ^\top ⊤表示向量的转置。则 f ( x ) f(\mathbf{x}) f(x)的导数可以写成一个行向量的形式:
∂ f ( x ) ∂ x ⊤ = [ ∂ f ( x ) ∂ x 1 ∂ f ( x ) ∂ x 2 ⋯ ∂ f ( x ) ∂ x n ] \frac{\partial f(\mathbf{x})}{\partial \mathbf{x}^\top}=\begin{bmatrix}\frac{\partial f(\mathbf{x})}{\partial x_1} & \frac{\partial f(\mathbf{x})}{\partial x_2} & \cdots & \frac{\partial f(\mathbf{x})}{\partial x_n}\end{bmatrix} ∂x⊤∂f(x)=[∂x1∂f(x)∂x2∂f(x)⋯∂xn∂f(x)]
其中每个偏导数都是一个标量,因此 ∂ f ( x ) ∂ x ⊤ \frac{\partial f(\mathbf{x})}{\partial \mathbf{x}^\top} ∂x⊤∂f(x)是一个行向量。
∣ ∣ x ∣ ∣ 2 ||\mathbf{x}||_2 ∣∣x∣∣2对 x \mathbf{x} x 的导数为 2 x ⊤ 2\mathbf{x}^\top 2x⊤
假设 x \mathbf{x} x是一个 n n n维列向量,则 ∣ ∣ x ∣ ∣ 2 ||\mathbf{x}||_2 ∣∣x∣∣2(L2范数)定义为:
∣ ∣ x ∣ ∣ 2 = ∑ i = 1 n x i 2 ||\mathbf{x}||_2 = \sqrt{\sum_{i=1}^{n}x_i^2} ∣∣x∣∣2=i=1∑nxi2
我们可以使用链式法则来计算 ∣ ∣ x ∣ ∣ 2 ||\mathbf{x}||_2 ∣∣x∣∣2对 x \mathbf{x} x 的导数。
首先,令 f ( t ) = t f(t) = \sqrt{t} f(t)=t,则:
∂ f ( t ) ∂ t = 1 2 t \frac{\partial f(t)}{\partial t} = \frac{1}{2\sqrt{t}} ∂t∂f(t)=2t1
然后,令 t = g ( x ) = ∑ i = 1 n x i 2 t=g(\mathbf{x})=\sum_{i=1}^{n}x_i^2 t=g(x)=∑i=1nxi2,则:
∂ g ( x ) ∂ x i = 2 x i \frac{\partial g(\mathbf{x})}{\partial x_i} = 2x_i ∂xi∂g(x)=2xi
因此,根据链式法则,有:
∂ ∣ ∣ x ∣ ∣ 2 ∂ x = ∂ f ( g ( x ) ) ∂ x = ∂ f ( g ( x ) ) ∂ g ( x ) ⋅ ∂ g ( x ) ∂ x = 1 2 g ( x ) ⋅ 2 x = x ∣ ∣ x ∣ ∣ 2 \frac{\partial ||\mathbf{x}||_2}{\partial \mathbf{x}}=\frac{\partial f(g(\mathbf{x}))}{\partial \mathbf{x}}=\frac{\partial f(g(\mathbf{x}))}{\partial g(\mathbf{x})} \cdot \frac{\partial g(\mathbf{x})}{\partial \mathbf{x}}=\frac{1}{2\sqrt{g(\mathbf{x})}} \cdot 2\mathbf{x}=\frac{\mathbf{x}}{||\mathbf{x}||_2} ∂x∂∣∣x∣∣2=∂x∂f(g(x))=∂g(x)∂f(g(x))⋅∂x∂g(x)=2g(x)1⋅2x=∣∣x∣∣2x
其中, ∂ g ( x ) ∂ x = [ ∂ g ( x ) ∂ x 1 ∂ g ( x ) ∂ x 2 ⋯ ∂ g ( x ) ∂ x n ] = [ 2 x 1 2 x 2 ⋯ 2 x n ] \frac{\partial g(\mathbf{x})}{\partial \mathbf{x}}=\begin{bmatrix}\frac{\partial g(\mathbf{x})}{\partial x_1} & \frac{\partial g(\mathbf{x})}{\partial x_2} & \cdots & \frac{\partial g(\mathbf{x})}{\partial x_n}\end{bmatrix}=\begin{bmatrix}2x_1 & 2x_2 & \cdots & 2x_n\end{bmatrix} ∂x∂g(x)=[∂x1∂g(x)∂x2∂g(x)⋯∂xn∂g(x)]=[2x12x2⋯2xn]
因此, ∂ ∣ ∣ x ∣ ∣ 2 ∂ x = x ∣ ∣ x ∣ ∣ 2 \frac{\partial ||\mathbf{x}||_2}{\partial \mathbf{x}} = \frac{\mathbf{x}}{||\mathbf{x}||_2} ∂x∂∣∣x∣∣2=∣∣x∣∣2x可以写成:
∂ ∣ ∣ x ∣ ∣ 2 ∂ x = [ ∂ ∣ ∣ x ∣ ∣ 2 ∂ x 1 ∂ ∣ ∣ x ∣ ∣ 2 ∂ x 2 ⋮ ∂ ∣ ∣ x ∣ ∣ 2 ∂ x n ] = [ x 1 ∣ ∣ x ∣ ∣ 2 x 2 ∣ ∣ x ∣ ∣ 2 ⋮ x n ∣ ∣ x ∣ ∣ 2 ] \frac{\partial ||\mathbf{x}||_2}{\partial \mathbf{x}} = \begin{bmatrix}\frac{\partial ||\mathbf{x}||_2}{\partial x_1} \ \frac{\partial ||\mathbf{x}||_2}{\partial x_2} \ \vdots \ \frac{\partial ||\mathbf{x}||_2}{\partial x_n}\end{bmatrix} = \begin{bmatrix}\frac{x_1}{||\mathbf{x}||_2} \ \frac{x_2}{||\mathbf{x}||_2} \ \vdots \ \frac{x_n}{||\mathbf{x}||_2}\end{bmatrix} ∂x∂∣∣x∣∣2=[∂x1∂∣∣x∣∣2 ∂x2∂∣∣x∣∣2 ⋮ ∂xn∂∣∣x∣∣2]=[∣∣x∣∣2x1 ∣∣x∣∣2x2 ⋮ ∣∣x∣∣2xn]
这个结果可以进一步简化为 ∂ ∣ ∣ x ∣ ∣ 2 ∂ x = x ⊤ ∣ ∣ x ∣ ∣ 2 \frac{\partial ||\mathbf{x}||_2}{\partial \mathbf{x}} = \frac{\mathbf{x}^\top}{||\mathbf{x}||_2} ∂x∂∣∣x∣∣2=∣∣x∣∣2x⊤,因为 x ∣ ∣ x ∣ ∣ 2 \frac{\mathbf{x}}{||\mathbf{x}||_2} ∣∣x∣∣2x是一个列向量,其转置即为一个行向量。所以:
∂ x ⊤ = x ⊤ ∣ ∣ x ∣ ∣ 2 {\partial \mathbf{x}^\top} = \frac{\mathbf{x}^\top}{||\mathbf{x}||_2} ∂x⊤=∣∣x∣∣2x⊤
因此,当对 ∣ ∣ x ∣ ∣ 2 ||\mathbf{x}||_2 ∣∣x∣∣2求导时,得到的结果是 ∂ ∣ ∣ x ∣ ∣ 2 ∂ x ⊤ = x ⊤ ∣ ∣ x ∣ ∣ 2 \frac{\partial ||\mathbf{x}||_2}{\partial \mathbf{x}^\top} = \frac{\mathbf{x}^\top}{||\mathbf{x}||_2} ∂x⊤∂∣∣x∣∣2=∣∣x∣∣2x⊤。又因为 ∣ x ∣ 2 2 = ∑ i = 1 n x i 2 |\mathbf{x}|2^2 = \sum{i=1}^{n} x_i^2 ∣x∣22=∑i=1nxi2,所以我们可以将 x ⊤ ∣ ∣ x ∣ ∣ 2 \frac{\mathbf{x}^\top}{||\mathbf{x}||_2} ∣∣x∣∣2x⊤进一步简化为:
∂ ∣ ∣ x ∣ ∣ 2 ∂ x ⊤ = 1 ∣ ∣ x ∣ ∣ 2 [ x 1 x 2 ⋮ x n ] ⊤ = 2 x ⊤ 2 ∣ ∣ x ∣ ∣ 2 = 2 x ⊤ ∑ i = 1 n x i 2 \frac{\partial ||\mathbf{x}||_2}{\partial \mathbf{x}^\top} = \frac{1}{||\mathbf{x}||_2} \begin{bmatrix} x_1 \ x_2 \ \vdots \ x_n \end{bmatrix}^\top = \frac{2\mathbf{x}^\top}{2||\mathbf{x}||2} = \frac{2\mathbf{x}^\top}{\sqrt{\sum_{i=1}^{n} x_i^2}} ∂x⊤∂∣∣x∣∣2=∣∣x∣∣21[x1 x2 ⋮ xn]⊤=2∣∣x∣∣22x⊤=∑i=1nxi22x⊤
因此, ∣ ∣ x ∣ ∣ 2 ||\mathbf{x}||_2 ∣∣x∣∣2对 x \mathbf{x} x的导数为 2 x ⊤ 2\mathbf{x}^\top 2x⊤。