-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Closed
Milestone
Description
I am curious whats a negative index in System.Numerics.Tensors represents ?
var arrayA = new[, ,]
{
{
{0, 1, 2},
{3, 4, 5}
},
{
{6, 7 ,8 },
{9, 10 ,11 },
},
{
{12, 13 ,14 },
{15, 16 ,17 },
},
{
{18, 19 ,20 },
{21, 22 ,23 },
}
};
var tensorA = arrayA.ToTensor<int>(); // tensorA shape (4, 2, 3)
var y = tensorA[2, -1, -2]; // **7**
var z = tensorA[0, -1, -2]; // **throws error**
I was trying to draw parallels with numpy. Numpy results made sense.
a = np.array([ [[0,1,2], [3,4,5]], [[6,7,8], [9,10,11]], [[12,13,14],[15,16,17]]])
y = a[2,-1,-2] # 16, looks ok
z = a[0,-1,-2] # 4, looks ok
Reactions are currently unavailable