Advertisement
Guest User

Untitled

a guest
Nov 28th, 2017
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.98 KB | None | 0 0
  1. import numpy as np
  2. import matplotlib.pyplot as plt
  3. try:
  4. from scipy import misc
  5. except ImportError:
  6. !pip install scipy
  7. from scipy import misc
  8.  
  9. import tensorflow as tf
  10. import numpy as np
  11. import imageio
  12. import matplotlib.pyplot as plt
  13. try:
  14. from scipy import misc
  15. except ImportError:
  16. !pip install scipy
  17. from scipy import misc
  18.  
  19. training_size = 265
  20. col_row = 400
  21. img_size = 400*400
  22. training_data = np.empty(shape=(training_size, 400*400))
  23.  
  24. import glob
  25. i = 0
  26. for filename in glob.glob('C:/Mah/TensorPalms/Train/*.jpg'):
  27. image = imageio.imread(filename)
  28. print(image.shape)
  29. training_data[i] = image.reshape(-1)
  30. i+=1
  31.  
  32. #label
  33.  
  34. a= [0,0,0,0,0,
  35. 1,1,1,1,1,
  36. 2,2,2,2,2,
  37. 3,3,3,3,3,
  38. 4,4,4,4,4,
  39. 5,5,5,5,5,
  40. 6,6,6,6,6,
  41. 7,7,7,7,7,
  42. 8,8,8,8,8,
  43. 9,9,9,9,9,
  44. 10,10,10,10,10,
  45. 11,11,11,11,11,
  46. 12,12,12,12,12,
  47. 13,13,13,13,13,
  48. 14,14,14,14,14,
  49. 15,15,15,15,15,
  50. 16,16,16,16,16,
  51. 17,17,17,17,17,
  52. 18,18,18,18,18,
  53. 19,19,19,19,19,
  54. 20,20,20,20,20,
  55. 21,21,21,21,21,
  56. 22,22,22,22,22,
  57. 23,23,23,23,23,
  58. 24,24,24,24,24,
  59. 25,25,25,25,25,
  60. 26,26,26,26,26,
  61. 27,27,27,27,27,
  62. 28,28,28,28,28,
  63. 29,29,29,29,29,
  64. 30,30,30,30,30,
  65. 31,31,31,31,31,
  66. 32,32,32,32,32,
  67. 33,33,33,33,33,
  68. 34,34,34,34,34,
  69. 35,35,35,35,35,
  70. 36,36,36,36,36,
  71. 37,37,37,37,37,
  72. 38,38,38,38,38,
  73. 39,39,39,39,39,
  74. 40,40,40,40,40,
  75. 41,41,41,41,41,
  76. 42,42,42,42,42,
  77. 43,43,43,43,43,
  78. 44,44,44,44,44,
  79. 45,45,45,45,45,
  80. 46,46,46,46,46,
  81. 47,47,47,47,47,
  82. 48,48,48,48,48,
  83. 49,49,49,49,49,
  84. 50,50,50,50,50,
  85. 51,51,51,51,51,
  86. 52,52,52,52,52,]
  87.  
  88.  
  89. b = tf.one_hot(a,53)
  90. sess = tf.Session()
  91. sess.run(b)
  92.  
  93. print(b.shape)
  94.  
  95. from sklearn.preprocessing import OneHotEncoder
  96. training_label = OneHotEncoder(sparse=False).fit_transform(np.asarray(a).reshape(-1, 1))
  97. print(training_label)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement