Git Product home page Git Product logo

Comments (3)

yyzzyy78 avatar yyzzyy78 commented on May 24, 2024 2

Great! Thanks for your detailed reply. I think I understand your formula derivation.
Thanks again! @PanagiotisP

from gaussian-splatting.

PanagiotisP avatar PanagiotisP commented on May 24, 2024 1

You are right that dSigma_dM isn't the matrix shown, as it is a matrix w.r.t. matrix derivative that cannot be written in matrix form (it is a tensor, as mentioned also at Wikipedia). I would say that this is a small abuse of terminology, but it makes sense. I'll try to explain below.

The derivatives in the backward pass are always thought of in a chain rule way. You start with a scalar $L$, which is the loss and you build the chain rule with that as a nominator.
To write chain rules that include scalar-to-matrix and even matrix-to-matrix derivatives, the Frobenius inner product is used. That's basically an element-wise multiplication of the two matrices and then summation over the resulting products.

So, using that, the derivative above would be computed as follows. $x$ he is a scalar which $M$ is dependent on.

$$\dfrac{\partial L}{\partial x} = \langle \dfrac{\partial L}{\partial \Sigma_{3D}}, \dfrac{\partial \Sigma_{3D}}{\partial x} \rangle = \langle \dfrac{\partial L}{\partial \Sigma_{3D}}, \dfrac{\partial (M M^T)}{\partial x} \rangle = \langle \dfrac{\partial L}{\partial \Sigma_{3D}}, \dfrac{\partial M}{\partial x}M^T \rangle + \langle \dfrac{\partial L}{\partial \Sigma_{3D}}, M\dfrac{\partial M^T}{\partial x} \rangle =$$ $$\langle \dfrac{\partial L}{\partial \Sigma_{3D}}M, \dfrac{\partial M}{\partial x}\rangle + \langle M^T\dfrac{\partial L}{\partial \Sigma_{3D}}, (\dfrac{\partial M}{\partial x})^T \rangle = \langle \dfrac{\partial L}{\partial \Sigma_{3D}}M, \dfrac{\partial M}{\partial x}\rangle + \langle \dfrac{\partial L}{\partial \Sigma_{3D}}M, \dfrac{\partial M}{\partial x} \rangle = 2\langle \dfrac{\partial L}{\partial \Sigma_{3D}}M, \dfrac{\partial M}{\partial x}\rangle$$

(I used some properties of the Frobenius inner product and the fact that $\dfrac{\partial L}{\partial \Sigma_{3D}}$ is symmetric)
For $x = M_{ij}$ the right matrix has $1$ in position $i j$ and 0 elsewhere, so you basically take the $i j$ entry of the left-hand matrix. So, the whole scalar-to-matrix derivative can be written as:

$$\dfrac{\partial L}{\partial M} = 2\dfrac{\partial L}{\partial \Sigma_{3D}}M$$

which is what the code has (in row-major form, so everything is transposed, hence the different order of multiplications).

In general, if you get the hang of the Frobenius inner product, you can derive the full backward pass yourself, as it basically requires you to apply it over and over, as you progress along the chain.

from gaussian-splatting.

yyzzyy78 avatar yyzzyy78 commented on May 24, 2024

@kwea123

from gaussian-splatting.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.