yenchenlin / nerf-pytorch

A PyTorch implementation of NeRF (Neural Radiance Fields) that reproduces the results.
MIT License
5.37k stars 1.04k forks source link

Unstable training result on Lego scene #52

Closed wtyuan96 closed 2 years ago

wtyuan96 commented 2 years ago

Thanks for your work!

When I use your original code to train on Lego scene with same setting repeatedly, I get two different rendering results showing below: PSNR30_000 PSNR32_000 Obviously, the result above is vaguer than the one below, then I check out the training log, I find the train PSNR above(mostly less than 30) is lower than the one below(mostly more than 30).

Then, I repeatedly run several experiments on the Lego scene, I find the initial Loss if Ier: 100 is unstable, leading to an unstable rendering result.

Do you have any idea about that?

P.S.: This problem is not presented on fern scene.

yenchenlin commented 2 years ago

May I know which git commit you are using?

wtyuan96 commented 2 years ago

Thanks for your reply.

May I know which git commit you are using?

commit id is a15fd7cb363e93f933012fd1f1ad5395302f63a4. Maybe you can reproduce the problem above by repeating the experiment 5 times(check the initial loss of Iter: 100 to see the instability)

I set all random seeds fixed by code below, then I can get exactly the same result in multiple experiments.

def set_random_seed(seed):
    random.seed(seed)
    np.random.seed(seed)
    torch.manual_seed(seed)
    torch.cuda.manual_seed_all(seed)
set_random_seed(seed=0)

Then the question is: is NeRF sensitive to the first few optimization steps?

yenchenlin commented 2 years ago

Yes, NeRF is sensitive to the first few optimization steps! I will investigate the instability issue further.

wtyuan96 commented 2 years ago

Ok, Thanks.