Comprehensive utilities library for JAX testing, debugging, and instrumentation
73
A utility for validating machine learning model outputs by comparing nested data structures with precise floating-point tolerance handling.
{"loss": 1.0, "accuracy": 0.95} and {"loss": 1.0, "accuracy": 0.95}, validation passes @test[1.0, 2.0, 3.0] and [1.0, 2.0, 3.0], validation passes @test{"metrics": [1.0, 2.0], "stats": {"mean": 1.5}} and {"metrics": [1.0, 2.0], "stats": {"mean": 1.5}}, validation passes @test{"a": 1.0} and {"b": 1.0}, validation fails with an informative error @test1.0 + 1e-15 and 1.0, with max_ulp=2, validation passes @test1.0 and 1.0 + 1e-14, with max_ulp=2, validation fails @test[1.0, 2.0, 3.0], validation passes with default tolerance @test{"layer1": {"weights": [1.0, 2.0]}, "layer2": {"bias": [0.5]}} and actual={"layer1": {"weights": [1.0 + 1e-15, 2.0]}, "layer2": {"bias": [0.5]}}, with max_ulp=10, validation passes @test[{"loss": 0.1}, {"loss": 0.2}] and actual=[{"loss": 0.1 + 1e-15}, {"loss": 0.2}], with max_ulp=5, validation passes @test@generates
def validate_outputs(expected, actual, max_ulp=1):
"""
Validates that two nested data structures are equivalent within floating-point tolerance.
Args:
expected: Expected output structure (nested dicts, lists, arrays)
actual: Actual output structure to validate
max_ulp: Maximum difference in Units in Last Place (ULP) for floating-point comparison
Raises:
ValueError: If structures don't match or values differ beyond tolerance
"""
passProvides tree comparison utilities with ULP-based floating-point precision handling.
@satisfied-by
Install with Tessl CLI
npx tessl i tessl/pypi-chexevals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10