Certainly! Here’s a formal mathematical description of the loss function you're describing — suitable for inclusion in a paper, presentation, or scientific documentation.
📘 Loss Function Definition for View Direction and Field-of-View Estimation
We aim to predict both a viewing direction and a half field-of-view (FoV) for a sensor or agent. The model outputs two unit vectors:
-
Direction:
[
\hat{\mathbf{d}} = (\sin{\hat{\theta}}, \cos{\hat{\theta}}) \in \mathbb{R}^2
]
-
Half-FoV:
[
\hat{\mathbf{f}} = (\sin{\hat{\alpha}}, \cos{\hat{\alpha}}) \in \mathbb{R}^2
]
where (\hat{\alpha} \in \left(0, \frac{\pi}{2}\right]) represents the angle between the center direction and the edge of the view cone.
The corresponding ground truth target values are:
- Direction:
[
\mathbf{d} = (\sin{\theta}, \cos{\theta})
]
- Half-FoV:
[
\mathbf{f} = (\sin{\alpha}, \cos{\alpha})
]
🔺 Total Loss
We define the total loss as a weighted sum of four sub-losses:
[
\mathcal{L}{\text{total}} =
\lambda_1 , \mathcal{L}{\text{dir}} +
\lambda_2 , \mathcal{L}{\text{fov}} +
\lambda_3 , \mathcal{L}{\text{range}} +
\lambda_4 , \mathcal{L}_{\text{contain}}
]
Where:
🔹 Direction Loss:
Angle between predicted and target direction vectors.
[
\mathcal{L}_{\text{dir}} = 1 - \cos(\hat{\theta} - \theta) = 1 - \frac{\hat{\mathbf{d}} \cdot \mathbf{d}}{|\hat{\mathbf{d}}| \cdot |\mathbf{d}|}
]
(This encourages alignment between predicted and target viewing directions.)
🔹 FoV Vector Loss:
Difference between predicted and target half-FoV vectors.
[
\mathcal{L}_{\text{fov}} = \left| \hat{\mathbf{f}} - \mathbf{f} \right|_2^2
]
(This ensures the shape of the viewing cone is correctly estimated.)
🔹 FoV Range Penalty:
Penalizes predicted FoV angles that are too narrow or too wide:
Let:
- (\hat{\alpha} = \mathrm{atan2}(\hat{f}_x, \hat{f}_y)),
- (\alpha = \mathrm{atan2}(f_x, f_y))
Then:
[
\mathcal{L}_{\text{range}} =
\begin{cases}
(\hat{\alpha} - \alpha)^2, & \text{if } |\hat{\alpha} - \alpha| > \delta \
0, & \text{otherwise}
\end{cases}
]
((\delta) allows small deviations without penalty; a Huber-like margin.)
🔹 Containment Loss:
Ensures the predicted field-of-view cone contains the ground truth direction.