Here is a detailed description of the loss function:
Loss Function Description
The loss function is designed to evaluate the accuracy of predicted directions and half-fov values, while also ensuring that the predicted field of view (FoV) contains the target direction. The input to the loss function consists of two parts:
- Target values: The target direction and half-fov values, represented as pairs of sine and cosine values, i.e.,
(sin_dir, cos_dir) and (sin_fov, cos_fov).
- Predicted values: The predicted direction and half-fov values, also represented as pairs of sine and cosine values, i.e.,
(sin_dir_pred, cos_dir_pred) and (sin_fov_pred, cos_fov_pred).
Loss Function Rules
The loss function applies the following rules to compute the loss:
- Half-fov penalty: If the predicted half-fov value is significantly higher or lower than the target half-fov value, a penalty is applied. This penalty is designed to discourage the model from predicting half-fov values that are far from the target values.
- FoV containment penalty: If the predicted FoV does not contain the target direction, a penalty is applied. This penalty is designed to ensure that the predicted FoV is large enough to include the target direction.
- Direction penalty: If the predicted direction is not the same as the target direction, a penalty is applied. However, this penalty is smaller than the half-fov penalty and FoV containment penalty, as the model is allowed some flexibility in predicting the direction.
Loss Function Formula
The loss function can be represented mathematically as:
L = w1 * L_half_fov + w2 * L_fov_containment + w3 * L_direction
where:
L_half_fov is the half-fov penalty term
L_fov_containment is the FoV containment penalty term
L_direction is the direction penalty term
w1, w2, and w3 are weights that control the relative importance of each term
The half-fov penalty term L_half_fov can be computed as:
L_half_fov = (sin_fov_pred - sin_fov_target)^2 + (cos_fov_pred - cos_fov_target)^2
The FoV containment penalty term L_fov_containment can be computed as:
L_fov_containment = max(0, sin_fov_pred - sin_dir_target)^2 + (cos_fov_pred - cos_dir_target)^2
The direction penalty term L_direction can be computed as:
L_direction = (sin_dir_pred - sin_dir_target)^2 + (cos_dir_pred - cos_dir_target)^2
Hyperparameters
The loss function has several hyperparameters that need to be tuned:
w1, w2, and w3: weights that control the relative importance of each term
threshold: a threshold value that determines when the half-fov penalty is applied
These hyperparameters can be tuned using a validation set to optimize the performance of the model.