Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AssertionError: tensorly.tt_tensor.validate_tt_rank test #529

Closed
mobley-trent opened this issue Sep 17, 2023 · 1 comment
Closed

AssertionError: tensorly.tt_tensor.validate_tt_rank test #529

mobley-trent opened this issue Sep 17, 2023 · 1 comment

Comments

@mobley-trent
Copy link

Describe the bug

The assertion test case for this tt_tensor method is failing when rounding="floor".
Only the test case for rounding="ceil" is passing.

Steps or Code to Reproduce

This is the code from the test case

import numpy as np
import tensorly as tl

coef = 0.2
tensor_shape = tuple(np.random.randint(5, 10, size=4))
n_param_tensor = np.prod(tensor_shape)

rank = tl.tt_tensor.validate_tt_rank(tensor_shape, coef, rounding="floor")
n_param = tl.tt_tensor._tt_n_param(tensor_shape, rank)
np.testing.assert_(n_param >= n_param_tensor * coef)

Expected behavior

The test case is supposed to pass.

Actual result

The test is returning an AssertionError

Versions

Linux-5.15.0-1041-azure-x86_64-with-glibc2.28
Python 3.10.0 (default, Mar 3 2022, 09:58:08) [GCC 7.5.0]
NumPy 1.25.2
SciPy 1.11.2
JAX 0.4.14
PyTorch 2.0.1+cpu
TensorFlow 2.13.0
TensorLy 0.8.1

@JeanKossaifi
Copy link
Member

JeanKossaifi commented Sep 19, 2023

@mobley-trent this is not the code from the test, you changed only the rounding but not the check. You should change the check too if you want to use floor - you'd want to change the greater or equal to lower or equal since you're rounding down now instead of up.

The actual test-case is

   # Rounding = floor
    rank = validate_tt_rank(tensor_shape, rank=coef, rounding="floor")
    n_param = _tt_n_param(tensor_shape, rank)
    assert_(n_param <= n_param_tensor * coef)

See, test-file. All the tests are run at each new commit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants