-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
loss render is NaN,The following problems occurred. I did not modify the training parameters. Is the training parameters wrong? #5
Comments
python train.py --model=l2g_nerf --yaml=l2g_nerf_blender --group=exp_synthetic --name=l2g_lego --data.scene=lego --data.root=./data/blender/nerf_synthetic --camera.noise_r=0.07 --camera.n
|
Sorry, we can not reproduce the issue. You could change the random seed to see if it happens again. |
@manjidada I got the same issue on blender dataset. It seems depth range will become 0 when entering the iteration loop like above, which is weird. Therefore, I force the depth range to be scalar instead of torch tensor during validation and it work for me. Like: class Graph(nerf.Graph):
...
def forward(self, opt, var, mode=None):
# rescale the size of the scene condition on the pose
if opt.data.dataset == "blender":
depth_min, depth_max = opt.nerf.depth.range
position = camera.Pose().invert(
self.optimised_training_poses.weight.data.detach().clone().view(-1, 3, 4))[..., -1]
diameter = ((position[self.idx_grid[..., 0]] -
position[self.idx_grid[..., 1]]).norm(dim=-1)).max()
depth_min_new = (depth_min/(depth_max+depth_min))*diameter
depth_max_new = (depth_max/(depth_max+depth_min))*diameter
if mode in ["train"]:
opt.nerf.depth.range = [
depth_min_new, depth_max_new]
else:
# force scalar
opt.nerf.depth.range = [
depth_min_new.item(), depth_max_new.item()]
...
....
@torch.no_grad()
def validate(self, opt, ep=None):
pose, pose_GT = self.get_all_training_poses(opt)
_, self.graph.sim3 = self.prealign_cameras(opt, pose, pose_GT)
# force scalar
if torch.is_tensor(opt.nerf.depth.range[0]):
opt.nerf.depth.range[0] = opt.nerf.depth.range[0].item()
if torch.is_tensor(opt.nerf.depth.range[1]):
opt.nerf.depth.range[1] = opt.nerf.depth.range[1].item()
super().validate(opt, ep=ep) Hope for the official solution. |
Thanks for pointing this out. I rescale the size of the blender objects(near/far) condition on the optimized poses as shown here. I guess the depth range becoming 0 is caused by the diameter becoming 0, but it is weird as the diameter is determined by the maximum distance between the two cameras. Does anyone have any idea? |
Traceback (most recent call last):
File "train.py", line 35, in
main()
File "train.py", line 32, in main
m.train(opt)
File "G:\work_document\python_work\L2G-NeRF-main\model\nerf.py", line 61, in train
if self.it%opt.freq.val==0: self.validate(opt,self.it)
File "G:\work_document\Tensorflow\Miniconda3\envs\L2G-NeRF\lib\site-
packages\torch\autograd\grad_mode.py", line 27, in decorate_context
return func(*args, **kwargs)
File "G:\work_document\python_work\L2G-NeRF-main\model\l2g_nerf.py", line 89, in validate
super().validate(opt,ep=ep)
File "G:\work_document\Tensorflow\Miniconda3\envs\L2G-NeRF\lib\site-packages\torch\autograd\grad_mode.py", line 27, in decorate_context
return func(*args, **kwargs)
File "G:\work_document\python_work\L2G-NeRF-main\model\base.py", line 154, in validate
loss = self.summarize_loss(opt,var,loss)
File "G:\work_document\python_work\L2G-NeRF-main\model\base.py", line 139, in summarize_loss
assert not torch.isnan(loss[key]),"loss {} is NaN".format(key)
AssertionError: loss render is NaN
The text was updated successfully, but these errors were encountered: