Comments (4)
I can't reproduce the behaviour you are describing. Can you provide a test case for the bug? The following test seems to work correctly:
def test_getitem():
subs = (
array([0, 1, 0, 5, 7, 8]),
array([2, 0, 4, 5, 3, 9]),
array([0, 1, 2, 2, 1, 0])
)
vals = array([1, 2, 3, 4, 5, 6])
S = sptensor(subs, vals, shape=[10, 10, 3])
assert_equal(0, S[1, 1, 1])
assert_equal(0, S[1, 2, 3])
assert_equal(1, S[0, 2, 0])
assert_equal(2, S[1, 0, 1])
assert_equal(3, S[0, 4, 2])
assert_equal(4, S[5, 5, 2])
assert_equal(5, S[7, 3, 1])
assert_equal(6, S[8, 9, 0])
from scikit-tensor.
Hmm your example is working indeed.
But I found that if I use python array instead of numpy array, it won't work. Since it works correctly with ndarray, the bug may be resolved but I think it may be helpful to add a notice for this to docstrings.
Try it like this:
def test_getitem():
subs = (
[0, 1, 0, 5, 7, 8],
[2, 0, 4, 5, 3, 9],
[0, 1, 2, 2, 1, 0]
)
vals = [1, 2, 3, 4, 5, 6]
S = sptensor(subs, vals, shape=[10, 10, 3])
assert_equal(0, S[1, 1, 1])
assert_equal(0, S[1, 2, 3])
assert_equal(1, S[0, 2, 0])
assert_equal(2, S[1, 0, 1])
assert_equal(3, S[0, 4, 2])
assert_equal(4, S[5, 5, 2])
assert_equal(5, S[7, 3, 1])
assert_equal(6, S[8, 9, 0])
from scikit-tensor.
@mnick do you think adding support for lists as indices and values for sparse tensors is worthwhile? Basically something like
if type(subs) != np.ndarray:
subs = np.array(subs)
and the same for vals. Or would it be better to raise an error if the type is not ndarray?
from scikit-tensor.
For now I would prefer the later until the API / functionality matured.
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.