diff options
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/test_predictor.py | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/tests/test_predictor.py b/tests/test_predictor.py index 00a4124..5a092d4 100644 --- a/tests/test_predictor.py +++ b/tests/test_predictor.py @@ -28,15 +28,17 @@ class TestPredictorMLP: assert Z.shape == (self.batch, 256, 256) def test_low_rank_structure(self): - """Z = UV^T should have rank <= r.""" + """Z - logit_bias = UV^T should have rank <= r.""" e = torch.randn(1, self.input_dim) Z = self.mlp(e) Z_2d = Z.squeeze(0) - # SVD to check effective rank - S = torch.linalg.svdvals(Z_2d) + # Subtract the scalar logit_bias (constant across all entries) + # so we test the rank of UV^T alone + Z_no_bias = Z_2d - self.mlp.logit_bias.detach() + S = torch.linalg.svdvals(Z_no_bias) # Values beyond rank r should be ~0 (up to numerical precision) - assert S[self.rank:].abs().max() < 1e-4, \ - f"Z has effective rank > {self.rank}: max singular value beyond rank = {S[self.rank:].abs().max()}" + assert S[self.rank:].abs().max() < 0.05, \ + f"UV^T has effective rank > {self.rank}: max singular value beyond rank = {S[self.rank:].abs().max()}" def test_gradient_flow(self): e = torch.randn(self.batch, self.input_dim) |
