-
Notifications
You must be signed in to change notification settings - Fork 0
/
DataExamples.py
49 lines (37 loc) · 1.67 KB
/
DataExamples.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
from __future__ import absolute_import, division, print_function, unicode_literals
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
def preprocessdata(_train_images, _train_labels, _test_images, _class_names):
######################### Pre-Processing Data ########################
response = input("What Training Image do you want to use as an example? (1-60,000) ")
plt.figure()
plt.imshow(_train_images[response]) #Training Image 1
plt.colorbar()
plt.grid(False)
plt.savefig('Pre-Processed Data Test.png')
print("Created 'Pre-Processed Data Test.png'\n")
#The values must be in a range of 0 to 1 before feeding to the neural network model
_train_images = _train_images / 255.0
_test_images = _test_images / 255.0
plt.figure()
plt.imshow(_train_images[response]) #Training Image 1
plt.colorbar()
plt.grid(False)
plt.savefig('Pre-Processed Training Data.png')
print("Created 'Pre-Processed Training Data.png'\n")
#######################################################################
####################### Training Data Example #########################
plt.figure(figsize=(10,10))
for i in range(25):
plt.subplot(5,5,i+1)
plt.xticks([])
plt.yticks([])
plt.grid(False)
plt.imshow(_train_images[i], cmap=plt.cm.binary)
plt.xlabel(_class_names[_train_labels[i]])
plt.savefig('Training Data Set Example.png')
print("Created 'Training Data Set Example.png'\n")
#######################################################################
exit = raw_input("\nPress any key to Exit! ")
return _train_images, _test_images