0

I would like to seek a help to convert from a list into the matrix. I have a list of array like this:

output [[[ 0.]
         [ 0.]
         [ 0.]
         [ 1.]]

         [[ 0.]
          [ 0.]
          [ 1.]
          [ 0.]]

         [[ 0.]
          [ 0.]
          [ 1.]
          [ 0.]]]

And I need to convert it in the matrix:

X [matrix([[0],
    [0],
    [0],
    [1]]), matrix([[0],
    [0],
    [1],
    [0]]), matrix([[0],
    [0],
    [1],
    [0]])

Hopefully, somebody may help me. Thank you.

Afir
  • 483
  • 3
  • 15
  • Do you mean `array(x)`? – kabanus Jul 06 '18 at 05:53
  • I mean the output need to be converted into the matrix form. `X [matrix([[0], [0], [0], [1]]), matrix([[0], [0], [1], [0]]), matrix([[0], [0], [1], [0]])` – Afir Jul 06 '18 at 05:58
  • This is quite straight forward: Given, `list = [[[ 0.], [ 0.], [ 0.], [ 1.]], [[ 0.], [ 0.], [ 1.], [ 0.]], [[ 0.], [ 0.], [ 1.], [ 0.]]]` required output: `list_of_mat = [np.matrix(i) for i in list]` – Mankind_008 Jul 06 '18 at 06:15
  • Thank you so much @Mankind_008. That is the good answer. – Afir Jul 06 '18 at 06:46

0 Answers0