You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Below are the current outputs from tensor.mttkrp in pyttb and the Matlab Tensor Toolbox. For dimensions 0, 3, 4, pyttb works, but the other dimensions throw a ValueError during the reshape of the khatrirao product.
pyttb:
>>> T = ttb.tensor.from_data(np.arange(1,np.prod(shape)+1), shape)
>>> U = [];
>>> for s in shape: U.append(np.ones((s,2)))
...
>>> T.mttkrp(U,0)
array([[129600., 129600.],
[129960., 129960.]])
>>> T.mttkrp(U,1)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\dmdunla\dev\github.com\pyttb\pyttb\tensor.py", line 603, in mttkrp
Ur = np.reshape(ttb.khatrirao(U[0:self.ndims - 2], reverse=True), (szl, 1, R), order='F')
File "<__array_function__ internals>", line 5, in reshape
File "C:\Users\dmdunla\Anaconda3\lib\site-packages\numpy\core\fromnumeric.py", line 299, in reshape
return _wrapfunc(a, 'reshape', newshape, order=order)
File "C:\Users\dmdunla\Anaconda3\lib\site-packages\numpy\core\fromnumeric.py", line 58, in _wrapfunc
return bound(*args, **kwds)
ValueError: cannot reshape array of size 48 into shape (2,1,2)
>>> T.mttkrp(U,2)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\dmdunla\dev\github.com\pyttb\pyttb\tensor.py", line 603, in mttkrp
Ur = np.reshape(ttb.khatrirao(U[0:self.ndims - 2], reverse=True), (szl, 1, R), order='F')
File "<__array_function__ internals>", line 5, in reshape
File "C:\Users\dmdunla\Anaconda3\lib\site-packages\numpy\core\fromnumeric.py", line 299, in reshape
return _wrapfunc(a, 'reshape', newshape, order=order)
File "C:\Users\dmdunla\Anaconda3\lib\site-packages\numpy\core\fromnumeric.py", line 58, in _wrapfunc
return bound(*args, **kwds)
ValueError: cannot reshape array of size 48 into shape (6,1,2)
>>> T.mttkrp(U,3)
array([[45000., 45000.],
[48456., 48456.],
[51912., 51912.],
[55368., 55368.],
[58824., 58824.]])
>>> T.mttkrp(U,4)
array([[ 7260., 7260.],
[21660., 21660.],
[36060., 36060.],
[50460., 50460.],
[64860., 64860.],
[79260., 79260.]])
Matlab:
>> T = tensor(1:prod(shape),shape);
>> U = {}; for i = 1:length(shape), U{i} = ones(shape(i),2); end
>> mttkrp(T,U,1)
ans =
129600 129600
129960 129960
>> mttkrp(T,U,2)
ans =
86040 86040
86520 86520
87000 87000
>> mttkrp(T,U,3)
ans =
63270 63270
64350 64350
65430 65430
66510 66510
>> mttkrp(T,U,4)
ans =
45000 45000
48456 48456
51912 51912
55368 55368
58824 58824
>> mttkrp(T,U,5)
ans =
7260 7260
21660 21660
36060 36060
50460 50460
64860 64860
79260 79260
The text was updated successfully, but these errors were encountered:
Below are the current outputs from
tensor.mttkrp
inpyttb
and the Matlab Tensor Toolbox. For dimensions 0, 3, 4,pyttb
works, but the other dimensions throw aValueError
during the reshape of thekhatrirao
product.pyttb
:Matlab:
The text was updated successfully, but these errors were encountered: