Guest User

Untitled

a guest
Nov 14th, 2018
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. #used to create the patches
  2.  
  3. import numpy as np
  4. import h5py
  5. import patches
  6.  
  7. fname = 'all_images.hdf5'
  8. patch_sizes = [(7, 7)]
  9.  
  10. f = h5py.File(fname,'r')
  11.  
  12. # List all groups
  13. print("Keys: %s" % f.keys())
  14.  
  15. # Get the data
  16. X = f['X']
  17. y = f['y']
  18.  
  19. print(X.shape)
  20. print(y.shape)
  21.  
  22. # Get one row of 7x7 patches
  23.  
  24. uniques, ids = np.unique(y, return_inverse=True)
  25.  
  26. print(uniques)
  27.  
  28. for patch_size in patch_sizes:
  29. fname = str(patch_size[0]) + "_" + str(patch_size[1])
  30. fname += ".data"
  31. fname += ".csv"
  32.  
  33. # 4. Create patches.
  34. patches.save_patches(X, y, fname, patch_size, ignore_class=0)
  35.  
  36. f.close()
Add Comment
Please, Sign In to add comment