# Losses#

Collection of Losses.

nerfstudio.model_components.losses.distortion_loss(weights_list, ray_samples_list)#

From mipnerf360

nerfstudio.model_components.losses.interlevel_loss(weights_list, ray_samples_list)#

Calculates the proposal loss in the MipNeRF-360 paper.

nerfstudio.model_components.losses.lossfun_distortion(t, w)#
nerfstudio.model_components.losses.lossfun_outer(t: Tensor, w: Tensor, t_env: Tensor, w_env: Tensor)#
Parameters:
• t – interval edges

• w – weights

• t_env – interval edges of the upper bound enveloping historgram

• w_env – weights that should upper bound the inner (t,w) histogram

nerfstudio.model_components.losses.nerfstudio_distortion_loss(ray_samples: RaySamples, densities: Optional[Tensor] = None, weights: Optional[Tensor] = None) Tensor#

Ray based distortion loss proposed in MipNeRF-360. Returns distortion Loss.

$\mathcal{L}(\mathbf{s}, \mathbf{w}) =\iint\limits_{-\infty}^{\,\,\,\infty} \mathbf{w}_\mathbf{s}(u)\mathbf{w}_\mathbf{s}(v)|u - v|\,d_{u}\,d_{v}$

where $$\mathbf{w}_\mathbf{s}(u)=\sum_i w_i \mathbb{1}_{[\mathbf{s}_i, \mathbf{s}_{i+1})}(u)$$ is the weight at location $$u$$ between bin locations $$s_i$$ and $$s_{i+1}$$.

Parameters:
• ray_samples – Ray samples to compute loss over

• densities – Predicted sample densities

• weights – Predicted weights from densities and sample locations

nerfstudio.model_components.losses.orientation_loss(weights: Tensor, normals: Tensor, viewdirs: Tensor)#

Orientation loss proposed in Ref-NeRF. Loss that encourages that all visible normals are facing towards the camera.

nerfstudio.model_components.losses.outer(t0_starts: Tensor, t0_ends: Tensor, t1_starts: Tensor, t1_ends: Tensor, y1: Tensor) Tensor#

Faster version of

Parameters:
• t0_starts – start of the interval edges

• t0_ends – end of the interval edges

• t1_starts – start of the interval edges

• t1_ends – end of the interval edges

• y1 – weights

nerfstudio.model_components.losses.pred_normal_loss(weights: Tensor, normals: Tensor, pred_normals: Tensor)#

Loss between normals calculated from density and normals from prediction network.

nerfstudio.model_components.losses.ray_samples_to_sdist(ray_samples)#

Convert ray samples to s space