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

cp_als giving many errors about data not being F-ordered #371

Closed
tgkolda opened this issue Dec 24, 2024 · 2 comments
Closed

cp_als giving many errors about data not being F-ordered #371

tgkolda opened this issue Dec 24, 2024 · 2 comments

Comments

@tgkolda
Copy link
Collaborator

tgkolda commented Dec 24, 2024

Here is the code that is giving errors with the current development version:

from scipy.io import loadmat
import requests
from io import BytesIO

# Download the MATLAB file from the URL
url = "https://gitlab.com/tensors/tensor_data_eem/-/raw/master/EEM18.mat?ref_type=heads&inline=false"
response = requests.get(url)
mat_data = loadmat(BytesIO(response.content))

# Convert the MATLAB tensor to a PyTTB tensor
X_mat = mat_data['X']
data = X_mat[0,0][0]
X = ttb.tensor(data, data.shape)

num_runs = 5
Xnrm = X.norm()
ranks = np.arange(1, 6)
errors_matrix = np.zeros((len(ranks), num_runs))
seeds = np.zeros((len(ranks), num_runs), dtype=int)
np.random.seed(0)
for i, r in enumerate(ranks):
    for run in range(num_runs):
        seed = np.random.randint(1, 10000000)
        seeds[i, run] = seed
        np.random.seed(seed)
        
        P, _, info = ttb.cp_als(X, r, printitn=0)
        Pfull = P.full()
        Diff = X - Pfull
        Diffnrm = Diff.norm()
        errors_matrix[i, run] = Diffnrm / Xnrm

print("Errors Matrix (Rank x Run):")
print(errors_matrix)
print("Seeds Matrix (Rank x Run):")
print(seeds)
@tgkolda
Copy link
Collaborator Author

tgkolda commented Dec 24, 2024

It looks like pyttb is depending on the user to make the data F-ordered before handing it over?

@ntjohnson1
Copy link
Collaborator

Duplicate of #368 there were a few internal calls that I didn't update correctly. Everything was functionally fine but hit the warning because we were trying to reduce unnecessary copies.

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