Question about the Equation(1) implementation
onevfall opened this issue · comments
Hi, Thanks for your awesome work, the result is very cool!
But I am not fully understanding the density implementation of Equation(1) in the sugar_model.py.
The code is here:
shift = (x[:, None] - closest_gaussian_centers)
warped_shift = closest_gaussian_inv_scaled_rotation.transpose(-1, -2) @ shift[..., None]
neighbor_opacities = (warped_shift[..., 0] * warped_shift[..., 0]).sum(dim=-1).clamp(min=0., max=1e8)
neighbor_opacities = density_factor * closest_gaussian_strengths[..., 0] * torch.exp(-1. / 2 * neighbor_opacities)
densities = neighbor_opacities.sum(dim=-1)
I think closest_gaussian_inv_scaled_rotation.transpose(-1, -2) is corresponding to the inverse of the covariance matrix.
There are two points that make me confused.
- warped_shift[..., 0] * warped_shift[..., 0] seems like the element of closest_gaussian_inv_scaled_rotation is calculated twice, not fully corresponding to the equation?
- why the closest_gaussian_strengths[..., 0] exists? I do not fully understand the role of it.
Could you provide any help? Thank you very much.
Hello @onevfall,
Thank you for your nice words!
Here are some answers for you:
Question 1. The covariance matrix can be computed as
To compute the density of the point, you first need to compute
So you can compute this quantity as the squared norm of the shift closest_gaussian_inv_scaled_rotation
in the code.
After multiplying the shift (warped_shift[..., 0] * warped_shift[..., 0]).sum(dim=-1)
.
Question 2. The tensor closest_gaussian_strengths[..., 0]
just contains the opacities density_factor
is just a constant factor that can be used to adjust or play with the densities to avoid numerical instability in the computation.
I hope this answer will be helpful to you!
Wow, I understand it fully. Thanks very much for your kind help! @Anttwo