Mathjs: Can we subset or slice Matrix like Numpy?

Created on 10 Sep 2018  路  2Comments  路  Source: josdejong/mathjs

Hello,

Is it possible to slice a matrix (tensor) like in Numpy with Math.js? To give you examples,

train_image.shape # MNIST image data saved as a Tensor with shape (60000, 28, 28)
train_image[10: 100] # 1. Retrieve 10th ~ 99th MNIST digits
train_images[128 * n:128 * (n + 1)] # 2. getting an nth batch

What's the best way to achieve this?
1) Can you do this using math.subset?
2) Should we create another function named slice?
3) Is it better to do this outside of Math.js?

feature help wanted

Most helpful comment

Yes something like that would be cool. We had a similar discussion long time ago, see #54

All 2 comments

Yes something like that would be cool. We had a similar discussion long time ago, see #54

For reference: mathjs supports ranges like A[10: 100] and A[2: end - 2] right now, but does not offer more complicated slicing like you suggest.

See examples in the docs: http://mathjs.org/docs/expressions/syntax.html#matrices

Was this page helpful?
0 / 5 - 0 ratings