Comments (4)
The following patch could work as a solution to this problem:
diff --git a/sktensor/sptensor.py b/sktensor/sptensor.py
index 21baf74..0eacfb6 100644
--- a/sktensor/sptensor.py
+++ b/sktensor/sptensor.py
@@ -134,9 +134,9 @@ class sptensor(tensor_mixin):
# Case 2: result is a vector
if len(remdims) == 1:
- c = accum(nsubs, nvals, shape=nshp)
+ c, s = accum(nsubs, nvals, shape=nshp, with_subs=True)
if len(np.nonzero(c)[0]) <= 0.5 * prod(nshp):
- return sptensor(arange(nshp), c)
+ return sptensor(s, c)
else:
return c
combined with this correction on the function accum:
diff --git a/sktensor/utils.py b/sktensor/utils.py
index b76ad83..ae6fa82 100644
--- a/sktensor/utils.py
+++ b/sktensor/utils.py
@@ -24,7 +24,7 @@ def accum(subs, vals, func=np.sum, sorted=False, shape=None, with_subs=False):
# return results
if with_subs:
- return nvals, subs[idx[:-1]]
+ return nvals, tuple(sub[idx[:-1]] for sub in subs)
else:
return nvals
from scikit-tensor.
Thanks for the bug report. The bug occured because of some API changes for sptensor.
I incorporated your fix in 10116c8 and the test case in 7a7502d.
from scikit-tensor.
Thanks for the fix, Maximilian.
I have another error, that seems related to this, since it occurs when ttv returns a sptensor.
It can be reproduced with this test case:
def test_uttkrp():
subs, vals, shape = mysetup()
S = sptensor(subs, vals, shape)
U = []
for shp in (25, 11, 18, 7, 2):
U.append(np.zeros((shp, 5)))
SU = S.uttkrp(U, mode=0)
assert_equal(SU.shape, (25, 5))
The error is "TypeError: float() argument must be a string or a number", and it happens in sptensor.py, line 191, in uttkrp:
V[:, r] = self.ttv(Z, mode, without=True)
It seems that, when the result of ttv is a sptensor, it cannot be assigned to V using this operation.
Let me know if I should open a new issue report or if you will reopen this one.
from scikit-tensor.
Please open a new issue, as this is a different issue. Thank you!
from scikit-tensor.
Related Issues (20)
- scikit-tensor is creating nans / infinities along the way HOT 1
- `cp_als` fails with `sptensor`---intended behavior?
- hosvd fails for sptensor when using full rank along a mode HOT 2
- 2D array in example code
- Implementation of Unfolding Clarification
- Implementation of CP Alternating Poisson Regression algorithm HOT 4
- "Maximum allowed dimension exceeded" error HOT 1
- setup can't find virtualenv packages
- cp.py _init has off-by-one error HOT 1
- update pypi version
- Example data no longer available at the provided link
- Tucker-2 decomposition HOT 2
- Install not seeming to work. HOT 6
- Installing error HOT 1
- Sptensor wrong check.
- Installation error: SyntaxError: Missing parentheses in call to 'print'. Did you mean print(mod.__version__)? HOT 1
- sktensor.tucker.hooi doesn't return fit, itr and exectimes
- Batch_size problem in using ttm in a custom layer in keras
- Sparse tensor with Tucker
- Does not corresponds to the formula in the paper
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from scikit-tensor.