Reputation: 3621
I have a set of manufactured data (generated from an explicit mathematical function) stored in a 3-dimensional tensor called A
.
When I try to run parafac, I receive the following:
Traceback (most recent call last):
File "./ParafacPrintValues.py", line 145, in <module>
A1, A2, A3 = parafac(A,2)
ValueError: not enough values to unpack (expected 3, got 2)
I am importing parafac like this:
from tensorly.decomposition import parafac
I installed (and just updated, again) the tensorly library with:
pip3 install -U tensorly
However, when I run the identical code in a Jupyter notebook, it works as expected. It appears that there is a difference between what I have installed via Pip and what is in the IPython of the Jupyter notebook. Can anyone help?
Upvotes: 1
Views: 304
Reputation: 375
In the latest version of TensorLy, parafac returns a CPTensor that acts as a tuple (weight, factors) : in addition to the factors of the decomposition, you also get a vector of weights. This is because the CP decomposition expresses the original tensor as a weighted sum of rank-1 tensors.
In other words, if you are using the latest version of TensorLy, your code should be either:
weights, factors = parafac(tensor, rank)
or, if you want to explicitly store each factor in a variable as in your example:
weights, (A1, A2, A3) = parafac(tensor, rank)
Upvotes: 1