Skip to content

cp_als with option printitn=0 causes ZeroDivisionError #235

@jeremy-myers

Description

@jeremy-myers

Minimal working example:

R = 3
np.random.seed(0)  # Set seed for reproducibility
X = ttb.tensor(np.random.rand(6,8,10), shape=(6,8,10))
M = ttb.cp_als(X, R, printitn=0)

ZeroDivisionError                         Traceback (most recent call last)
Cell In[83], line 1
----> 1 M = ttb.cp_als(X, R, printitn=0)

File ~/pyttb/pyttb/cp_als.py:241, in cp_als(input_tensor, rank, stoptol, maxiters, dimorder, init, printitn, fixsigns)
    238 else:
    239     flag = 1
--> 241 if (divmod(iteration, printitn)[1] == 0) or (printitn > 0 and flag == 0):
    242     print(f" Iter {iteration}: f = {fit:e} f-delta = {fitchange:7.1e}")
    244 # Check for convergence

ZeroDivisionError: integer division or modulo by zero

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions