0

I have a array which has this output and your type is cupy.ndarray:

x = array([[0],
       [0],
       [0],
       ...,
       [0],
       [0],
       [0]])

I want is output:

array([0, 0, 0, ..., 0, 0, 0])

I tried use transpose and np.expand_dims and had the outputs:

x.transpose()

# Output
array([[0, 0, 0, ..., 0, 0, 0]])

np.expand_dims(x, axis=1)

#Output
array([[[0, 0, 0, ..., 0, 0, 0]]])
7
  • [arr[0] for arr in x] Commented Oct 25, 2022 at 20:03
  • 1
    If you just want to make it 1d, x.flatten() Commented Oct 25, 2022 at 20:03
  • Do x = x.reshape(-1). That tells is to keep the same number of elements but make it a 1D array instead of a 2D array. Commented Oct 25, 2022 at 20:03
  • 1
    or x.ravel() so many options. Commented Oct 25, 2022 at 20:04
  • or x.T.squeeze()... Commented Oct 25, 2022 at 20:04

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.