0

Assume there is a list that includes a numpy array such as

import numpy as np output = [np.array([[[5.21]], [[2.22]], [[1.10]], [[3.76]]], dtype=np.float32)] 

Is there any quick way to extract values from this output list such as

result = [5.21, 2.22, 1.10, 3.76] 

many thanks

2
  • 1
    list(output[0][0:,0].flatten()) Commented Jan 11, 2022 at 1:44
  • 2
    Think in steps. First get the array out of the list. Then convert the array to 1d. Finally use tolist to get a list. Commented Jan 11, 2022 at 1:45

1 Answer 1

2

Yes. Try this

result = output[0].reshape(1,-1).flatten().tolist() 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.