ShijieZhou-UCLA / feature-3dgs

[CVPR 2024 Highlight] Feature 3DGS: Supercharging 3D Gaussian Splatting to Enable Distilled Feature Fields
Other
314 stars 21 forks source link

Gradient Shape Mismatch in _RasterizeGaussiansBackward Function #41

Open SHIBOYA opened 2 weeks ago

SHIBOYA commented 2 weeks ago

Hi, I encounter an issue with using feature-3dgs on my datasets.

While running the train.py script, I encounter the following error during the backward pass:

RuntimeError: Function _RasterizeGaussiansBackward returned an invalid gradient at index 4 - got [2000, 1, 8] but expected shape compatible with [2000, 1, 256]

It seems that the problem arises from a shape mismatch in the gradients returned by the _RasterizeGaussiansBackward function. I've been inspecting the tensor shape transformations during the forward pass, but I'm unsure how to correct this gradient shape mismatch.

  1. Are there specific considerations or transformations in the _RasterizeGaussiansBackward function that I should be aware of when calculating gradients?
  2. How should I adjust the operations in the forward pass, or what modifications should be made during the backward pass, to ensure the gradient shapes are consistent with the expected output?
  3. Do you have any debugging tips or example code that could help me better understand and resolve this issue?

I look forward to any advice or suggestions.

SHIBOYA commented 2 weeks ago

Following up on my previous issue regarding the gradient shape mismatch error, I want to bring up another issue I've encountered during backpropagation related to the _RasterizeGaussiansBackward function.

Occasionally, I receive a different runtime error during the backward pass:

RuntimeError: Function _RasterizeGaussiansBackward returned an invalid gradient at index 4 - got [2025, 26, 8] but expected shape compatible with [1975, 26, 8]

This suggests that the problem might not be limited to a single shape mismatch but could vary depending on the input or some other factors during training. I’m curious to understand more about how the _RasterizeGaussiansBackward function operates.

Specifically, I have the following questions:

  1. Where is _RasterizeGaussiansBackward implemented in the code? I would like to inspect the function to better understand how it handles different dimensional changes during backpropagation.
  2. How should I approach modifying the function to handle varying dimensions properly? Any guidance on ensuring that the shapes of the gradients match as expected across different scenarios would be highly appreciated.

I’m eager to resolve these issues and would greatly appreciate any insights or suggestions you might have on addressing these dimension-related errors.