title: Convert a 2d matrix to a 3d one hot matrix numpy
body: <p>I have np matrix and I want to convert it to a 3d array with one hot encoding of the elements as third dimension. Is there a way to do with without looping over each row 
  eg</p>
  
  <pre><code>a=[[1,3],
     [2,4]]
  </code></pre>
  
  <p>should be made into</p>
  
  <pre><code>b=[[1,0,0,0], [0,0,1,0],
     [0,1,0,0], [0,0,0,1]]
  </code></pre>