-
Notifications
You must be signed in to change notification settings - Fork 8
/
transform_files.py
37 lines (26 loc) · 989 Bytes
/
transform_files.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
import numpy
from tempfile import TemporaryFile
nb_training_examples = 15000
nb_test_examples = 6000
nb_classes = 3
save_directory = 'saved_data'
a = numpy.fromfile('%s/X_train.txt' % save_directory,sep=" ")
b = numpy.reshape(a,[nb_training_examples,nb_classes])
outfile = open('%s/X_train.npy' % save_directory,'wb')
numpy.save(outfile, b)
outfile.close()
a = numpy.fromfile('%s/X_test.txt' % save_directory,sep=" ")
b = numpy.reshape(a,[nb_test_examples,nb_classes])
outfile = open('%s/X_test.npy' % save_directory,'wb')
numpy.save(outfile, b)
outfile.close()
a = numpy.fromfile('%s/Y_train.txt' % save_directory,sep=" ")
b = numpy.reshape(a,[nb_training_examples,nb_classes])
outfile = open('%s/Y_train.npy' % save_directory,'wb')
numpy.save(outfile, b)
outfile.close()
a = numpy.fromfile('%s/Y_test.txt' % save_directory,sep=" ")
b = numpy.reshape(a,[nb_test_examples,nb_classes])
outfile = open('%s/Y_test.npy' % save_directory,'wb')
numpy.save(outfile, b)
outfile.close()