Advertisement
Guest User

Untitled

a guest
Mar 30th, 2017
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.35 KB | None | 0 0
  1. x1 = np.arange(27.0).reshape((3, 3, 3))
  2. # x1 is (3,3,3)
  3. x2 = x1.min(axis=(1,2))
  4. # x2 is (3,)
  5. (x1 - x2).shape
  6. #Output: (3, 3, 3)
  7.  
  8. (x1 - x2).shape == x1.shape
  9. #As expected: True
  10.  
  11. mat1 = np.random.rand(10,5,2,1)
  12. # mat1 is (10,5,2,1)
  13. mat2 = mat1.min(axis = (1,2,3))
  14. # mat2 is (10,)
  15. (mat1 - mat2).shape == mat1.shape
  16. # Should be True, but
  17. #Output: False
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement