2DGS梯度推导

1 minute read

Published:

https://en.wikipedia.org/wiki/Matrix_calculus#Scalar-by-vector_identities

Ray-splat points

\[\mathbf{x}=(x z, y z, z, 1)^{\mathrm{T}}=\mathbf{W} P(u, v)=\mathbf{W H}(u, v, 1,1)^{\mathrm{T}}\] \[\hat{\mathbf{x}}=(x, y, z)^{\mathrm{T}}=(\frac{1}{z}, \frac{1}{z}, 1)\mathbf{W} P(u, v)\]

Depth

Mean depth

\[D=\sum_i \omega_i z_i\]

where

\[\omega_i=T_i \alpha_i \hat{\mathcal{G}}_i(\mathbf{u}(\mathbf{x}))\]

is the weight contribution of the

$i$

-th Gaussian and

\[T_i=\prod_{j=1}^{i-1}\left(1-\alpha_j \hat{\mathcal{G}}_j(\mathbf{u}(\mathbf{x}))\right)\]

measures its visibility.

  • Relative variables
    • \[z_i\]
    • \[\omega_i\]

Calculate

\(z_i\)

\[\frac{\partial z_{\text {mean }}}{\partial z_i}=\omega_i\] \[\frac{\partial L}{\partial z_i}=\frac{\partial L}{D}\frac{D}{\partial z_i}=\frac{\partial L}{D}\omega_i\]

Calculate

\(\omega_i\)

\[\frac{\partial z_{\text {mean }}}{\partial \omega_i}= z_i\] \[\frac{\partial L}{\partial \omega_i}=\frac{\partial L}{D}\frac{D}{\partial \omega_i}=\frac{\partial L}{D}z_i\]

Calculate

\(\alpha_i\)

\[\frac{\partial T_i}{\partial \alpha_i} = T_{i-1} \left(-\hat{\mathcal{G}}_{i-1}(\mathbf{u}(\mathbf{x}))\right)\] \[\frac{\partial \omega_i}{\partial \alpha_i}= T_i \hat{\mathcal{G}}_i(\mathbf{u}(\mathbf{x})) + \alpha_i \hat{\mathcal{G}}_i(\mathbf{u}(\mathbf{x})) \frac{\partial T_i}{\partial \alpha_i}\\ = T_i \hat{\mathcal{G}}_i(\mathbf{u}(\mathbf{x})) - \alpha_i T_{i-1} \hat{\mathcal{G}}_{i-1}(\mathbf{u}(\mathbf{x})) \hat{\mathcal{G}}_i(\mathbf{u}(\mathbf{x}))\]

Distortion loss

\[\begin{aligned} &\begin{aligned} \mathcal{Dist} & =\sum_{i=0}^{N-1} \sum_{j=0}^{i-1} \omega_i \omega_j\left(m_i-m_j\right)^2 \\ & =\sum_{i=0}^{N-1} \omega_i\left(m_i^2 \sum_{j=0}^{i-1} \omega_j+\sum_{j=0}^{i-1} \omega_j m_j^2-2 m_i \sum_{j=0}^{i-1} \omega_j m_j\right) \\ & =\sum_{i=0}^{N-1} \omega_i\left(m_i^2 A_{i-1}+D_{i-1}^2-2 m_i D_{i-1}\right) \end{aligned}\\ &\text { where } A_i=\sum_{j=0}^{i} \omega_j, D_i=\sum_{j=0}^{i} \omega_j m_j \text { and } D_i^2=\sum_{j=0}^{i} \omega_j m_j^2 \text {. } \end{aligned}\] \[A_i=\sum_{j=0}^{i} \omega_j =\sum_{j=0}^{i} \alpha_j \hat{\mathcal{G}}_j(\mathbf{u}(\mathbf{x})) T_j = 1.0 - T_i = 1.0 - \prod_{j=1}^{i}\left(1-\alpha_j \hat{\mathcal{G}}_j(\mathbf{u}(\mathbf{x}))\right)\] \[\frac{\partial \mathcal{Dist}}{\partial m_i}=\omega_i * 2 * m_i * A_{i-1} - 2 D_{i-1} = 2 (\omega_i * m_i * A_{i-1} - D_{i-1})\] \[\frac{\partial \mathcal{Dist}}{\partial \omega_i}=m_i^2 A_{i-1}+D_{i-1}^2-2 m_i D_{i-1}\] \[\frac{\partial \mathcal{Dist}}{\partial \alpha_i}=\frac{\partial L}{\partial \omega_i} \frac{\partial \omega_i}{\partial \alpha_i}\]