Sum of Every Second Row

0
easy

Given a 2D tensor (matrix) `matrix` as input, return a tensor that has sum of all elements in rows 0, 2, 4,...

To solve this exercise, extract every second row from the given matrix using slicing with a step of 2. Then, compute the sum of each row to get the result.

Examples:

1
2
3
4
5
6
7
8
9
10
3
11
19
1
1
2
2
3
3
4
4
2
6

Loading...
2024 © TensorGym
Contrinbute | Contact | Copyright | 𝕏