src.tests.torf_losses_test
Classes
- class src.tests.torf_losses_test.TorfLossesTest
- Author:
Alberto M. Esmoris Pena
Test that TORF masked losses produce the same results as their non-TORF counterparts on fully valid data, and correctly exclude masked positions.
- __init__()
Basic configuration for any VL3D test.
- Parameters:
name (str) – Test name
- run()
Run all TORF loss tests.
- Returns:
True if all tests pass, False otherwise.
- Return type:
bool
- static test_torf_cce(eps)
Plain categorical: TORF vs Keras on valid data.
- static test_torf_cwcce(eps)
CW categorical: TORF vs non-TORF on valid data.
- static test_torf_fcce(eps)
Focal categorical: TORF vs numpy on valid data.
- static test_torf_cwfcce(eps)
CW+focal categorical: TORF vs non-TORF.
- static test_torf_bce(eps)
Plain binary: TORF vs Keras on valid data.
- static test_torf_cwbce(eps)
CW binary: TORF vs non-TORF on valid data.
- static test_torf_fbce(eps)
Focal binary: TORF vs numpy on valid data.
- static test_torf_cwfbce(eps)
CW+focal binary: TORF vs non-TORF.
- static test_masking_categorical(eps)
Verify masked positions are excluded.
- static test_masking_binary(eps)
Verify masked positions are excluded.
- static test_masking_all_categorical(eps)
Masking for all 4 categorical variants.
- static test_masking_all_binary(eps)
Masking for all 4 binary variants.
- static test_scattered_mask(eps)
Non-contiguous (scattered) mask pattern.
- static test_single_valid_position(eps)
Single valid position per batch element.
- static test_rank3_binary(eps)
Binary with rank-3 input (B, K, 1).
- static test_rank3_binary_masked(eps)
Rank-3 binary (B,K,1) with masking.
- static test_different_gamma(eps)
Focal with gamma != 2.0 (test 1.5 and 3.0).
- static test_two_class_categorical(eps)
Categorical with nc=2 (boundary case).
- static test_all_invalid()
All-invalid batch returns 0.0, not NaN.